@dialpad/eslint-plugin-dialtone 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +19 -0
- package/README.md +46 -0
- package/docs/rules/old-dialtone-icons.md +35 -0
- package/lib/index.js +22 -0
- package/lib/rules/old-dialtone-icons.js +50 -0
- package/package.json +60 -0
- package/tests/lib/rules/old-dialtone-icons.js +31 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
root: true,
|
|
5
|
+
extends: [
|
|
6
|
+
"eslint:recommended",
|
|
7
|
+
"plugin:eslint-plugin/recommended",
|
|
8
|
+
"plugin:node/recommended",
|
|
9
|
+
],
|
|
10
|
+
env: {
|
|
11
|
+
node: true,
|
|
12
|
+
},
|
|
13
|
+
overrides: [
|
|
14
|
+
{
|
|
15
|
+
files: ["tests/**/*.js"],
|
|
16
|
+
env: { mocha: true },
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# eslint-plugin-dialtone
|
|
2
|
+
|
|
3
|
+
dialtone eslint plugin
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You'll first need to install [ESLint](https://eslint.org/):
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i eslint --save-dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Next, install `@dialpad/eslint-plugin-dialtone`:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @dialpad/eslint-plugin-dialtone --save-dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Add `@dialpad/dialtone` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"plugins": [
|
|
26
|
+
"@dialpad/dialtone"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Then configure the rules you want to use under the rules section.
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"rules": {
|
|
37
|
+
"@dialpad/dialtone/rule-name": 2
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Supported Rules
|
|
43
|
+
|
|
44
|
+
* Fill in provided rules here
|
|
45
|
+
|
|
46
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Finds and warns about old dialtone icons usage (old-dialtone-icons)
|
|
2
|
+
|
|
3
|
+
Please describe the origin of the rule here.
|
|
4
|
+
|
|
5
|
+
## Rule Details
|
|
6
|
+
|
|
7
|
+
This rule aims to...
|
|
8
|
+
|
|
9
|
+
Examples of **incorrect** code for this rule:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
|
|
13
|
+
// fill me in
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Examples of **correct** code for this rule:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
|
|
21
|
+
// fill me in
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Options
|
|
26
|
+
|
|
27
|
+
If there are any options, describe them here. Otherwise, delete this section.
|
|
28
|
+
|
|
29
|
+
## When Not To Use It
|
|
30
|
+
|
|
31
|
+
Give a short description of when it would be appropriate to turn off this rule.
|
|
32
|
+
|
|
33
|
+
## Further Reading
|
|
34
|
+
|
|
35
|
+
If there are other links that describe the issue this rule addresses, please include them here in a bulleted list.
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview dialtone eslint plugin
|
|
3
|
+
* @author julio ortega
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
//------------------------------------------------------------------------------
|
|
8
|
+
// Requirements
|
|
9
|
+
//------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const requireIndex = require("requireindex");
|
|
12
|
+
|
|
13
|
+
//------------------------------------------------------------------------------
|
|
14
|
+
// Plugin Definition
|
|
15
|
+
//------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// import all rules in lib/rules
|
|
19
|
+
module.exports.rules = requireIndex(__dirname + "/rules");
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Finds and warns about old dialtone icons usage
|
|
3
|
+
* @author julio ortega
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
//------------------------------------------------------------------------------
|
|
8
|
+
// Rule Definition
|
|
9
|
+
//------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
/** @type {import('eslint').Rule.RuleModule} */
|
|
12
|
+
module.exports = {
|
|
13
|
+
meta: {
|
|
14
|
+
type: 'suggestion', // `problem`, `suggestion`, or `layout`
|
|
15
|
+
docs: {
|
|
16
|
+
description: "Finds and warns about old dialtone icons usage",
|
|
17
|
+
recommended: false,
|
|
18
|
+
url: null, // URL to the documentation page for this rule
|
|
19
|
+
},
|
|
20
|
+
fixable: null, // Or `code` or `whitespace`
|
|
21
|
+
schema: [], // Add a schema if the rule has options
|
|
22
|
+
messages: {
|
|
23
|
+
avoidImport: "Avoid usage of old dialtone icons [deprecated]. Check https://dialpad.design",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
create(context) {
|
|
27
|
+
// variables should be defined here
|
|
28
|
+
|
|
29
|
+
//----------------------------------------------------------------------
|
|
30
|
+
// Helpers
|
|
31
|
+
//----------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
// any helper functions should go here or else delete this section
|
|
34
|
+
|
|
35
|
+
//----------------------------------------------------------------------
|
|
36
|
+
// Public
|
|
37
|
+
//----------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
ImportDeclaration(node) {
|
|
41
|
+
if (node.source.value.includes('@dialpad/dialtone/lib/build')) {
|
|
42
|
+
context.report({
|
|
43
|
+
node: node,
|
|
44
|
+
messageId: "avoidImport",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dialpad/eslint-plugin-dialtone",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "dialtone eslint plugin",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Dialpad",
|
|
7
|
+
"Dialtone",
|
|
8
|
+
"eslint",
|
|
9
|
+
"eslintplugin",
|
|
10
|
+
"eslint-plugin"
|
|
11
|
+
],
|
|
12
|
+
"contributors": [
|
|
13
|
+
{
|
|
14
|
+
"name": "Brad Paugh",
|
|
15
|
+
"email": "brad.paugh@dialpad.com",
|
|
16
|
+
"url": "https://github.com/braddialpad"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Francis Rupert",
|
|
20
|
+
"email": "francis.rupert@dialpad.com",
|
|
21
|
+
"url": "https://github.com/francisrupert"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Julio Ortega",
|
|
25
|
+
"email": "julio.ortega@dialpad.com",
|
|
26
|
+
"url": "https://github.com/juliodialpad"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Jose Silva",
|
|
30
|
+
"email": "jose.silva@dialpad.com",
|
|
31
|
+
"url": "https://github.com/josedialpad"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"repository": "git@github.com:dialpad/eslint-plugin-dialtone.git",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"email": "dialtone@dialpad.com"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"main": "./lib/index.js",
|
|
40
|
+
"exports": "./lib/index.js",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"test": "mocha tests --recursive"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"requireindex": "^1.2.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"eslint": "^8.19.0",
|
|
50
|
+
"eslint-plugin-eslint-plugin": "^5.0.0",
|
|
51
|
+
"eslint-plugin-node": "^11.1.0",
|
|
52
|
+
"mocha": "^10.0.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"eslint": ">=7"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Finds and warns about old dialtone icons usage
|
|
3
|
+
* @author julio ortega
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
//------------------------------------------------------------------------------
|
|
8
|
+
// Requirements
|
|
9
|
+
//------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
const rule = require("../../../lib/rules/old-dialtone-icons"),
|
|
12
|
+
RuleTester = require("eslint").RuleTester;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
//------------------------------------------------------------------------------
|
|
16
|
+
// Tests
|
|
17
|
+
//------------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const ruleTester = new RuleTester();
|
|
20
|
+
ruleTester.run("old-dialtone-icons", rule, {
|
|
21
|
+
valid: [
|
|
22
|
+
// give me some code that won't trigger a warning
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
invalid: [
|
|
26
|
+
{
|
|
27
|
+
code: "import svgLockIcon from '@dialpad/dialtone/lib/build/svg/system/lock.svg';",
|
|
28
|
+
errors: [{ message: "Fill me in.", type: "Me too" }],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|