@tcy/eslint-rules 1.2.0 → 1.3.1

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.
@@ -515,3 +515,117 @@ BRDA:60,11,2,0
515
515
  BRF:27
516
516
  BRH:0
517
517
  end_of_record
518
+ TN:
519
+ SF:src/vuejs-define-component.js
520
+ FN:22,(anonymous_0)
521
+ FN:24,(anonymous_1)
522
+ FN:47,(anonymous_2)
523
+ FN:62,(anonymous_3)
524
+ FNF:4
525
+ FNH:0
526
+ FNDA:0,(anonymous_0)
527
+ FNDA:0,(anonymous_1)
528
+ FNDA:0,(anonymous_2)
529
+ FNDA:0,(anonymous_3)
530
+ DA:1,0
531
+ DA:23,0
532
+ DA:25,0
533
+ DA:28,0
534
+ DA:34,0
535
+ DA:37,0
536
+ DA:40,0
537
+ DA:41,0
538
+ DA:45,0
539
+ DA:47,0
540
+ DA:48,0
541
+ DA:49,0
542
+ DA:51,0
543
+ DA:52,0
544
+ DA:53,0
545
+ DA:62,0
546
+ DA:63,0
547
+ DA:67,0
548
+ DA:71,0
549
+ DA:72,0
550
+ DA:73,0
551
+ DA:75,0
552
+ DA:76,0
553
+ DA:80,0
554
+ LF:24
555
+ LH:0
556
+ BRDA:28,0,0,0
557
+ BRDA:28,0,1,0
558
+ BRDA:29,1,0,0
559
+ BRDA:29,1,1,0
560
+ BRDA:29,1,2,0
561
+ BRDA:29,1,3,0
562
+ BRDA:40,2,0,0
563
+ BRDA:40,2,1,0
564
+ BRDA:40,3,0,0
565
+ BRDA:40,3,1,0
566
+ BRDA:48,4,0,0
567
+ BRDA:48,4,1,0
568
+ BRDA:48,5,0,0
569
+ BRDA:48,5,1,0
570
+ BRDA:49,6,0,0
571
+ BRDA:49,6,1,0
572
+ BRDA:52,7,0,0
573
+ BRDA:52,7,1,0
574
+ BRDA:62,8,0,0
575
+ BRDA:62,8,1,0
576
+ BRDA:75,9,0,0
577
+ BRDA:75,9,1,0
578
+ BRF:22
579
+ BRH:0
580
+ end_of_record
581
+ TN:
582
+ SF:src/vuejs-define-workspace.js
583
+ FN:14,(anonymous_0)
584
+ FN:27,(anonymous_1)
585
+ FN:48,(anonymous_2)
586
+ FNF:3
587
+ FNH:0
588
+ FNDA:0,(anonymous_0)
589
+ FNDA:0,(anonymous_1)
590
+ FNDA:0,(anonymous_2)
591
+ DA:15,0
592
+ DA:16,0
593
+ DA:19,0
594
+ DA:22,0
595
+ DA:23,0
596
+ DA:26,0
597
+ DA:28,0
598
+ DA:31,0
599
+ DA:37,0
600
+ DA:40,0
601
+ DA:43,0
602
+ DA:44,0
603
+ DA:47,0
604
+ DA:49,0
605
+ DA:55,0
606
+ DA:56,0
607
+ LF:16
608
+ LH:0
609
+ BRDA:19,0,0,0
610
+ BRDA:19,0,1,0
611
+ BRDA:22,1,0,0
612
+ BRDA:22,1,1,0
613
+ BRDA:31,2,0,0
614
+ BRDA:31,2,1,0
615
+ BRDA:32,3,0,0
616
+ BRDA:32,3,1,0
617
+ BRDA:32,3,2,0
618
+ BRDA:32,3,3,0
619
+ BRDA:43,4,0,0
620
+ BRDA:43,4,1,0
621
+ BRDA:43,5,0,0
622
+ BRDA:43,5,1,0
623
+ BRDA:49,6,0,0
624
+ BRDA:49,6,1,0
625
+ BRDA:49,6,2,0
626
+ BRDA:49,6,3,0
627
+ BRDA:55,7,0,0
628
+ BRDA:55,7,1,0
629
+ BRF:20
630
+ BRH:0
631
+ end_of_record
package/dist/index.d.ts CHANGED
@@ -116,6 +116,34 @@ declare namespace _default {
116
116
  PropertyDefinition(node: any): void;
117
117
  };
118
118
  };
