@dialpad/eslint-plugin-dialtone 1.0.2 → 1.1.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/docs/rules/{old-svg-icons.md → deprecated-icons.md} +13 -2
- package/lib/rules/{old-svg-icons.js → deprecated-icons.js} +7 -14
- package/package.json +1 -1
- package/tests/lib/rules/{old-svg-icons.js → deprecated-icons.js} +24 -7
- package/docs/rules/old-vue-icons.md +0 -21
- package/lib/rules/old-vue-icons.js +0 -50
- package/tests/lib/rules/old-vue-icons.js +0 -34
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Finds
|
|
1
|
+
# Finds deprecated dialtone svg and vue icons usage (deprecated-icons)
|
|
2
2
|
|
|
3
3
|
We separated icons from dialtone into dialtone-icons repo,
|
|
4
|
-
so we are deprecating old svg icons on dialtone once the migrations are finished.
|
|
4
|
+
so we are deprecating old svg and vue icons on dialtone once the migrations are finished.
|
|
5
5
|
|
|
6
6
|
## Rule Details
|
|
7
7
|
|
|
@@ -12,6 +12,8 @@ Examples of **incorrect** code for this rule:
|
|
|
12
12
|
```js
|
|
13
13
|
import svgLockIcon from '@dialpad/dialtone/lib/build/svg/system/lock.svg';
|
|
14
14
|
import svgLockIcon from '../node_modules/@dialpad/dialtone/lib/dist/svg/system/lock.svg';
|
|
15
|
+
import IconSettings from '@dialpad/dialtone/vue/icons/IconSettings';
|
|
16
|
+
import IconSettings from '../node_modules/@dialpad/dialtone/vue/icons/IconSettings';
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
Examples of **correct** code for this rule:
|
|
@@ -26,3 +28,12 @@ import svgLockIcon from '@dialpad/dialtone-icons/dist/svg/lock.svg';
|
|
|
26
28
|
import { DtIcon } from '@dialpad/dialtone-vue';
|
|
27
29
|
<dt-icon name="lock" />
|
|
28
30
|
```
|
|
31
|
+
|
|
32
|
+
## Exceptions
|
|
33
|
+
|
|
34
|
+
For now, we are allowing the importing of `brand` and `spot illustrations` icons from dialtone, so this rule will not trigger if you import an
|
|
35
|
+
icon like:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import dialpadAiIcon from '../../node_modules/@dialpad/dialtone/lib/build/svg/brand/dialpad-ai.svg';
|
|
39
|
+
```
|
|
@@ -13,37 +13,30 @@ module.exports = {
|
|
|
13
13
|
meta: {
|
|
14
14
|
type: 'suggestion', // `problem`, `suggestion`, or `layout`
|
|
15
15
|
docs: {
|
|
16
|
-
description: 'Finds
|
|
16
|
+
description: 'Finds deprecated svg and vue icon imports from dialtone',
|
|
17
17
|
recommended: false,
|
|
18
|
-
url: 'https://github.com/dialpad/eslint-plugin-dialtone/blob/main/docs/rules/
|
|
18
|
+
url: 'https://github.com/dialpad/eslint-plugin-dialtone/blob/main/docs/rules/deprecated-icons.md', // URL to the documentation page for this rule
|
|
19
19
|
},
|
|
20
20
|
fixable: null, // Or `code` or `whitespace`
|
|
21
21
|
schema: [], // Add a schema if the rule has options
|
|
22
22
|
messages: {
|
|
23
|
-
|
|
23
|
+
avoidDeprecatedImport: 'Avoid usage of old dialtone icons [deprecated]. Check https://dialpad.design/components/icon.html for details.',
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
26
|
create(context) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//----------------------------------------------------------------------
|
|
30
|
-
// Helpers
|
|
31
|
-
//----------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
// any helper functions should go here or else delete this section
|
|
34
|
-
|
|
27
|
+
const iconRegex = /.*@dialpad\/dialtone\/(vue\/.*|.+\.svg)/gm;
|
|
35
28
|
//----------------------------------------------------------------------
|
|
36
29
|
// Public
|
|
37
30
|
//----------------------------------------------------------------------
|
|
38
31
|
|
|
39
32
|
return {
|
|
40
33
|
ImportDeclaration(node) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
34
|
+
const matched = iconRegex.exec(node.source.value.toLowerCase());
|
|
35
|
+
if (!matched ||matched.input.includes('/brand/') || matched.input.includes('/spot/')) return;
|
|
43
36
|
|
|
44
37
|
context.report({
|
|
45
38
|
node: node,
|
|
46
|
-
messageId: '
|
|
39
|
+
messageId: 'avoidDeprecatedImport',
|
|
47
40
|
});
|
|
48
41
|
}
|
|
49
42
|
};
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// Requirements
|
|
9
9
|
//------------------------------------------------------------------------------
|
|
10
10
|
|
|
11
|
-
const rule = require("../../../lib/rules/
|
|
11
|
+
const rule = require("../../../lib/rules/deprecated-icons"), RuleTester = require("eslint").RuleTester;
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
//------------------------------------------------------------------------------
|
|
@@ -16,12 +16,20 @@ const rule = require("../../../lib/rules/old-svg-icons"), RuleTester = require("
|
|
|
16
16
|
//------------------------------------------------------------------------------
|
|
17
17
|
|
|
18
18
|
const ruleTester = new RuleTester({parserOptions: {sourceType: 'module', ecmaVersion: 'latest'}});
|
|
19
|
-
ruleTester.run("
|
|
19
|
+
ruleTester.run("deprecated-icons", rule, {
|
|
20
20
|
valid: [
|
|
21
21
|
{
|
|
22
22
|
name: 'New icon import',
|
|
23
23
|
code: "import svgLockIcon from '@dialpad/dialtone-icons/dist/svg/lock.svg';",
|
|
24
24
|
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Brand icon import',
|
|
27
|
+
code: "import dialpadAiIcon from '../../node_modules/@dialpad/dialtone/lib/build/svg/brand/dialpad-ai.svg';",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Spot illustration import',
|
|
31
|
+
code: "import SpotBrowserTableGraph from '@dialpad/dialtone/vue/spot/SpotBrowserTableGraph';",
|
|
32
|
+
},
|
|
25
33
|
{
|
|
26
34
|
name: 'Dialtone Styles import',
|
|
27
35
|
code: "import dialtoneCSS from '@dialpad/dialtone/lib/build/less/dialtone.less';",
|
|
@@ -30,22 +38,31 @@ ruleTester.run("old-svg-icons", rule, {
|
|
|
30
38
|
|
|
31
39
|
invalid: [
|
|
32
40
|
{
|
|
33
|
-
name: 'Old icon import from build',
|
|
41
|
+
name: 'Old SVG icon import from build',
|
|
34
42
|
code: "import svgLockIcon from '../node_modules/@dialpad/dialtone/lib/build/svg/system/lock.svg';",
|
|
35
43
|
errors: [
|
|
36
44
|
{
|
|
37
|
-
messageId: "
|
|
45
|
+
messageId: "avoidDeprecatedImport"
|
|
38
46
|
}
|
|
39
47
|
],
|
|
40
48
|
},
|
|
41
49
|
{
|
|
42
|
-
name: 'Old icon import from dist',
|
|
50
|
+
name: 'Old SVG icon import from dist',
|
|
43
51
|
code: "import svgLockIcon from '../node_modules/@dialpad/dialtone/lib/dist/svg/system/lock.svg';",
|
|
44
52
|
errors: [
|
|
45
53
|
{
|
|
46
|
-
messageId: "
|
|
54
|
+
messageId: "avoidDeprecatedImport"
|
|
47
55
|
}
|
|
48
56
|
],
|
|
49
|
-
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'Old VUE icon import',
|
|
60
|
+
code: "import IconSettings from '@dialpad/dialtone/vue/icons/IconSettings';",
|
|
61
|
+
errors: [
|
|
62
|
+
{
|
|
63
|
+
messageId: "avoidDeprecatedImport"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
},
|
|
50
67
|
],
|
|
51
68
|
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Finds old dialtone vue icons usage (old-vue-icons)
|
|
2
|
-
|
|
3
|
-
We separated icons from dialtone into dialtone-icons repo,
|
|
4
|
-
so we are deprecating old vue icons on dialtone once the migrations are finished.
|
|
5
|
-
|
|
6
|
-
## Rule Details
|
|
7
|
-
|
|
8
|
-
This rule aims to inform developers that they're importing icons from dialtone instead of using dtIcon component from dialtone-vue.
|
|
9
|
-
|
|
10
|
-
Examples of **incorrect** code for this rule:
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
import IconSettings from '@dialpad/dialtone/vue/icons/IconSettings';
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Examples of **correct** code for this rule:
|
|
17
|
-
|
|
18
|
-
```js
|
|
19
|
-
import { DtIcon } from '@dialpad/dialtone-vue';
|
|
20
|
-
<dt-icon name="settings" />
|
|
21
|
-
```
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Finds old dialtone vue 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 old vue icons imports from dialtone',
|
|
17
|
-
recommended: false,
|
|
18
|
-
url: 'https://github.com/dialpad/eslint-plugin-dialtone/blob/main/docs/rules/old-vue-icons.md', // 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
|
-
avoidVueImport: 'Avoid usage of old dialtone vue icons [deprecated]. Use DtIcon component instead https://vue.dialpad.design/?path=/docs/components-icon--default'
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
create(context) {
|
|
28
|
-
// variables should be defined here
|
|
29
|
-
|
|
30
|
-
//----------------------------------------------------------------------
|
|
31
|
-
// Helpers
|
|
32
|
-
//----------------------------------------------------------------------
|
|
33
|
-
|
|
34
|
-
// any helper functions should go here or else delete this section
|
|
35
|
-
|
|
36
|
-
//----------------------------------------------------------------------
|
|
37
|
-
// Public
|
|
38
|
-
//----------------------------------------------------------------------
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
ImportDeclaration(node) {
|
|
42
|
-
if (!node.source.value.toLowerCase().includes('@dialpad/dialtone/vue')) return;
|
|
43
|
-
context.report({
|
|
44
|
-
node: node,
|
|
45
|
-
messageId: 'avoidVueImport',
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Finds old dialtone vue icons usage
|
|
3
|
-
* @author julio ortega
|
|
4
|
-
*/
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
//------------------------------------------------------------------------------
|
|
8
|
-
// Requirements
|
|
9
|
-
//------------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
const rule = require("../../../lib/rules/old-vue-icons"), RuleTester = require("eslint").RuleTester;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//------------------------------------------------------------------------------
|
|
15
|
-
// Tests
|
|
16
|
-
//------------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
const ruleTester = new RuleTester({parserOptions: {sourceType: 'module', ecmaVersion: 'latest'}});
|
|
19
|
-
ruleTester.run("old-vue-icons", rule, {
|
|
20
|
-
valid: [
|
|
21
|
-
{
|
|
22
|
-
name: 'Dialtone-vue DtIcon import',
|
|
23
|
-
code: "import { DtIcon } from '@dialpad/dialtone-vue';",
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
|
|
27
|
-
invalid: [
|
|
28
|
-
{
|
|
29
|
-
name: 'Dialtone vue icon import',
|
|
30
|
-
code: "import IconSettingsOld from '@dialpad/dialtone/vue/icons/IconSettings';",
|
|
31
|
-
errors: [{ messageId: 'avoidVueImport' }],
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
});
|