@agilebot/eslint-plugin 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @agilebot/eslint-plugin
2
2
 
3
- Agilebot extended ESLint rules. For @agilebot/eslint-config.
3
+ [![npm](https://img.shields.io/npm/v/@agilebot/eslint-plugin?color=444&label=)](https://npmjs.com/package/@agilebot/eslint-plugin)
4
+
5
+ Agilebot extended ESLint rules. Designed for @agilebot/eslint-config.
4
6
 
5
7
  ### Usage
6
8
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-plugin v0.5.1
2
+ * @license @agilebot/eslint-plugin v0.5.2
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -2627,8 +2627,8 @@ var tssUnusedClasses = createRule({
2627
2627
  const RULE_NAME = 'var-naming';
2628
2628
  const reactGlobalFuncs = new Set(['createContext', 'forwardRef', 'lazy', 'memo', 'combineProviders']);
2629
2629
  const reactFCTypes = new Set(['FC', 'FunctionComponent', 'VFC', 'VoidFunctionComponent']);
2630
- const otherTypes = new Set(['StoryObj', 'StoryFn']);
2631
- const defaultExcludes = ['^(__dirname|__filename)$', '(.*)Event$'];
2630
+ const defaultExcludeTypes = ['StoryObj', 'StoryFn'];
2631
+ const defaultExcludeNames = ['^(__dirname|__filename)$', '(.*)Event$'];
2632
2632
  var varNaming = createRule({
2633
2633
  name: RULE_NAME,
2634
2634
  meta: {
@@ -2652,7 +2652,19 @@ var varNaming = createRule({
2652
2652
  "enum": ['camelCase', 'PascalCase', 'UPPER_CASE']
2653
2653
  }
2654
2654
  },
2655
- exclude: {
2655
+ excludeNames: {
2656
+ type: 'array',
2657
+ items: {
2658
+ type: 'string'
2659
+ }
2660
+ },
2661
+ excludeFuncs: {
2662
+ type: 'array',
2663
+ items: {
2664
+ type: 'string'
2665
+ }
2666
+ },
2667
+ excludeTypes: {
2656
2668
  type: 'array',
2657
2669
  items: {
2658
2670
  type: 'string'
@@ -2673,8 +2685,11 @@ var varNaming = createRule({
2673
2685
  }
2674
2686
  const funcFormat = context.options[0].funcFormat || ['camelCase'];
2675
2687
  const varFormat = context.options[0].varFormat || ['camelCase', 'UPPER_CASE'];
2676
- let exclude = context.options[0].exclude || [];
2677
- exclude = [...defaultExcludes, ...exclude];
2688
+ let excludeNames = context.options[0].excludeNames || [];
2689
+ excludeNames = [...defaultExcludeNames, ...excludeNames];
2690
+ const excludeFuncs = context.options[0].excludeFuncs || [];
2691
+ let excludeTypes = context.options[0].excludeTypes || [];
2692
+ excludeTypes = [...defaultExcludeTypes, ...excludeTypes];
2678
2693
  function validate(type, {
2679
2694
  node,
2680
2695
  name
@@ -2801,14 +2816,18 @@ var varNaming = createRule({
2801
2816
  }
2802
2817
  } else if (node.id) {
2803
2818
  const varName = node.id.name;
2804
- for (const excludeRegex of exclude) {
2819
+ for (const excludeRegex of excludeNames) {
2805
2820
  if (new RegExp(excludeRegex).test(varName)) {
2806
2821
  return;
2807
2822
  }
2808
2823
  }
2809
2824
  const typeName = getTypeReference(node);
2810
- if (typeName && otherTypes.has(typeName)) {
2811
- return;
2825
+ if (typeName) {
2826
+ for (const excludeRegex of excludeTypes) {
2827
+ if (new RegExp(excludeRegex).test(typeName)) {
2828
+ return;
2829
+ }
2830
+ }
2812
2831
  }
2813
2832
  if (node.id.parent && node.id.parent.init) {
2814
2833
  let calleeName;
@@ -2820,6 +2839,13 @@ var varNaming = createRule({
2820
2839
  shouldCheckReact = true;
2821
2840
  calleeName = node.id.parent.init.expression.callee.name;
2822
2841
  }
2842
+ if (calleeName) {
2843
+ for (const excludeRegex of excludeFuncs) {
2844
+ if (new RegExp(excludeRegex).test(calleeName)) {
2845
+ return;
2846
+ }
2847
+ }
2848
+ }
2823
2849
  if (shouldCheckReact) {
2824
2850
  if (!calleeName) {
2825
2851
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilebot/eslint-plugin",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Agilebot's ESLint plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,11 +19,11 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@eslint/compat": "^1.1.1",
22
- "@typescript-eslint/utils": "~8.5.0",
22
+ "@typescript-eslint/utils": "~8.7.0",
23
23
  "eslint-plugin-deprecation": "^3.0.0",
24
24
  "eslint-plugin-react": "^7.35.0",
25
25
  "eslint-plugin-react-hooks": "^4.6.2",
26
- "@agilebot/eslint-utils": "0.5.1"
26
+ "@agilebot/eslint-utils": "0.5.2"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0"
@@ -36,7 +36,7 @@
36
36
  "@types/estree": "^1.0.5",
37
37
  "color-name": "^2.0.0",
38
38
  "eslint-vitest-rule-tester": "^0.6.1",
39
- "typescript-eslint": "~8.5.0"
39
+ "typescript-eslint": "~8.7.0"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "rollup -c rollup.config.mjs",