@agilebot/eslint-plugin 0.3.9 → 0.3.10

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.
Files changed (2) hide show
  1. package/dist/index.js +94 -77
  2. package/package.json +4 -5
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-plugin v0.3.9
2
+ * @license @agilebot/eslint-plugin v0.3.10
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -11,7 +11,6 @@
11
11
  var eslintUtils = require('@agilebot/eslint-utils');
12
12
  var fs = require('node:fs');
13
13
  var path = require('node:path');
14
- var utils = require('@typescript-eslint/utils');
15
14
 
16
15
  function _interopNamespaceDefault(e) {
17
16
  var n = Object.create(null);
@@ -33,12 +32,12 @@ function _interopNamespaceDefault(e) {
33
32
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
34
33
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
35
34
 
36
- var enforceMuiIconAlias = {
35
+ var enforceMuiIconAlias = eslintUtils.createESLintRule({
37
36
  meta: {
38
37
  type: 'problem',
39
38
  docs: {
40
39
  description: 'Enforce alias for @mui/icons-material imports',
41
- recommended: true
40
+ recommended: 'recommended'
42
41
  },
43
42
  fixable: 'code',
44
43
  schema: [],
@@ -46,6 +45,7 @@ var enforceMuiIconAlias = {
46
45
  iconAlias: 'Import for {{ name }} should be aliased.'
47
46
  }
48
47
  },
48
+ defaultOptions: [],
49
49
  create(context) {
50
50
  return {
51
51
  ImportDeclaration(node) {
@@ -70,10 +70,11 @@ var enforceMuiIconAlias = {
70
70
  }
71
71
  };
72
72
  }
73
- };
73
+ });
74
74
 
75
- var funcNaming = {
75
+ var funcNaming = eslintUtils.createESLintRule({
76
76
  meta: {
77
+ type: 'problem',
77
78
  docs: {
78
79
  description: 'Enforce function naming convention'
79
80
  },
@@ -81,6 +82,7 @@ var funcNaming = {
81
82
  type: 'object',
82
83
  properties: {
83
84
  format: {
85
+ type: 'string',
84
86
  "enum": ['camelCase', 'PascalCase']
85
87
  }
86
88
  }
@@ -90,6 +92,7 @@ var funcNaming = {
90
92
  invalidReactFCNaming: 'Invalid naming convention for React functional component, expected PascalCase'
91
93
  }
92
94
  },
95
+ defaultOptions: [],
93
96
  create(context) {
94
97
  if (!context.options[0]) {
95
98
  throw new Error('Missing options');
@@ -169,7 +172,8 @@ var funcNaming = {
169
172
  const typeAnnotation = node.id.typeAnnotation.typeAnnotation;
170
173
  if (typeAnnotation.type === 'TSTypeReference' && typeAnnotation.typeName.type === 'Identifier') {
171
174
  const typeName = typeAnnotation.typeName.name;
172
- if (['FC', 'React.FC', 'FunctionComponent', 'React.FunctionComponent'].includes(typeName)) {
175
+ const typeNameLast = typeName.split('.').pop();
176
+ if (['FC', 'FunctionComponent', 'VFC', 'VoidFunctionComponent'].includes(typeNameLast)) {
173
177
  isReactComponent = true;
174
178
  }
175
179
  }
@@ -187,7 +191,7 @@ var funcNaming = {
187
191
  }
188
192
  };
189
193
  }
190
- };
194
+ });
191
195
 
192
196
  function getSetting(context, name) {
193
197
  return context.settings["agilebot/".concat(name)];
@@ -202,12 +206,12 @@ function warnOnce(message) {
202
206
  console.warn("Warning: ".concat(message));
203
207
  }
204
208
 
205
- var importMonorepo = {
209
+ var importMonorepo = eslintUtils.createESLintRule({
206
210
  meta: {
207
211
  type: 'problem',
208
212
  docs: {
209
213
  description: 'Enforce import styles for monorepo',
210
- recommended: true
214
+ recommended: 'recommended'
211
215
  },
212
216
  fixable: 'code',
213
217
  schema: [],
@@ -215,6 +219,7 @@ var importMonorepo = {
215
219
  monorepoImport: 'Import for {{ module }} should not contains src folder.'
216
220
  }
217
221
  },
222
+ defaultOptions: [],
218
223
  create(context) {
219
224
  return {
220
225
  ImportDeclaration(node) {
@@ -247,7 +252,7 @@ var importMonorepo = {
247
252
  }
248
253
  };
249
254
  }
250
- };
255
+ });
251
256
 
252
257
  function findFormatMessageAttrNode(node, attrName) {
253
258
  if (node.type === 'CallExpression' && (node.callee.name === 'formatMessage' || node.callee.name === '$t') && node.arguments.length > 0 && node.arguments[0].properties) {
@@ -317,13 +322,12 @@ function getIntlIds(context) {
317
322
  return results;
318
323
  }
319
324
 
320
- var intlIdMissing = {
325
+ var intlIdMissing = eslintUtils.createESLintRule({
321
326
  meta: {
327
+ type: 'problem',
322
328
  docs: {
323
- description: 'Validates intl message ids are in locale file',
324
- category: 'Intl'
329
+ description: 'Validates intl message ids are in locale file'
325
330
  },
326
- fixable: undefined,
327
331
  schema: [],
328
332
  messages: {
329
333
  missingId: 'Missing id: {{value}}',
@@ -331,6 +335,7 @@ var intlIdMissing = {
331
335
  disallowInvoke: 'Do not invoke intl by {{value}}'
332
336
  }
333
337
  },
338
+ defaultOptions: [],
334
339
  create: function (context) {
335
340
  const translatedIds = getIntlIds(context);
336
341
  const translatedIdSet = new Set(translatedIds);
@@ -403,19 +408,19 @@ var intlIdMissing = {
403
408
  }
404
409
  };
405
410
  }
406
- };
411
+ });
407
412
 
408
- var intlIdNaming = {
413
+ var intlIdNaming = eslintUtils.createESLintRule({
409
414
  meta: {
415
+ type: 'problem',
410
416
  docs: {
411
- description: 'Validates intl message ids naming convention',
412
- category: 'Intl'
417
+ description: 'Validates intl message ids naming convention'
413
418
  },
414
- fixable: undefined,
415
419
  schema: [{
416
420
  type: 'object',
417
421
  properties: {
418
422
  format: {
423
+ type: 'string',
419
424
  "enum": ['camelCase', 'PascalCase']
420
425
  }
421
426
  }
@@ -424,6 +429,7 @@ var intlIdNaming = {
424
429
  invalidIdNaming: "Invalid id naming, expected {{format}}"
425
430
  }
426
431
  },
432
+ defaultOptions: [],
427
433
  create: function (context) {
428
434
  if (!context.options[0]) {
429
435
  throw new Error('Missing options');
@@ -495,15 +501,14 @@ var intlIdNaming = {
495
501
  }
496
502
  };
497
503
  }
498
- };
504
+ });
499
505
 
500
- var intlIdPrefix = {
506
+ var intlIdPrefix = eslintUtils.createESLintRule({
501
507
  meta: {
508
+ type: 'problem',
502
509
  docs: {
503
- description: 'Validates intl message ids has correct prefixes',
504
- category: 'Intl'
510
+ description: 'Validates intl message ids has correct prefixes'
505
511
  },
506
- fixable: undefined,
507
512
  schema: [{
508
513
  type: 'array',
509
514
  items: {
@@ -514,6 +519,7 @@ var intlIdPrefix = {
514
519
  invalidIdPrefix: 'Invalid id prefix: {{value}}'
515
520
  }
516
521
  },
522
+ defaultOptions: [],
517
523
  create: function (context) {
518
524
  if (context.options[0].length === 0) {
519
525
  throw new Error('Prefixes are required in settings');
@@ -569,18 +575,19 @@ var intlIdPrefix = {
569
575
  }
570
576
  };
571
577
  }
572
- };
578
+ });
573
579
 
574
580
  const usedIds = new Map();
575
- var intlIdUnused = {
581
+ var intlIdUnused = eslintUtils.createESLintRule({
576
582
  meta: {
583
+ type: 'problem',
577
584
  docs: {
578
- description: 'Finds unused intl message ids in locale file',
579
- category: 'Intl'
585
+ description: 'Finds unused intl message ids in locale file'
580
586
  },
581
- fixable: undefined,
582
- schema: []
587
+ schema: [],
588
+ messages: {}
583
589
  },
590
+ defaultOptions: [],
584
591
  create: function (context) {
585
592
  const projectRoot = getSetting(context, 'project-root');
586
593
  if (!projectRoot) {
@@ -645,20 +652,20 @@ var intlIdUnused = {
645
652
  }
646
653
  };
647
654
  }
648
- };
655
+ });
649
656
 
650
- var intlNoDefault = {
657
+ var intlNoDefault = eslintUtils.createESLintRule({
651
658
  meta: {
659
+ type: 'problem',
652
660
  docs: {
653
- description: 'Validates defaultMessage is not used with react-intl',
654
- category: 'Intl'
661
+ description: 'Validates defaultMessage is not used with react-intl'
655
662
  },
656
- fixable: undefined,
657
663
  schema: [],
658
664
  messages: {
659
665
  noDefaultMessage: 'Do not use defaultMessage'
660
666
  }
661
667
  },
668
+ defaultOptions: [],
662
669
  create: function (context) {
663
670
  function processAttrNode(node) {
664
671
  context.report({
@@ -687,21 +694,21 @@ var intlNoDefault = {
687
694
  }
688
695
  };
689
696
  }
690
- };
697
+ });
691
698
 
692
- var noAsyncArrayMethods = {
699
+ var noAsyncArrayMethods = eslintUtils.createESLintRule({
693
700
  meta: {
701
+ type: 'problem',
694
702
  docs: {
695
703
  description: 'No async callback for Array methods forEach, map, filter, reduce, some, every, etc.',
696
- category: 'Array',
697
- recommended: true
704
+ recommended: 'recommended'
698
705
  },
699
- fixable: undefined,
700
706
  schema: [],
701
707
  messages: {
702
708
  noAsyncArrayMethods: "No async function in method '{{ methodName }}'"
703
709
  }
704
710
  },
711
+ defaultOptions: [],
705
712
  create: function (context) {
706
713
  return {
707
714
  ExpressionStatement: function (node) {
@@ -729,21 +736,21 @@ var noAsyncArrayMethods = {
729
736
  }
730
737
  };
731
738
  }
732
- };
739
+ });
733
740
 
734
- var noImportCss = {
741
+ var noImportCss = eslintUtils.createESLintRule({
735
742
  meta: {
736
743
  type: 'problem',
737
744
  docs: {
738
745
  description: 'Prevent importing CSS',
739
- recommended: true
746
+ recommended: 'recommended'
740
747
  },
741
- fixable: 'code',
742
748
  schema: [],
743
749
  messages: {
744
750
  noImportCSS: 'Do not import CSS files. Use CSS-in-JS instead.'
745
751
  }
746
752
  },
753
+ defaultOptions: [],
747
754
  create(context) {
748
755
  return {
749
756
  ImportDeclaration(node) {
@@ -760,9 +767,9 @@ var noImportCss = {
760
767
  }
761
768
  };
762
769
  }
763
- };
770
+ });
764
771
 
765
- var noThenCatchFinally = {
772
+ var noThenCatchFinally = eslintUtils.createESLintRule({
766
773
  meta: {
767
774
  type: 'suggestion',
768
775
  docs: {
@@ -784,6 +791,7 @@ var noThenCatchFinally = {
784
791
  forbiddenThenCatchFinally: "then()/catch()/finally() is forbidden when invoke {{ name }}()."
785
792
  }
786
793
  },
794
+ defaultOptions: [],
787
795
  create(context) {
788
796
  const configuration = context.options[0] || {};
789
797
  const restrictedFunctions = configuration.restrictedFunctions || [];
@@ -814,14 +822,14 @@ var noThenCatchFinally = {
814
822
  }
815
823
  };
816
824
  }
817
- };
825
+ });
818
826
 
819
- var noUnnecessaryTemplateLiterals = {
827
+ var noUnnecessaryTemplateLiterals = eslintUtils.createESLintRule({
820
828
  meta: {
821
829
  type: 'problem',
822
830
  docs: {
823
831
  description: 'Check if a template string contains only one ${}',
824
- recommended: true
832
+ recommended: 'recommended'
825
833
  },
826
834
  fixable: 'code',
827
835
  schema: [],
@@ -829,6 +837,7 @@ var noUnnecessaryTemplateLiterals = {
829
837
  unnecessaryTemplateString: 'Unnecessary template string with only one ${}.'
830
838
  }
831
839
  },
840
+ defaultOptions: [],
832
841
  create(context) {
833
842
  return {
834
843
  TemplateLiteral(node) {
@@ -845,7 +854,7 @@ var noUnnecessaryTemplateLiterals = {
845
854
  }
846
855
  };
847
856
  }
848
- };
857
+ });
849
858
 
850
859
  var reactBetterExhaustiveDeps = {
851
860
  meta: {
@@ -2039,19 +2048,20 @@ function isAncestorNodeOf(a, b) {
2039
2048
  }
2040
2049
 
2041
2050
  const Components = require('eslint-plugin-react/lib/util/Components');
2042
- var reactHookUseRef = {
2051
+ var reactHookUseRef = eslintUtils.createESLintRule({
2043
2052
  meta: {
2053
+ type: 'suggestion',
2044
2054
  docs: {
2045
2055
  description: 'Ensure naming of useRef hook value.',
2046
- recommended: true
2056
+ recommended: 'recommended'
2047
2057
  },
2048
2058
  schema: [],
2049
- type: 'suggestion',
2050
2059
  hasSuggestions: true,
2051
2060
  messages: {
2052
2061
  useRefName: 'useRef call is not end with "Ref"'
2053
2062
  }
2054
2063
  },
2064
+ defaultOptions: [],
2055
2065
  create: Components.detect((context, component, util) => ({
2056
2066
  CallExpression(node) {
2057
2067
  const isImmediateReturn = node.parent && node.parent.type === 'ReturnStatement';
@@ -2070,7 +2080,7 @@ var reactHookUseRef = {
2070
2080
  }
2071
2081
  }
2072
2082
  }))
2073
- };
2083
+ });
2074
2084
 
2075
2085
  function* updateImportStatement(context, fixer, key) {
2076
2086
  const sourceCode = context.sourceCode;
@@ -2089,10 +2099,9 @@ function* updateImportStatement(context, fixer, key) {
2089
2099
  }
2090
2100
  yield fixer.insertTextAfter([...importNode.specifiers].pop(), ", ".concat(key));
2091
2101
  }
2092
- var reactPreferNamedPropertyAccess = utils.ESLintUtils.RuleCreator.withoutDocs({
2093
- defaultOptions: [],
2102
+ var reactPreferNamedPropertyAccess = eslintUtils.createESLintRule({
2094
2103
  meta: {
2095
- type: 'layout',
2104
+ type: 'problem',
2096
2105
  fixable: 'code',
2097
2106
  docs: {
2098
2107
  description: 'Enforce importing each member of React namespace separately instead of accessing them through React namespace',
@@ -2104,6 +2113,7 @@ var reactPreferNamedPropertyAccess = utils.ESLintUtils.RuleCreator.withoutDocs({
2104
2113
  },
2105
2114
  schema: []
2106
2115
  },
2116
+ defaultOptions: [],
2107
2117
  create(context) {
2108
2118
  return {
2109
2119
  TSQualifiedName(node) {
@@ -2155,12 +2165,12 @@ var reactPreferNamedPropertyAccess = utils.ESLintUtils.RuleCreator.withoutDocs({
2155
2165
  }
2156
2166
  });
2157
2167
 
2158
- var reactPreferSxProp = {
2168
+ var reactPreferSxProp = eslintUtils.createESLintRule({
2159
2169
  meta: {
2170
+ type: 'problem',
2160
2171
  docs: {
2161
2172
  description: 'Prefer using sx prop instead of inline styles',
2162
- category: 'Best Practices',
2163
- recommended: true
2173
+ recommended: 'recommended'
2164
2174
  },
2165
2175
  messages: {
2166
2176
  preferSxProp: 'Avoid using inline styles, use sx prop or tss-react or styled-component instead'
@@ -2178,6 +2188,7 @@ var reactPreferSxProp = {
2178
2188
  }
2179
2189
  }]
2180
2190
  },
2191
+ defaultOptions: [],
2181
2192
  create(context) {
2182
2193
  const configuration = context.options[0] || {};
2183
2194
  const allowedFor = configuration.allowedFor || [];
@@ -2222,7 +2233,7 @@ var reactPreferSxProp = {
2222
2233
  }
2223
2234
  };
2224
2235
  }
2225
- };
2236
+ });
2226
2237
 
2227
2238
  function getBasicIdentifier(node) {
2228
2239
  if (node.type === 'Identifier') {
@@ -2313,18 +2324,19 @@ function loopStylesObj(node, callback) {
2313
2324
  }
2314
2325
  }
2315
2326
 
2316
- var tssClassNaming = {
2327
+ var tssClassNaming = eslintUtils.createESLintRule({
2317
2328
  meta: {
2318
2329
  type: 'problem',
2319
2330
  docs: {
2320
2331
  description: 'Enforce camelCase class names in TSS',
2321
- category: 'Best Practices',
2322
- recommended: true
2332
+ recommended: 'recommended'
2323
2333
  },
2334
+ schema: [],
2324
2335
  messages: {
2325
2336
  camelCase: 'Class `{{ className }}` must be camelCase in TSS.'
2326
2337
  }
2327
2338
  },
2339
+ defaultOptions: [],
2328
2340
  create: function rule(context) {
2329
2341
  return {
2330
2342
  CallExpression(node) {
@@ -2353,7 +2365,7 @@ var tssClassNaming = {
2353
2365
  }
2354
2366
  };
2355
2367
  }
2356
- };
2368
+ });
2357
2369
 
2358
2370
  var colors = {
2359
2371
  aliceblue: [240, 248, 255],
@@ -2506,17 +2518,19 @@ var colors = {
2506
2518
  yellowgreen: [154, 205, 50]
2507
2519
  };
2508
2520
 
2509
- var tssNoColorName = {
2521
+ var tssNoColorName = eslintUtils.createESLintRule({
2510
2522
  meta: {
2511
2523
  type: 'suggestion',
2512
2524
  docs: {
2513
2525
  description: 'Enforce the use of color variables instead of color name within TSS',
2514
- recommended: true
2526
+ recommended: 'recommended'
2515
2527
  },
2528
+ schema: [],
2516
2529
  messages: {
2517
2530
  disallowColorName: 'Disallowed color name. Use color from `@mui/material/colors` or `theme.palette`.'
2518
2531
  }
2519
2532
  },
2533
+ defaultOptions: [],
2520
2534
  create: function (context) {
2521
2535
  return {
2522
2536
  CallExpression(node) {
@@ -2536,19 +2550,21 @@ var tssNoColorName = {
2536
2550
  }
2537
2551
  };
2538
2552
  }
2539
- };
2553
+ });
2540
2554
 
2541
- var tssNoColorValue = {
2555
+ var tssNoColorValue = eslintUtils.createESLintRule({
2542
2556
  meta: {
2543
2557
  type: 'problem',
2544
2558
  docs: {
2545
2559
  description: 'Enforce the use of color variables instead of color codes within TSS',
2546
- recommended: true
2560
+ recommended: 'recommended'
2547
2561
  },
2562
+ schema: [],
2548
2563
  messages: {
2549
2564
  preferMuiColor: 'Prefer use color from `@mui/material/colors` or `theme.palette`.'
2550
2565
  }
2551
2566
  },
2567
+ defaultOptions: [],
2552
2568
  create: function (context) {
2553
2569
  return {
2554
2570
  CallExpression(node) {
@@ -2571,20 +2587,21 @@ var tssNoColorValue = {
2571
2587
  }
2572
2588
  };
2573
2589
  }
2574
- };
2590
+ });
2575
2591
 
2576
- var tssUnusedClasses = {
2592
+ var tssUnusedClasses = eslintUtils.createESLintRule({
2577
2593
  meta: {
2578
2594
  type: 'suggestion',
2579
2595
  docs: {
2580
2596
  description: 'Disallow unused classes in tss',
2581
- category: 'Best Practices',
2582
- recommended: true
2597
+ recommended: 'recommended'
2583
2598
  },
2599
+ schema: [],
2584
2600
  messages: {
2585
2601
  unusedClass: 'Class `{{ className }}` is unused in JSX'
2586
2602
  }
2587
2603
  },
2604
+ defaultOptions: [],
2588
2605
  create: function rule(context) {
2589
2606
  const usedClasses = {};
2590
2607
  const definedClasses = {};
@@ -2660,7 +2677,7 @@ var tssUnusedClasses = {
2660
2677
  }
2661
2678
  };
2662
2679
  }
2663
- };
2680
+ });
2664
2681
 
2665
2682
  var ruleFiles = /*#__PURE__*/Object.freeze({
2666
2683
  __proto__: null,
@@ -2706,7 +2723,7 @@ Object.keys(ruleFiles).forEach(key => {
2706
2723
  const rule = ruleFiles[key];
2707
2724
  plugin.rules[finalKey] = rule;
2708
2725
  if (rule.meta && rule.meta.docs && rule.meta.docs.recommended) {
2709
- plugin.configs.recommended.rules["@agilebot/".concat(finalKey)] = rule.meta.type === 'suggestion' ? 'warn' : 'error';
2726
+ plugin.configs.recommended.rules["@agilebot/".concat(finalKey)] = rule.meta.type === 'problem' ? 'error' : 'warn';
2710
2727
  }
2711
2728
  });
2712
2729
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilebot/eslint-plugin",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "Agilebot's ESLint plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,9 +18,8 @@
18
18
  "node": "^18.18.0 || >=20.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "@typescript-eslint/utils": "~7.9.0",
22
- "eslint-plugin-react": "^7.34.1",
23
- "@agilebot/eslint-utils": "0.3.9"
21
+ "eslint-plugin-react": "^7.34.3",
22
+ "@agilebot/eslint-utils": "0.3.10"
24
23
  },
25
24
  "peerDependencies": {
26
25
  "eslint": "^7.0.0 || ^8.0.0"
@@ -33,7 +32,7 @@
33
32
  "@types/estree": "^1.0.5",
34
33
  "color-name": "^2.0.0",
35
34
  "eslint-vitest-rule-tester": "^0.3.2",
36
- "typescript-eslint": "^7.11.0"
35
+ "typescript-eslint": "^7.16.0"
37
36
  },
38
37
  "scripts": {
39
38
  "build": "rollup -c rollup.config.mjs",