119
+ 'vuejs-define-component': {
120
+ meta: {
121
+ type: string;
122
+ docs: {
123
+ description: string;
124
+ recommended: boolean;
125
+ };
126
+ schema: any[];
127
+ };
128
+ create(context: any): {
129
+ ExportDefaultDeclaration(node: any): void;
130
+ };
131
+ };
132
+ 'vuejs-define-workspace': {
133
+ meta: {
134
+ type: string;
135
+ docs: {
136
+ description: string;
137
+ recommended: boolean;
138
+ };
139
+ schema: any[];
140
+ };
141
+ create(context: any): {
142
+ ExportDefaultDeclaration?: undefined;
143
+ } | {
144
+ ExportDefaultDeclaration(node: any): void;
145
+ };
146
+ };
119
147
  };
120
148
  }
121
149
  export default _default;
@@ -0,0 +1,14 @@
1
+ declare namespace _default {
2
+ namespace meta {
3
+ let type: string;
4
+ namespace docs {
5
+ let description: string;
6
+ let recommended: boolean;
7
+ }
8
+ let schema: any[];
9
+ }
10
+ function create(context: any): {
11
+ ExportDefaultDeclaration(node: any): void;
12
+ };
13
+ }
14
+ export default _default;
@@ -0,0 +1,16 @@
1
+ declare namespace _default {
2
+ namespace meta {
3
+ let type: string;
4
+ namespace docs {
5
+ let description: string;
6
+ let recommended: boolean;
7
+ }
8
+ let schema: any[];
9
+ }
10
+ function create(context: any): {
11
+ ExportDefaultDeclaration?: undefined;
12
+ } | {
13
+ ExportDefaultDeclaration(node: any): void;
14
+ };
15
+ }
16
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tcy/eslint-rules",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "```typescript import { plugin as customRules } from 'tcy@eslint-rules/src/index.mjs';",
5
5
  "homepage": "https://github.com/tcastelly/eslint-rules#readme",
6
6
  "bugs": {
@@ -22,12 +22,12 @@
22
22
  "test": "jest"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/core": "^7.28.6",
26
- "@babel/preset-env": "^7.28.6",
25
+ "@babel/core": "^7.29.0",
26
+ "@babel/preset-env": "^7.29.0",
27
27
  "@types/jest": "^30.0.0",
28
28
  "babel-jest": "^30.2.0",
29
29
  "jest": "^30.2.0",
30
- "rimraf": "^6.1.2",
30
+ "rimraf": "^6.1.3",
31
31
  "typescript": "^5.9.3"
32
32
  }
33
33
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Enforce all Tailwind classes to end with "!" (important modifier)
3
3
  */
4
- export const isMissingImportant = (cls) => !/^[a-zA-Z0-9-%&>*.:',/[\]()_]+(:?!)$/.test(cls);
4
+ export const isMissingImportant = (cls) => !/^[a-zA-Z0-9-%&>*.:',/[\]()_@]+(:?!)$/.test(cls);
5
5
 
6
6
  export const addImportant = (cls) => `${cls}!`;
7
7
 
package/src/index.js CHANGED
@@ -5,6 +5,8 @@ import jsxExpressionStringLiterals from './jsx-expression-string-literals.js';
5
5
  import enforceTailwindImportant from './enforce-tailwind-important.js';
6
6
  import vModelNameMatch from './v-model-name-match.js';
7
7
  import decoratorTypeEnforcement from './decorator-type-enforcement.js'
8
+ import vuejsDefineComponent from './vuejs-define-component.js'
9
+ import vuejsDefineWorkspace from './vuejs-define-workspace.js'
8
10
 
9
11
  export default {
10
12
  rules: {
@@ -15,5 +17,7 @@ export default {
15
17
  'enforce-tailwind-important': enforceTailwindImportant,
16
18
  'v-model-name-match': vModelNameMatch,
17
19
  'decorator-type-enforcement': decoratorTypeEnforcement,
20
+ 'vuejs-define-component': vuejsDefineComponent,
21
+ 'vuejs-define-workspace': vuejsDefineWorkspace,
18
22
  },
19
23
  };
@@ -0,0 +1,86 @@
1
+ const attributesOrder = [
2
+ 'name',
3
+ 'route',
4
+ 'inheritAttrs',
5
+ 'directives',
6
+ 'props',
7
+ 'emits',
8
+ 'render',
9
+ 'setup',
10
+ ];
11
+
12
+ export default {
13
+ meta: {
14
+ type: 'problem',
15
+ docs: {
16
+ description: 'Custom best practices in defineComponent',
17
+ recommended: false,
18
+ },
19
+ schema: [],
20
+ },
21
+
22
+ create(context) {
23
+ return {
24
+ ExportDefaultDeclaration(node) {
25
+ const decl = node.declaration;
26
+
27
+ // export default defineComponent(...)
28
+ if (
29
+ !decl ||
30
+ decl.type !== 'CallExpression' ||
31
+ decl.callee.type !== 'Identifier' ||
32
+ decl.callee.name !== 'defineComponent'
33
+ ) {
34
+ return;
35
+ }
36
+
37
+ const arg = decl.arguments[0];
38
+
39
+ // defineComponent({ ... })
40
+ if (!arg || arg.type !== 'ObjectExpression') {
41
+ return;
42
+ }
43
+
44
+
45
+ const seenIndexes = [];
46
+
47
+ arg.properties.forEach((prop) => {
48
+ if (prop.type !== 'Property' || prop.computed) return;
49
+ if (prop.key.type !== 'Identifier') return;
50
+
51
+ const index = attributesOrder.indexOf(prop.key.name);
52
+ if (index !== -1) {
53
+ seenIndexes.push({
54
+ name: prop.key.name,
55
+ index,
56
+ node: prop,
57
+ });
58
+ }
59
+ });
60
+
61
+ // ---- name required ----
62
+ if (!seenIndexes.some((p) => p.name === 'name')) {
63
+ context.report({
64
+ node: arg,
65
+ message: 'Components defined with defineComponent must have a "name" property',
66
+ });
67
+ return;
68
+ }
69
+
70
+ // ---- order validation ----
71
+ for (let i = 1; i < seenIndexes.length; i++) {
72
+ const prev = seenIndexes[i - 1];
73
+ const curr = seenIndexes[i];
74
+
75
+ if (curr.index < prev.index) {
76
+ context.report({
77
+ node: curr.node,
78
+ message: `"${curr.name}" should appear before "${prev.name}" in defineComponent options`,
79
+ });
80
+ return;
81
+ }
82
+ }
83
+ },
84
+ };
85
+ },
86
+ };
@@ -0,0 +1,65 @@
1
+ import path from 'node:path';
2
+
3
+ export default {
4
+ meta: {
5
+ type: 'problem',
6
+ docs: {
7
+ description:
8
+ 'Require a route object in defineComponent for Workspace* and Page* files',
9
+ recommended: false,
10
+ },
11
+ schema: [],
12
+ },
13
+
14
+ create(context) {
15
+ const filename = context.getFilename();
16
+ const basename = path.basename(filename);
17
+
18
+ const requiresRoute =
19
+ basename.startsWith('Workspace') || basename.startsWith('Page');
20
+
21
+ // If filename doesn't match, do nothing
22
+ if (!requiresRoute) {
23
+ return {};
24
+ }
25
+
26
+ return {
27
+ ExportDefaultDeclaration(node) {
28
+ const decl = node.declaration;
29
+
30
+ // export default defineComponent(...)
31
+ if (
32
+ !decl ||
33
+ decl.type !== 'CallExpression' ||
34
+ decl.callee.type !== 'Identifier' ||
35
+ decl.callee.name !== 'defineComponent'
36
+ ) {
37
+ return;
38
+ }
39
+
40
+ const arg = decl.arguments[0];
41
+
42
+ // defineComponent({ ... })
43
+ if (!arg || arg.type !== 'ObjectExpression') {
44
+ return;
45
+ }
46
+
47
+ const hasRoute = arg.properties.some(
48
+ (prop) =>
49
+ prop.type === 'Property' &&
50
+ !prop.computed &&
51
+ prop.key.type === 'Identifier' &&
52
+ prop.key.name === 'route'
53
+ );
54
+
55
+ if (!hasRoute) {
56
+ context.report({
57
+ node: arg,
58
+ message:
59
+ 'Components in Workspace* or Page* files must define a "route" object',
60
+ });
61
+ }
62
+ },
63
+ };
64
+ },
65
+ };
package/tsconfig.json CHANGED
@@ -10,6 +10,7 @@
10
10
  "lib": ["es2016", "dom"],
11
11
  "noImplicitAny": false,
12
12
  "moduleResolution": "node",
13
+ "allowSyntheticDefaultImports": true
13
14
  },
14
15
  "include": ["src"],
15
16
  "exclude": ["dist", "node_modules"]