@agilebot/eslint-plugin 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.js +17 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-plugin v0.3.11
2
+ * @license @agilebot/eslint-plugin v0.3.12
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -2676,6 +2676,16 @@ var varNaming = eslintUtils.createESLintRule({
2676
2676
  }
2677
2677
  return false;
2678
2678
  }
2679
+ function getTypeReference(node) {
2680
+ if (node.id.typeAnnotation && node.id.typeAnnotation.typeAnnotation) {
2681
+ const typeAnnotation = node.id.typeAnnotation.typeAnnotation;
2682
+ if (typeAnnotation.type === 'TSTypeReference' && typeAnnotation.typeName.type === 'Identifier') {
2683
+ const typeName = typeAnnotation.typeName.name;
2684
+ const typeNameLast = typeName.split('.').pop();
2685
+ return typeNameLast;
2686
+ }
2687
+ }
2688
+ }
2679
2689
  return {
2680
2690
  FunctionDeclaration(node) {
2681
2691
  if (node.type === 'FunctionDeclaration' && node.id) {
@@ -2693,15 +2703,9 @@ var varNaming = eslintUtils.createESLintRule({
2693
2703
  if (node.id && node.init && ['FunctionExpression', 'ArrowFunctionExpression'].includes(node.init.type)) {
2694
2704
  const fnName = node.id.name;
2695
2705
  let isReactComponent = checkJSXElement(node.init.body);
2696
- if (node.id.typeAnnotation && node.id.typeAnnotation.typeAnnotation) {
2697
- const typeAnnotation = node.id.typeAnnotation.typeAnnotation;
2698
- if (typeAnnotation.type === 'TSTypeReference' && typeAnnotation.typeName.type === 'Identifier') {
2699
- const typeName = typeAnnotation.typeName.name;
2700
- const typeNameLast = typeName.split('.').pop();
2701
- if (reactFCTypes.has(typeNameLast)) {
2702
- isReactComponent = true;
2703
- }
2704
- }
2706
+ const typeName = getTypeReference(node);
2707
+ if (typeName && reactFCTypes.has(typeName)) {
2708
+ isReactComponent = true;
2705
2709
  }
2706
2710
  if (!isReactComponent) {
2707
2711
  validate('func', {
@@ -2716,15 +2720,9 @@ var varNaming = eslintUtils.createESLintRule({
2716
2720
  return;
2717
2721
  }
2718
2722
  }
2719
- if (node.id.typeAnnotation && node.id.typeAnnotation.typeAnnotation) {
2720
- const typeAnnotation = node.id.typeAnnotation.typeAnnotation;
2721
- if (typeAnnotation.type === 'TSTypeReference' && typeAnnotation.typeName.type === 'Identifier') {
2722
- const typeName = typeAnnotation.typeName.name;
2723
- const typeNameLast = typeName.split('.').pop();
2724
- if (otherTypes.has(typeNameLast)) {
2725
- return;
2726
- }
2727
- }
2723
+ const typeName = getTypeReference(node);
2724
+ if (typeName && otherTypes.has(typeName)) {
2725
+ return;
2728
2726
  }
2729
2727
  if (node.id.parent && node.id.parent.init) {
2730
2728
  let calleeName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilebot/eslint-plugin",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "description": "Agilebot's ESLint plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "eslint-plugin-react": "^7.35.0",
22
- "@agilebot/eslint-utils": "0.3.11"
22
+ "@agilebot/eslint-utils": "0.3.12"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "eslint": "^7.0.0 || ^8.0.0"