@dialpad/eslint-plugin-dialtone 1.3.0 → 1.5.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 CHANGED
@@ -8,7 +8,8 @@ module.exports = {
8
8
  "plugin:node/recommended",
9
9
  ],
10
10
  parserOptions: {
11
- ecmaVersion: 'latest'
11
+ ecmaVersion: 'latest',
12
+ parser: "vue-eslint-parser"
12
13
  },
13
14
  env: {
14
15
  node: true,
@@ -0,0 +1,31 @@
1
+ # Finds deprecated directives that should be replaced by Dialtone Vue directives
2
+
3
+ ## Rule Details
4
+
5
+ This informs developers of deprecated product side directives that should be replaced by Dialtone Vue directives. It will suggest a replacement directive.
6
+
7
+ Currently the directives with the below attribute names are considered deprecated:
8
+
9
+ - v-tooltip
10
+
11
+ This rule specifically targets components in ubervoice. If you are using Dialtone Vue outside of ubervoice you may want to disable this rule.
12
+
13
+ Examples of **incorrect** code for this rule:
14
+
15
+ **usage of a deprecated directive**:
16
+
17
+ ```html
18
+ <template>
19
+ <button v-tooltip="tooltipText">Hover</button>
20
+ </template>
21
+ ```
22
+
23
+ Examples of **correct** code for this rule:
24
+
25
+ **usage of the correct replacement directive**:
26
+
27
+ ```html
28
+ <template>
29
+ <button v-dt-tooltip="tooltipText">Hover</button>
30
+ </template>
31
+ ```
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @fileoverview Detects usages of old dialpad product side components which should be replaced by Dialtone components.
3
+ * @author Brad Paugh
4
+ */
5
+ 'use strict';
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Rule Definition
9
+ //------------------------------------------------------------------------------
10
+
11
+ module.exports = {
12
+ meta: {
13
+ type: 'suggestion', // `problem`, `suggestion`, or `layout`
14
+ docs: {
15
+ description:
16
+ 'Detects usages of deprecated vue directives that should be replaced by Dialtone Vue directives',
17
+ recommended: false,
18
+ url: 'https://github.com/dialpad/eslint-plugin-dialtone/blob/main/docs/rules/deprecated-directive.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
+ deprecatedDirective:
24
+ 'v-{{ directiveName }} is deprecated and should be replaced with the Dialtone Vue v-{{ replacement }} component.\n{{ link }}',
25
+ },
26
+ },
27
+
28
+ create(context) {
29
+ const deprecatedDirectives = [
30
+ {
31
+ directiveName: 'tooltip',
32
+ replacement: 'dt-tooltip',
33
+ link: 'https://vue.dialpad.design/?path=/docs/directives-tooltip--docs',
34
+ },
35
+ ];
36
+
37
+ return context.parserServices.defineTemplateBodyVisitor({
38
+ VAttribute(node) {
39
+ deprecatedDirectives.forEach((item) => {
40
+ if (node.directive && node.key.name.name === item.directiveName) {
41
+ context.report({
42
+ node: node,
43
+ messageId: 'deprecatedDirective',
44
+ data: {
45
+ directiveName: item.directiveName,
46
+ replacement: item.replacement,
47
+ link: item.link,
48
+ },
49
+ });
50
+ }
51
+ });
52
+ },
53
+ });
54
+ },
55
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialpad/eslint-plugin-dialtone",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "dialtone eslint plugin",
5
5
  "keywords": [
6
6
  "Dialpad",
@@ -49,6 +49,7 @@
49
49
  "eslint": "^8.19.0",
50
50
  "eslint-plugin-eslint-plugin": "^5.0.0",
51
51
  "eslint-plugin-node": "^11.1.0",
52
+ "eslint-plugin-vue": "^9.17.0",
52
53
  "mocha": "^10.0.0"
53
54
  },
54
55
  "engines": {
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @fileoverview Detects usages of old dialpad product side components which should be replaced by Dialtone components.
3
+ * @author Brad Paugh
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const rule = require("../../../lib/rules/deprecated-directive"), RuleTester = require("eslint").RuleTester;
12
+
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Tests
16
+ //------------------------------------------------------------------------------
17
+ const ruleTester = new RuleTester({
18
+ parser: require.resolve('vue-eslint-parser'),
19
+ parserOptions: { ecmaVersion: 'latest' }
20
+ })
21
+ ruleTester.run("deprecated-directive", rule, {
22
+ valid: [
23
+ {
24
+ name: 'Non deprecated directive',
25
+ code: "<template><dt-button v-dt-tooltip=\"'tooltip'\" /></template>",
26
+ },
27
+ ],
28
+
29
+ invalid: [
30
+ {
31
+ name: 'Deprecated directive',
32
+ code: "<template><button v-tooltip=\"'tooltip'\" /></template>",
33
+ errors: [
34
+ {
35
+ messageId: "deprecatedDirective"
36
+ }
37
+ ],
38
+ },
39
+ ],
40
+ });