eslint-plugin-no-implicit-any-function-args 1.1.12 → 1.2.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/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOvD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAE5C,eAAO,MAAM,KAAK;;CAiEjB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOvD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAE5C,eAAO,MAAM,KAAK;;CAoEjB,CAAC"}
package/index.js CHANGED
@@ -27,6 +27,7 @@ exports.rules = {
27
27
  },
28
28
  defaultOptions: [{}],
29
29
  create: (context, [options]) => {
30
+ var _a;
30
31
  if (!context.sourceCode.parserServices ||
31
32
  !context.sourceCode.parserServices.program ||
32
33
  !context.sourceCode.parserServices.esTreeNodeToTSNodeMap) {
@@ -34,12 +35,17 @@ exports.rules = {
34
35
  }
35
36
  const ignoreRegex = options.ignorePattern ? new RegExp(options.ignorePattern) : undefined;
36
37
  const service = context.sourceCode.parserServices;
37
- const typeChecker = service.program.getTypeChecker();
38
+ const typeChecker = (_a = service.program) === null || _a === void 0 ? void 0 : _a.getTypeChecker();
38
39
  function functionTest(node) {
40
+ var _a, _b;
39
41
  for (const param of node.params) {
40
42
  if (!param.typeAnnotation && !param.right) {
41
- const typescriptParam = context.sourceCode.parserServices.esTreeNodeToTSNodeMap.get(param);
42
- const type = typeChecker.getTypeAtLocation(typescriptParam);
43
+ const typescriptParam = (_b = (_a = context.sourceCode.parserServices) === null || _a === void 0 ? void 0 : _a.esTreeNodeToTSNodeMap) === null || _b === void 0 ? void 0 : _b.get(param);
44
+ if (!typescriptParam)
45
+ continue;
46
+ const type = typeChecker === null || typeChecker === void 0 ? void 0 : typeChecker.getTypeAtLocation(typescriptParam);
47
+ if (!type)
48
+ continue;
43
49
  if ((type.flags & typescript_1.TypeFlags.Any) === 0)
44
50
  continue;
45
51
  if (ignoreRegex === null || ignoreRegex === void 0 ? void 0 : ignoreRegex.test(param.name))
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AACvD,2CAAuC;AAEvC,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,GAAG,EAAE,CAAC,2EAA2E,CAClF,CAAC;AASW,QAAA,KAAK,GAAG;IACnB,+BAA+B,EAAE,UAAU,CAAsB;QAC/D,IAAI,EAAE,+BAA+B;QACrC,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,IAAI,EAAE;gBACJ,WAAW,EAAE,qDAAqD;gBAClE,oBAAoB,EAAE,IAAI;aAC3B;YACD,QAAQ,EAAE;gBACR,gBAAgB,EAAE,yCAAyC;aAC5D;YACD,MAAM,EAAE,CAAC;oBACP,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,aAAa,EAAE;4BACb,IAAI,EAAE,QAAQ;yBACf;qBACF;iBACF,CAAC;SACH;QACD,cAAc,EAAE,CAAC,EAAE,CAAC;QACpB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;YAC7B,IACE,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc;gBAClC,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAA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AAC;CACH,CAAC","sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils';\nimport { TypeFlags } from 'typescript';\n\nconst createRule = ESLintUtils.RuleCreator(\n () => 'https://github.com/fast-facts/eslint-plugin-no-implicit-any-function-args'\n);\n\nexport type Options = [\n {\n ignorePattern?: string,\n }\n];\nexport type MessageIds = 'noImplicitAnyArg';\n\nexport const rules = {\n 'no-implicit-any-function-args': createRule<Options, MessageIds>({\n name: 'no-implicit-any-function-args',\n meta: {\n type: 'problem',\n docs: {\n description: 'No implicit any for a function argument is allowed.',\n requiresTypeChecking: true\n },\n messages: {\n noImplicitAnyArg: 'Argument \\'{{ name }}\\' requires a type'\n },\n schema: [{\n type: 'object',\n properties: {\n ignorePattern: {\n type: 'string'\n }\n }\n }]\n },\n defaultOptions: [{}],\n create: (context, [options]) => {\n if (\n !context.sourceCode.parserServices ||\n !context.sourceCode.parserServices.program ||\n !context.sourceCode.parserServices.esTreeNodeToTSNodeMap\n ) {\n throw new Error(\n 'You have used a rule which requires parserServices to be generated. You must therefore provide a value for the \"parserOptions.project\" property for @typescript-eslint/parser.'\n );\n }\n\n const ignoreRegex = options.ignorePattern ? new RegExp(options.ignorePattern) : undefined;\n\n const service = context.sourceCode.parserServices;\n const typeChecker = service.program.getTypeChecker();\n\n function functionTest(node: any) {\n for (const param of node.params) {\n if (!param.typeAnnotation && !param.right) {\n const typescriptParam = context.sourceCode.parserServices.esTreeNodeToTSNodeMap.get(param);\n const type = typeChecker.getTypeAtLocation(typescriptParam);\n\n if ((type.flags & TypeFlags.Any) === 0) continue;\n if (ignoreRegex?.test(param.name)) continue;\n\n context.report({\n node: param,\n messageId: 'noImplicitAnyArg',\n data: {\n name: param.name\n }\n });\n }\n }\n }\n\n return {\n FunctionDeclaration: functionTest,\n FunctionExpression: functionTest,\n ArrowFunctionExpression: functionTest\n };\n }\n })\n};"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA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AC,KAAK,CAAC,KAAK,EAAE;wBACzC,MAAM,eAAe,GAAG,MAAA,MAAA,OAAO,CAAC,UAAU,CAAC,cAAc,0CAAE,qBAAqB,0CAAE,GAAG,CAAC,KAAK,CAAC,CAAC;wBAC7F,IAAI,CAAC,eAAe;4BAAE,SAAS;wBAE/B,MAAM,IAAI,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC;wBAC7D,IAAI,CAAC,IAAI;4BAAE,SAAS;wBAEpB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,sBAAS,CAAC,GAAG,CAAC,KAAK,CAAC;4BAAE,SAAS;wBACjD,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;4BAAE,SAAS;wBAE5C,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,KAAK;4BACX,SAAS,EAAE,kBAAkB;4BAC7B,IAAI,EAAE;gCACJ,IAAI,EAAE,KAAK,CAAC,IAAI;6BACjB;yBACF,CAAC,CAAC;qBACJ;iBACF;YACH,CAAC;YAED,OAAO;gBACL,mBAAmB,EAAE,YAAY;gBACjC,kBAAkB,EAAE,YAAY;gBAChC,uBAAuB,EAAE,YAAY;aACtC,CAAC;QACJ,CAAC;KACF,CAAC;CACH,CAAC","sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils';\nimport { TypeFlags } from 'typescript';\n\nconst createRule = ESLintUtils.RuleCreator(\n () => 'https://github.com/fast-facts/eslint-plugin-no-implicit-any-function-args'\n);\n\nexport type Options = [\n {\n ignorePattern?: string,\n }\n];\nexport type MessageIds = 'noImplicitAnyArg';\n\nexport const rules = {\n 'no-implicit-any-function-args': createRule<Options, MessageIds>({\n name: 'no-implicit-any-function-args',\n meta: {\n type: 'problem',\n docs: {\n description: 'No implicit any for a function argument is allowed.',\n requiresTypeChecking: true\n },\n messages: {\n noImplicitAnyArg: 'Argument \\'{{ name }}\\' requires a type'\n },\n schema: [{\n type: 'object',\n properties: {\n ignorePattern: {\n type: 'string'\n }\n }\n }]\n },\n defaultOptions: [{}],\n create: (context, [options]) => {\n if (\n !context.sourceCode.parserServices ||\n !context.sourceCode.parserServices.program ||\n !context.sourceCode.parserServices.esTreeNodeToTSNodeMap\n ) {\n throw new Error(\n 'You have used a rule which requires parserServices to be generated. You must therefore provide a value for the \"parserOptions.project\" property for @typescript-eslint/parser.'\n );\n }\n\n const ignoreRegex = options.ignorePattern ? new RegExp(options.ignorePattern) : undefined;\n\n const service = context.sourceCode.parserServices;\n const typeChecker = service.program?.getTypeChecker();\n\n function functionTest(node: any) {\n for (const param of node.params) {\n if (!param.typeAnnotation && !param.right) {\n const typescriptParam = context.sourceCode.parserServices?.esTreeNodeToTSNodeMap?.get(param);\n if (!typescriptParam) continue;\n\n const type = typeChecker?.getTypeAtLocation(typescriptParam);\n if (!type) continue;\n\n if ((type.flags & TypeFlags.Any) === 0) continue;\n if (ignoreRegex?.test(param.name)) continue;\n\n context.report({\n node: param,\n messageId: 'noImplicitAnyArg',\n data: {\n name: param.name\n }\n });\n }\n }\n }\n\n return {\n FunctionDeclaration: functionTest,\n FunctionExpression: functionTest,\n ArrowFunctionExpression: functionTest\n };\n }\n })\n};"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-no-implicit-any-function-args",
3
- "version": "1.1.12",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,23 +16,23 @@
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
- "@typescript-eslint/utils": "^6.20.0"
19
+ "@typescript-eslint/utils": "^7.0.1"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "typescript": "^4.2.4 || ^5.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/jest": "^29.5.11",
26
- "@types/node": "^20.11.10",
27
- "@typescript-eslint/eslint-plugin": "^6.20.0",
28
- "@typescript-eslint/parser": "^6.20.0",
29
- "@typescript-eslint/rule-tester": "^6.20.0",
25
+ "@types/jest": "^29.5.12",
26
+ "@types/node": "^20.11.17",
27
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
28
+ "@typescript-eslint/parser": "^7.0.1",
29
+ "@typescript-eslint/rule-tester": "^7.0.1",
30
30
  "copyfiles": "^2.4.1",
31
31
  "eslint": "^8.56.0",
32
32
  "eslint-plugin-deprecation": "^2.0.0",
33
33
  "jest": "^29.7.0",
34
34
  "rimraf": "^5.0.5",
35
- "ts-api-utils": "^1.0.3",
35
+ "ts-api-utils": "^1.2.1",
36
36
  "ts-jest": "^29.1.2"
37
37
  }
38
38
  }