@checkdigit/eslint-plugin 4.0.0-beta.1 → 4.1.0-PR.32-b8ce

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 (61) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +6 -9
  3. package/SECURITY.md +14 -0
  4. package/dist/file-path-comment.d.ts +1 -0
  5. package/dist/file-path-comment.d.ts.map +1 -0
  6. package/dist/file-path-comment.js +1 -1
  7. package/dist/file-path-comment.js.map +1 -1
  8. package/dist/file-path-comment.spec.d.ts +1 -0
  9. package/dist/file-path-comment.spec.d.ts.map +1 -0
  10. package/dist/file-path-comment.spec.js +1 -1
  11. package/dist/file-path-comment.spec.js.map +1 -1
  12. package/dist/index.d.ts +4 -3
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +5 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/no-card-numbers.d.ts +1 -0
  17. package/dist/no-card-numbers.d.ts.map +1 -0
  18. package/dist/no-card-numbers.js +10 -3
  19. package/dist/no-card-numbers.js.map +1 -1
  20. package/dist/no-card-numbers.spec.d.ts +1 -0
  21. package/dist/no-card-numbers.spec.d.ts.map +1 -0
  22. package/dist/no-card-numbers.spec.js +31 -1
  23. package/dist/no-card-numbers.spec.js.map +1 -1
  24. package/dist/{pure-functions.d.ts → no-uuid.d.ts} +1 -0
  25. package/dist/no-uuid.d.ts.map +1 -0
  26. package/dist/no-uuid.js +102 -0
  27. package/dist/no-uuid.js.map +1 -0
  28. package/dist/no-uuid.spec.d.ts +2 -0
  29. package/dist/no-uuid.spec.d.ts.map +1 -0
  30. package/dist/no-uuid.spec.js +78 -0
  31. package/dist/no-uuid.spec.js.map +1 -0
  32. package/package.json +1 -67
  33. package/src/file-path-comment.ts +1 -1
  34. package/src/index.ts +5 -5
  35. package/src/no-card-numbers.ts +14 -4
  36. package/src/no-uuid.ts +109 -0
  37. package/.eslintrc +0 -76
  38. package/coverage/clover.xml +0 -94
  39. package/coverage/coverage-final.json +0 -4
  40. package/coverage/lcov-report/base.css +0 -224
  41. package/coverage/lcov-report/block-navigation.js +0 -87
  42. package/coverage/lcov-report/favicon.png +0 -0
  43. package/coverage/lcov-report/file-path-comment.ts.html +0 -349
  44. package/coverage/lcov-report/index.html +0 -146
  45. package/coverage/lcov-report/no-card-numbers.ts.html +0 -508
  46. package/coverage/lcov-report/prettify.css +0 -1
  47. package/coverage/lcov-report/prettify.js +0 -2
  48. package/coverage/lcov-report/pure-functions.ts.html +0 -301
  49. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  50. package/coverage/lcov-report/sorter.js +0 -196
  51. package/coverage/lcov.info +0 -176
  52. package/dist/pure-functions.js +0 -55
  53. package/dist/pure-functions.js.map +0 -1
  54. package/dist/pure-functions.spec.d.ts +0 -1
  55. package/dist/pure-functions.spec.js +0 -90
  56. package/dist/pure-functions.spec.js.map +0 -1
  57. package/src/file-path-comment.spec.ts +0 -71
  58. package/src/no-card-numbers.spec.ts +0 -114
  59. package/src/pure-functions.spec.ts +0 -93
  60. package/src/pure-functions.ts +0 -72
  61. package/tsconfig.json +0 -12
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2021-2022 Check Digit, LLC
3
+ Copyright (c) 2021-2023 Check Digit, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,20 +1,17 @@
1
1
  # checkdigit/eslint-plugin
2
2
 
3
- [![MIT License](https://img.shields.io/github/license/checkdigit/eslint-plugin)](https://github.com/checkdigit/eslint-plugin/blob/master/LICENSE.txt)
4
- [![David](https://status.david-dm.org/gh/checkdigit/eslint-plugin.svg)](https://status.david-dm.org/gh/checkdigit/eslint-plugin.svg)
5
-
6
- Copyright (c) 2021 [Check Digit, LLC](https://checkdigit.com)
3
+ Copyright (c) 2021-2023 [Check Digit, LLC](https://checkdigit.com)
7
4
 
8
5
  ## Rules
9
6
 
10
- * `@checkdigit/no-card-numbers`
11
- * `@checkdigit/file-path-comment`
12
- * `@checkdigit/pure-functions`
7
+ - `@checkdigit/no-card-numbers`
8
+ - `@checkdigit/file-path-comment`
9
+ - `@checkdigit/no-uuid`
13
10
 
14
11
  ## Configurations
15
12
 
16
- * `@checkdigit/all`
17
- * `@checkdigit/recommended`
13
+ - `@checkdigit/all`
14
+ - `@checkdigit/recommended`
18
15
 
19
16
  ## License
20
17
 
package/SECURITY.md ADDED
@@ -0,0 +1,14 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ These versions of `@checkdigit/eslint-plugin` are currently being supported with security updates.
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | \>= 4.0 | :white_check_mark: |
10
+ | \< 4.0 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ Please create an issue at https://github.com/checkdigit/eslint-plugin/issues
@@ -1,3 +1,4 @@
1
1
  import type { Rule } from 'eslint';
2
2
  declare const _default: Rule.RuleModule;
3
3
  export default _default;
4
+ //# sourceMappingURL=file-path-comment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-path-comment.d.ts","sourceRoot":"","sources":["../src/file-path-comment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;;AAQnC,wBA6EqB"}
@@ -2,7 +2,7 @@
2
2
  // file-path-comment.ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  /*
5
- * Copyright (c) 2021 Check Digit, LLC
5
+ * Copyright (c) 2021-2022 Check Digit, LLC
6
6
  *
7
7
  * This code is licensed under the MIT license (see LICENSE.txt for details).
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"file-path-comment.js","sourceRoot":"","sources":["../src/file-path-comment.ts"],"names":[],"mappings":";AAAA,uBAAuB;;AAIvB;;;;GAIG;AAEH,kBAAe;IACb,IAAI,E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EAAE,CAAC;yBACV;qBACF;oBACD,OAAO,EAAE,uDAAuD;oBAChE,GAAG,CAAC,KAAqB;wBACvB,OAAO,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,YAAY,EAAE,CAAC,CAAC;oBAC7E,CAAC;iBACF,CAAC,CAAC;aACJ;SACF;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACiB,CAAC","sourcesContent":["// file-path-comment.ts\n\nimport type { Rule } from 'eslint';\n\n/*\n * Copyright (c) 2021-2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nexport default {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Validate that first line of file is a path to the file',\n url: 'https://github.com/checkdigit/eslint-plugin',\n },\n fixable: 'code',\n },\n create(context) {\n const firstLine = context.getSourceCode().getLines()[0] as string;\n const expectedPath = context.getFilename().split('src/')[1];\n\n if (expectedPath === undefined) {\n return {};\n }\n\n if (!firstLine.startsWith('//')) {\n if (firstLine.startsWith('/*')) {\n context.report({\n loc: {\n start: {\n line: 0,\n column: 0,\n },\n end: {\n line: 0,\n column: 1,\n },\n },\n message: 'first line cannot be a block comment',\n fix(fixer: Rule.RuleFixer) {\n return fixer.insertTextBeforeRange([0, 0], `// ${expectedPath}\\n\\n`);\n },\n });\n } else {\n context.report({\n loc: {\n start: {\n line: 0,\n column: 0,\n },\n end: {\n line: 0,\n column: 1,\n },\n },\n message: 'first line is not a comment with the file path',\n fix(fixer: Rule.RuleFixer) {\n return fixer.insertTextBeforeRange([0, 0], `// ${expectedPath}\\n\\n`);\n },\n });\n }\n } else {\n const actualComment = firstLine.split('// ')[1];\n if (expectedPath !== actualComment) {\n context.report({\n loc: {\n start: {\n line: 0,\n column: 0,\n },\n end: {\n line: 0,\n column: 1,\n },\n },\n message: 'first line is a comment but is not a path to the file',\n fix(fixer: Rule.RuleFixer) {\n return fixer.replaceTextRange([0, firstLine.length], `// ${expectedPath}`);\n },\n });\n }\n }\n\n return {};\n },\n} as Rule.RuleModule;\n"]}
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=file-path-comment.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-path-comment.spec.d.ts","sourceRoot":"","sources":["../src/file-path-comment.spec.ts"],"names":[],"mappings":""}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  /*
8
- * Copyright (c) 2021 Check Digit, LLC
8
+ * Copyright (c) 2021-2022 Check Digit, LLC
9
9
  *
10
10
  * This code is licensed under the MIT license (see LICENSE.txt for details).
11
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"file-path-comment.spec.js","sourceRoot":"","sources":["../src/file-path-comment.spec.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;;;AAE5B;;;;GAIG;AAEH,mCAAoC;AAEpC,4EAAuC;AAEvC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,EAAE,aAAa,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAE5E,UAAU,CAAC,GAAG,CAAC,mBAAmB,EAAE,2BAAI,EAAE;QACxC,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE,oBAAoB;gBAC9B,IAAI,EAAE,mBAAmB;gBACzB,aAAa,EAAE;oBACb,OAAO,EAAE,iBAAiB;iBAC3B;aACF;YACD;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,eAAe;aACtB;YACD;gBACE,QAAQ,EAAE,UAAU;gBACpB,IAAI,EAAE,+BAA+B;aACtC;YACD;gBACE,QAAQ,EAAE,iBAAiB;gBAC3B,IAAI,EAAE,+BAA+B;aACtC;SACF;QACD,OAAO,EAAE;YACP;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE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oBACb,OAAO,EAAE,iBAAiB;iBAC3B;aACF;YACD;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,eAAe;aACtB;YACD;gBACE,QAAQ,EAAE,UAAU;gBACpB,IAAI,EAAE,+BAA+B;aACtC;YACD;gBACE,QAAQ,EAAE,iBAAiB;gBAC3B,IAAI,EAAE,+BAA+B;aACtC;SACF;QACD,OAAO,EAAE;YACP;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,iBAAiB;gBACvB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,uDAAuD,EAAE,CAAC;gBAC9E,MAAM,EAAE,aAAa;aACtB;YACD;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,cAAc;gBACpB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,uDAAuD,EAAE,CAAC;gBAC9E,MAAM,EAAE,eAAe;aACxB;YACD;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,oBAAoB;gBAC1B,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;gBAC7D,MAAM,EAAE,mCAAmC;aAC5C;YACD;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,gDAAgD,EAAE,CAAC;gBACvE,MAAM,EAAE,+BAA+B;aACxC;YACD;gBACE,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,gDAAgD,EAAE,CAAC;gBACvE,MAAM,EAAE,iBAAiB;aAC1B;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// file-path-comment.spec.ts\n\n/*\n * Copyright (c) 2021-2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport { RuleTester } from 'eslint';\n\nimport rule from './file-path-comment';\n\ndescribe('file-path-comment', () => {\n const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2020 } });\n\n ruleTester.run('file-path-comment', rule, {\n valid: [\n {\n filename: 'src/world/hello.ts',\n code: `// world/hello.ts`,\n parserOptions: {\n project: './tsconfig.json',\n },\n },\n {\n filename: 'src/hello.ts',\n code: `// hello.ts\\n`,\n },\n {\n filename: 'hello.ts',\n code: `// whatever does not matter\\n`,\n },\n {\n filename: 'source/hello.ts',\n code: `// whatever does not matter\\n`,\n },\n ],\n invalid: [\n {\n filename: 'src/hello.ts',\n code: `// not-hello.ts`,\n errors: [{ message: 'first line is a comment but is not a path to the file' }],\n output: `// hello.ts`,\n },\n {\n filename: 'src/hello.ts',\n code: `//hello.ts\\n`,\n errors: [{ message: 'first line is a comment but is not a path to the file' }],\n output: `// hello.ts\\n`,\n },\n {\n filename: 'src/hello.ts',\n code: `/* not-hello.ts */`,\n errors: [{ message: 'first line cannot be a block comment' }],\n output: `// hello.ts\\n\\n/* not-hello.ts */`,\n },\n {\n filename: 'src/hello.ts',\n code: `const x = 123;`,\n errors: [{ message: 'first line is not a comment with the file path' }],\n output: `// hello.ts\\n\\nconst x = 123;`,\n },\n {\n filename: 'src/hello.ts',\n code: ``,\n errors: [{ message: 'first line is not a comment with the file path' }],\n output: `// hello.ts\\n\\n`,\n },\n ],\n });\n});\n"]}
package/dist/index.d.ts CHANGED
@@ -2,23 +2,24 @@ declare const _default: {
2
2
  rules: {
3
3
  'file-path-comment': import("eslint").Rule.RuleModule;
4
4
  'no-card-numbers': import("eslint").Rule.RuleModule;
5
- 'pure-functions': import("eslint").Rule.RuleModule;
5
+ 'no-uuid': import("eslint").Rule.RuleModule;
6
6
  };
7
7
  configs: {
8
8
  all: {
9
9
  rules: {
10
10
  '@checkdigit/no-card-numbers': string;
11
11
  '@checkdigit/file-path-comment': string;
12
- '@checkdigit/pure-functions': string;
12
+ '@checkdigit/no-uuid': string;
13
13
  };
14
14
  };
15
15
  recommended: {
16
16
  rules: {
17
17
  '@checkdigit/no-card-numbers': string;
18
18
  '@checkdigit/file-path-comment': string;
19
- '@checkdigit/pure-functions': string;
19
+ '@checkdigit/no-uuid': string;
20
20
  };
21
21
  };
22
22
  };
23
23
  };
24
24
  export default _default;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAYA,wBAsBE"}
package/dist/index.js CHANGED
@@ -5,32 +5,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  /*
8
- * Copyright (c) 2021 Check Digit, LLC
8
+ * Copyright (c) 2021-2022 Check Digit, LLC
9
9
  *
10
10
  * This code is licensed under the MIT license (see LICENSE.txt for details).
11
11
  */
12
12
  const file_path_comment_1 = __importDefault(require("./file-path-comment"));
13
13
  const no_card_numbers_1 = __importDefault(require("./no-card-numbers"));
14
- const pure_functions_1 = __importDefault(require("./pure-functions"));
14
+ const no_uuid_1 = __importDefault(require("./no-uuid"));
15
15
  exports.default = {
16
16
  rules: {
17
17
  'file-path-comment': file_path_comment_1.default,
18
18
  'no-card-numbers': no_card_numbers_1.default,
19
- 'pure-functions': pure_functions_1.default,
19
+ 'no-uuid': no_uuid_1.default,
20
20
  },
21
21
  configs: {
22
22
  all: {
23
23
  rules: {
24
24
  '@checkdigit/no-card-numbers': 'error',
25
25
  '@checkdigit/file-path-comment': 'error',
26
- '@checkdigit/pure-functions': 'error',
26
+ '@checkdigit/no-uuid': 'error',
27
27
  },
28
28
  },
29
29
  recommended: {
30
30
  rules: {
31
31
  '@checkdigit/no-card-numbers': 'error',
32
32
  '@checkdigit/file-path-comment': 'off',
33
- '@checkdigit/pure-functions': 'off',
33
+ '@checkdigit/no-uuid': 'error',
34
34
  },
35
35
  },
36
36
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,WAAW;;;;;AAEX;;;;GAIG;AAEH,4EAAkD;AAClD,wEAA8C;AAC9C,sEAA6C;AAE7C,kBAAe;IACb,KAAK,EAAE;QACL,mBAAmB,EAAE,2BAAe;QACpC,iBAAiB,EAAE,yBAAa;QAChC,gBAAgB,EAAE,wBAAa;KAChC;IACD,OAAO,EAAE;QACP,GAAG,EAAE;YACH,KAAK,EAAE;gBACL,6BAA6B,EAAE,OAAO;gBACtC,+BAA+B,EAAE,OAAO;gBACxC,4BAA4B,EAAE,OAAO;aACtC;SACF;QACD,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,6BAA6B,EAAE,OAAO;gBACtC,+BAA+B,EAAE,KAAK;gBACtC,4BAA4B,EAAE,KAAK;aACpC;SACF;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,WAAW;;;;;AAEX;;;;GAIG;AAEH,4EAAkD;AAClD,wEAA8C;AAC9C,wDAA+B;AAE/B,kBAAe;IACb,KAAK,EAAE;QACL,mBAAmB,EAAE,2BAAe;QACpC,iBAAiB,EAAE,yBAAa;QAChC,SAAS,EAAE,iBAAM;KAClB;IACD,OAAO,EAAE;QACP,GAAG,EAAE;YACH,KAAK,EAAE;gBACL,6BAA6B,EAAE,OAAO;gBACtC,+BAA+B,EAAE,OAAO;gBACxC,qBAAqB,EAAE,OAAO;aAC/B;SACF;QACD,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,6BAA6B,EAAE,OAAO;gBACtC,+BAA+B,EAAE,KAAK;gBACtC,qBAAqB,EAAE,OAAO;aAC/B;SACF;KACF;CACF,CAAC","sourcesContent":["// index.ts\n\n/*\n * Copyright (c) 2021-2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport filePathComment from './file-path-comment';\nimport noCardNumbers from './no-card-numbers';\nimport noUuid from './no-uuid';\n\nexport default {\n rules: {\n 'file-path-comment': filePathComment,\n 'no-card-numbers': noCardNumbers,\n 'no-uuid': noUuid,\n },\n configs: {\n all: {\n rules: {\n '@checkdigit/no-card-numbers': 'error',\n '@checkdigit/file-path-comment': 'error',\n '@checkdigit/no-uuid': 'error',\n },\n },\n recommended: {\n rules: {\n '@checkdigit/no-card-numbers': 'error',\n '@checkdigit/file-path-comment': 'off',\n '@checkdigit/no-uuid': 'error',\n },\n },\n },\n};\n"]}
@@ -1,3 +1,4 @@
1
1
  import type { Rule } from 'eslint';
2
2
  declare const _default: Rule.RuleModule;
3
3
  export default _default;
4
+ //# sourceMappingURL=no-card-numbers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-card-numbers.d.ts","sourceRoot":"","sources":["../src/no-card-numbers.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;;AAkGnC,wBA2CqB"}
@@ -37,7 +37,14 @@ function checkForCardNumbers(value, context, node, loc) {
37
37
  if (matches === null) {
38
38
  return;
39
39
  }
40
- const cardNumbers = matches.filter((match) => luhnCheck(match) && allowCardNumbers.indexOf(match) === -1);
40
+ const cardNumbers = matches.filter((match) => luhnCheck(match) &&
41
+ allowCardNumbers.indexOf(match) === -1 &&
42
+ // any 16-digit number that begins with 0-1 or 7-9 is not a valid card number
43
+ match[0] !== '0' &&
44
+ match[0] !== '1' &&
45
+ match[0] !== '7' &&
46
+ match[0] !== '8' &&
47
+ match[0] !== '9');
41
48
  if (cardNumbers.length === 1) {
42
49
  if (node !== undefined) {
43
50
  context.report({
@@ -66,7 +73,7 @@ function checkForCardNumbers(value, context, node, loc) {
66
73
  context.report({
67
74
  messageId: CARD_NUMBERS_FOUND,
68
75
  data: {
69
- number: matches.join(', '),
76
+ numbers: matches.join(', '),
70
77
  },
71
78
  node,
72
79
  });
@@ -75,7 +82,7 @@ function checkForCardNumbers(value, context, node, loc) {
75
82
  context.report({
76
83
  messageId: CARD_NUMBERS_FOUND,
77
84
  data: {
78
- number: matches.join(', '),
85
+ numbers: matches.join(', '),
79
86
  },
80
87
  loc: {
81
88
  start: loc.start,
@@ -1 +1 @@
1
- {"version":3,"file":"no-card-numbers.js","sourceRoot":"","sources":["../src/no-card-numbers.ts"],"names":[],"mappings":";AAAA,qBAAqB;;AAWrB,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAChD,MAAM,eAAe,GAAG,cAAc,CAAC;AACvC,MAAM,gBAAgB,GAAG;IACvB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC;AAEF,SAAS,SAAS,CAAC,UAAkB;IACnC,OAAO,CACL,UAAU;SACP,KAAK,CAAC,EAAE,CAAC;SACT,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;SACnC,MAAM,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE;QAC7C,IAAI,KAAK,GAAG,YAAY,CAAC;QACzB,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,KAAK,IAAI,CAAC,CAAC;YACX,4CAA4C;YAC5C,IAAI,KAAK,GAAG,CAAC,EAAE;gBACb,KAAK,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;aAC1B;SACF;QACD,OAAO,aAAa,GAAG,KAAK,CAAC;IAC/B,CAAC,EAAE,CAAC,CAAC;QACL,EAAE;QACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa,EAAE,OAAyB,EAAE,IAAW,EAAE,GAAoB;IACtG,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC7C,IAAI,O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iBACR;gBACD,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC9B,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC5C,CAAC;YACD,eAAe,CAAC,IAAI;gBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;oBACf,OAAO;iBACR;gBACD,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE;oBACzC,OAAO;iBACR;gBACD,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACxD,CAAC;SACF,CAAC;IACJ,CAAC;CACiB,CAAC","sourcesContent":["// no-card-numbers.ts\n\n/*\n * Copyright (c) 2021-2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport type { Node, SourceLocation } from 'estree';\nimport type { Rule } from 'eslint';\n\nconst CARD_NUMBER_FOUND = 'CARD_NUMBER_FOUND';\nconst CARD_NUMBERS_FOUND = 'CARD_NUMBERS_FOUND';\nconst cardNumberRegex = /\\d{15,19}/gmu;\nconst allowCardNumbers = [\n '4111111111111111',\n '111111111111111',\n '000000000000000',\n '0000000000000000',\n '00000000000000000',\n '000000000000000000',\n '0000000000000000000',\n];\n\nfunction luhnCheck(cardNumber: string) {\n return (\n cardNumber\n .split('')\n .reverse()\n .map((digit) => parseInt(digit, 10))\n .reduce((previousValue, currentValue, index) => {\n let value = currentValue;\n if (index % 2 === 1) {\n value *= 2;\n // eslint-disable-next-line no-magic-numbers\n if (value > 9) {\n value = (value % 10) + 1;\n }\n }\n return previousValue + value;\n }, 0) %\n 10 ===\n 0\n );\n}\n\nfunction checkForCardNumbers(value: string, context: Rule.RuleContext, node?: Node, loc?: SourceLocation) {\n const matches = value.match(cardNumberRegex);\n if (matches === null) {\n return;\n }\n const cardNumbers = matches.filter(\n (match) =>\n luhnCheck(match) &&\n allowCardNumbers.indexOf(match) === -1 &&\n // any 16-digit number that begins with 0-1 or 7-9 is not a valid card number\n match[0] !== '0' &&\n match[0] !== '1' &&\n match[0] !== '7' &&\n match[0] !== '8' &&\n match[0] !== '9'\n );\n if (cardNumbers.length === 1) {\n if (node !== undefined) {\n context.report({\n messageId: CARD_NUMBER_FOUND,\n data: {\n number: cardNumbers[0] as string,\n },\n node,\n });\n } else if (loc !== undefined) {\n context.report({\n messageId: CARD_NUMBER_FOUND,\n data: {\n number: cardNumbers[0] as string,\n },\n loc: {\n start: loc.start,\n end: loc.end,\n },\n });\n }\n } else if (cardNumbers.length > 1) {\n if (node !== undefined) {\n context.report({\n messageId: CARD_NUMBERS_FOUND,\n data: {\n numbers: matches.join(', '),\n },\n node,\n });\n } else if (loc !== undefined) {\n context.report({\n messageId: CARD_NUMBERS_FOUND,\n data: {\n numbers: matches.join(', '),\n },\n loc: {\n start: loc.start,\n end: loc.end,\n },\n });\n }\n }\n}\n\nexport default {\n meta: {\n type: 'problem',\n docs: {\n description: 'Detects if a luhn passing card number',\n url: 'https://github.com/checkdigit/eslint-plugin',\n },\n messages: {\n [CARD_NUMBER_FOUND]: `Valid card number: \"{{ number }}\"`,\n [CARD_NUMBERS_FOUND]: `Multiple valid card numbers found: \"{{ numbers }}\"`,\n },\n },\n create(context) {\n const sourceCode = context.getSourceCode();\n const comments = sourceCode.getAllComments();\n\n comments.forEach((comment) => {\n if (comment.loc !== undefined && comment.loc !== null) {\n checkForCardNumbers(comment.value, context, undefined, comment.loc);\n }\n });\n return {\n Literal(node) {\n if (node.value === undefined) {\n return;\n }\n if (typeof node.value !== 'string' && typeof node.value !== 'number') {\n return;\n }\n const value = `${node.value}`;\n checkForCardNumbers(value, context, node);\n },\n TemplateElement(node) {\n if (!node.value) {\n return;\n }\n if (typeof node.value.cooked !== 'string') {\n return;\n }\n checkForCardNumbers(node.value.cooked, context, node);\n },\n };\n },\n} as Rule.RuleModule;\n"]}
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=no-card-numbers.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-card-numbers.spec.d.ts","sourceRoot":"","sources":["../src/no-card-numbers.spec.ts"],"names":[],"mappings":""}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  /*
8
- * Copyright (c) 2021 Check Digit, LLC
8
+ * Copyright (c) 2021-2022 Check Digit, LLC
9
9
  *
10
10
  * This code is licensed under the MIT license (see LICENSE.txt for details).
11
11
  */
@@ -61,6 +61,21 @@ const foo = 'nothing wrong here';
61
61
  const STRING_WITH_CARD_NUMBER_THAT_DOESNT_PASS_LUHN_CHECK = `
62
62
  const foo = 4507894813950285;
63
63
  `;
64
+ const CONTAINS_PASSING_BUT_INVALID_0_PREFIX_CARD_NUMBER_IN_STRING = `
65
+ const foo = '0027576507977237';
66
+ `;
67
+ const CONTAINS_PASSING_BUT_INVALID_1_PREFIX_CARD_NUMBER_IN_STRING = `
68
+ const foo = '1237027241007794';
69
+ `;
70
+ const CONTAINS_PASSING_BUT_INVALID_7_PREFIX_CARD_NUMBER_IN_STRING = `
71
+ const foo = '7603721237334401';
72
+ `;
73
+ const CONTAINS_PASSING_BUT_INVALID_8_PREFIX_CARD_NUMBER_IN_STRING = `
74
+ const foo = '8119915764450821';
75
+ `;
76
+ const CONTAINS_PASSING_BUT_INVALID_9_PREFIX_CARD_NUMBER_IN_STRING = `
77
+ const foo = '9118724531442999';
78
+ `;
64
79
  describe('no-card-numbers', () => {
65
80
  const ruleTester = new eslint_1.RuleTester({ parserOptions: { ecmaVersion: 2020 } });
66
81
  ruleTester.run('no-card-numbers', no_card_numbers_1.default, {
@@ -80,6 +95,21 @@ describe('no-card-numbers', () => {
80
95
  {
81
96
  code: CONTAINS_A_PASSING_CARD_NUMBER_IN_COMMENT,
82
97
  },
98
+ {
99
+ code: CONTAINS_PASSING_BUT_INVALID_0_PREFIX_CARD_NUMBER_IN_STRING,
100
+ },
101
+ {
102
+ code: CONTAINS_PASSING_BUT_INVALID_1_PREFIX_CARD_NUMBER_IN_STRING,
103
+ },
104
+ {
105
+ code: CONTAINS_PASSING_BUT_INVALID_7_PREFIX_CARD_NUMBER_IN_STRING,
106
+ },
107
+ {
108
+ code: CONTAINS_PASSING_BUT_INVALID_8_PREFIX_CARD_NUMBER_IN_STRING,
109
+ },
110
+ {
111
+ code: CONTAINS_PASSING_BUT_INVALID_9_PREFIX_CARD_NUMBER_IN_STRING,
112
+ },
83
113
  ],
84
114
  invalid: [
85
115
  {
@@ -1 +1 @@
1
- {"version":3,"file":"no-card-numbers.spec.js","sourceRoot":"","sources":["../src/no-card-numbers.spec.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;;;AAE1B;;;;GAIG;AAEH,mCAAoC;AAEpC,wEAAqC;AAErC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD,MAAM,qBAAqB,GAAG;IAC5B,SAAS,EAAE,iBAAiB;CAC7B,CAAC;AAEF,MAAM,sBAAsB,GAAG;IAC7B,SAAS,EAAE,kBAAkB;CAC9B,CAAC;AAEF,MAAM,WAAW,GAAG;;CAEnB,CAAC;AAEF,uDAAuD;AACvD,MAAM,aAAa,GAAG,mEAAmE,CAAC;AAE1F,MAAM,8BAA8B,GAAG;;CAEtC,CAAC;AAEF,MAAM,8BAA8B,GAAG;;;;;;;;;CAStC,CAAC;AAEF,MAAM,yCAAyC,GAAG;;;;;;;;;CASjD,CAAC;AAEF,MAAM,uCAAuC,GAAG;;CAE/C,CAAC;AAEF,MAAM,+BAA+B,GAAG;;;CAGvC,CAAC;AAEF,MAAM,wCAAwC,GAAG;;;CAGhD,CAAC;AAEF,MAAM,mDAAmD,GAAG;;CAE3D,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,MAAM,UAAU,GAAG,IAAI,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C;YACD;gBACE,IAAI,EAAE,+BAA+B;gBACrC,MAAM,EAAE,CAAC,qBAAqB,CAAC;aAChC;YACD;gBACE,IAAI,EAAE,wCAAwC;gBAC9C,MAAM,EAAE,CAAC,sBAAsB,CAAC;aACjC;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// no-card-numbers.spec.ts\n\n/*\n * Copyright (c) 2021-2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport { RuleTester } from 'eslint';\n\nimport rule from './no-card-numbers';\n\nconst CARD_NUMBER_FOUND = 'CARD_NUMBER_FOUND';\nconst CARD_NUMBERS_FOUND = 'CARD_NUMBERS_FOUND';\n\nconst CARD_NUMBER_FOUND_MSG = {\n messageId: CARD_NUMBER_FOUND,\n};\n\nconst CARD_NUMBERS_FOUND_MSG = {\n messageId: CARD_NUMBERS_FOUND,\n};\n\nconst STRING_TEST = `\nconst NOT_A_SECRET = \"I'm not a secret, I think\";\n`;\n\n// eslint-disable-next-line no-template-curly-in-string\nconst TEMPLATE_TEST = \"const NOT_A_SECRET = `A template that isn't a secret. ${1+1} = 2`\";\n\nconst CONTAINS_CARD_NUMBER_IN_NUMBER = `\nconst foo = 4507894813950280;\n`;\n\nconst CONTAINS_A_PASSING_CARD_NUMBER = `\nconst foo = 4111111111111111;\nconst fuz = 123111111111111111567;\nconst bar = 111111111111111;\nconst baz = 000000000000000;\nconst far = 0000000000000000;\nconst faz = 00000000000000000;\nconst doo = 000000000000000000;\nconst dar = 0000000000000000000;\n`;\n\nconst CONTAINS_A_PASSING_CARD_NUMBER_IN_COMMENT = `\n// 4111111111111111;\n// 123111111111111111567;\n// 111111111111111;\n// 000000000000000;\n// 0000000000000000;\n// 00000000000000000;\n// 000000000000000000;\n// 0000000000000000000;\n`;\n\nconst CONTAINS_SEVERAL_CARD_NUMBERS_IN_STRING = `\nconst foo = '4507894813950280 aa 4939816588221579';\n`;\n\nconst CONTAINS_CARD_NUMBER_IN_COMMENT = `\n// this test will be using this valid card number -> 4507894813950280\nconst foo = 'nothing wrong here';\n`;\n\nconst CONTAINS_SEVERAL_CARD_NUMBERS_IN_COMMENT = `\n// this test will be using these valid card numbers -> 4507894813950280 and 4732643354095204\nconst foo = 'nothing wrong here';\n`;\n\nconst STRING_WITH_CARD_NUMBER_THAT_DOESNT_PASS_LUHN_CHECK = `\n const foo = 4507894813950285;\n`;\n\nconst CONTAINS_PASSING_BUT_INVALID_0_PREFIX_CARD_NUMBER_IN_STRING = `\nconst foo = '0027576507977237';\n`;\n\nconst CONTAINS_PASSING_BUT_INVALID_1_PREFIX_CARD_NUMBER_IN_STRING = `\nconst foo = '1237027241007794';\n`;\n\nconst CONTAINS_PASSING_BUT_INVALID_7_PREFIX_CARD_NUMBER_IN_STRING = `\nconst foo = '7603721237334401';\n`;\n\nconst CONTAINS_PASSING_BUT_INVALID_8_PREFIX_CARD_NUMBER_IN_STRING = `\nconst foo = '8119915764450821';\n`;\n\nconst CONTAINS_PASSING_BUT_INVALID_9_PREFIX_CARD_NUMBER_IN_STRING = `\nconst foo = '9118724531442999';\n`;\n\ndescribe('no-card-numbers', () => {\n const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2020 } });\n ruleTester.run('no-card-numbers', rule, {\n valid: [\n {\n code: STRING_TEST,\n },\n {\n code: TEMPLATE_TEST,\n },\n {\n code: STRING_WITH_CARD_NUMBER_THAT_DOESNT_PASS_LUHN_CHECK,\n },\n {\n code: CONTAINS_A_PASSING_CARD_NUMBER,\n },\n {\n code: CONTAINS_A_PASSING_CARD_NUMBER_IN_COMMENT,\n },\n {\n code: CONTAINS_PASSING_BUT_INVALID_0_PREFIX_CARD_NUMBER_IN_STRING,\n },\n {\n code: CONTAINS_PASSING_BUT_INVALID_1_PREFIX_CARD_NUMBER_IN_STRING,\n },\n {\n code: CONTAINS_PASSING_BUT_INVALID_7_PREFIX_CARD_NUMBER_IN_STRING,\n },\n {\n code: CONTAINS_PASSING_BUT_INVALID_8_PREFIX_CARD_NUMBER_IN_STRING,\n },\n {\n code: CONTAINS_PASSING_BUT_INVALID_9_PREFIX_CARD_NUMBER_IN_STRING,\n },\n ],\n invalid: [\n {\n code: CONTAINS_CARD_NUMBER_IN_NUMBER,\n errors: [CARD_NUMBER_FOUND_MSG],\n },\n {\n code: CONTAINS_SEVERAL_CARD_NUMBERS_IN_STRING,\n errors: [CARD_NUMBERS_FOUND_MSG],\n },\n {\n code: CONTAINS_CARD_NUMBER_IN_COMMENT,\n errors: [CARD_NUMBER_FOUND_MSG],\n },\n {\n code: CONTAINS_SEVERAL_CARD_NUMBERS_IN_COMMENT,\n errors: [CARD_NUMBERS_FOUND_MSG],\n },\n ],\n });\n});\n"]}
@@ -1,3 +1,4 @@
1
1
  import type { Rule } from 'eslint';
2
2
  declare const _default: Rule.RuleModule;
3
3
  export default _default;
4
+ //# sourceMappingURL=no-uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-uuid.d.ts","sourceRoot":"","sources":["../src/no-uuid.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;;AAwDnC,wBA2CqB"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ // no-uuid.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const UUID_FOUND = 'UUID_FOUND';
5
+ const UUIDS_FOUND = 'UUIDS_FOUND';
6
+ const uuidRegex = /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/gmu;
7
+ function checkForUuid(value, context, node, loc) {
8
+ const matches = value.match(uuidRegex);
9
+ if (matches === null) {
10
+ return;
11
+ }
12
+ if (matches.length === 1) {
13
+ if (node !== undefined) {
14
+ context.report({
15
+ messageId: UUID_FOUND,
16
+ data: {
17
+ uuid: matches[0] ?? '',
18
+ },
19
+ node,
20
+ });
21
+ }
22
+ else if (loc !== undefined) {
23
+ context.report({
24
+ messageId: UUID_FOUND,
25
+ data: {
26
+ uuid: matches[0] ?? '',
27
+ },
28
+ loc: {
29
+ start: loc.start,
30
+ end: loc.end,
31
+ },
32
+ });
33
+ }
34
+ }
35
+ else if (matches.length > 1) {
36
+ if (node !== undefined) {
37
+ context.report({
38
+ messageId: UUIDS_FOUND,
39
+ data: {
40
+ uuids: matches.join(', '),
41
+ },
42
+ node,
43
+ });
44
+ }
45
+ else if (loc !== undefined) {
46
+ context.report({
47
+ messageId: UUIDS_FOUND,
48
+ data: {
49
+ uuids: matches.join(', '),
50
+ },
51
+ loc: {
52
+ start: loc.start,
53
+ end: loc.end,
54
+ },
55
+ });
56
+ }
57
+ }
58
+ }
59
+ exports.default = {
60
+ meta: {
61
+ type: 'problem',
62
+ docs: {
63
+ description: 'Detects if a string literal contains a UUID',
64
+ url: 'https://github.com/checkdigit/eslint-plugin',
65
+ },
66
+ messages: {
67
+ [UUID_FOUND]: `UUID found: "{{ uuid }}"`,
68
+ [UUIDS_FOUND]: `Multiple UUIDs found: "{{ uuids }}"`,
69
+ },
70
+ },
71
+ create(context) {
72
+ const sourceCode = context.getSourceCode();
73
+ const comments = sourceCode.getAllComments();
74
+ comments.forEach((comment) => {
75
+ if (comment.loc !== undefined && comment.loc !== null) {
76
+ checkForUuid(comment.value, context, undefined, comment.loc);
77
+ }
78
+ });
79
+ return {
80
+ Literal(node) {
81
+ if (node.value === undefined) {
82
+ return;
83
+ }
84
+ if (typeof node.value !== 'string') {
85
+ return;
86
+ }
87
+ const value = `${node.value}`;
88
+ checkForUuid(value, context, node);
89
+ },
90
+ TemplateElement(node) {
91
+ if (!node.value) {
92
+ return;
93
+ }
94
+ if (typeof node.value.cooked !== 'string') {
95
+ return;
96
+ }
97
+ checkForUuid(node.value.cooked, context, node);
98
+ },
99
+ };
100
+ },
101
+ };
102
+ //# sourceMappingURL=no-uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-uuid.js","source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C,IAAI,CAAC,KAAK,EAAE;oBACf,OAAO;iBACR;gBACD,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE;oBACzC,OAAO;iBACR;gBACD,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACjD,CAAC;SACF,CAAC;IACJ,CAAC;CACiB,CAAC","sourcesContent":["// no-uuid.ts\n\n/*\n * Copyright (c) 2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport type { Node, SourceLocation } from 'estree';\nimport type { Rule } from 'eslint';\n\nconst UUID_FOUND = 'UUID_FOUND';\nconst UUIDS_FOUND = 'UUIDS_FOUND';\nconst uuidRegex = /[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}/gmu;\n\nfunction checkForUuid(value: string, context: Rule.RuleContext, node?: Node, loc?: SourceLocation) {\n const matches = value.match(uuidRegex);\n if (matches === null) {\n return;\n }\n if (matches.length === 1) {\n if (node !== undefined) {\n context.report({\n messageId: UUID_FOUND,\n data: {\n uuid: matches[0] ?? '',\n },\n node,\n });\n } else if (loc !== undefined) {\n context.report({\n messageId: UUID_FOUND,\n data: {\n uuid: matches[0] ?? '',\n },\n loc: {\n start: loc.start,\n end: loc.end,\n },\n });\n }\n } else if (matches.length > 1) {\n if (node !== undefined) {\n context.report({\n messageId: UUIDS_FOUND,\n data: {\n uuids: matches.join(', '),\n },\n node,\n });\n } else if (loc !== undefined) {\n context.report({\n messageId: UUIDS_FOUND,\n data: {\n uuids: matches.join(', '),\n },\n loc: {\n start: loc.start,\n end: loc.end,\n },\n });\n }\n }\n}\n\nexport default {\n meta: {\n type: 'problem',\n docs: {\n description: 'Detects if a string literal contains a UUID',\n url: 'https://github.com/checkdigit/eslint-plugin',\n },\n messages: {\n [UUID_FOUND]: `UUID found: \"{{ uuid }}\"`,\n [UUIDS_FOUND]: `Multiple UUIDs found: \"{{ uuids }}\"`,\n },\n },\n create(context) {\n const sourceCode = context.getSourceCode();\n const comments = sourceCode.getAllComments();\n\n comments.forEach((comment) => {\n if (comment.loc !== undefined && comment.loc !== null) {\n checkForUuid(comment.value, context, undefined, comment.loc);\n }\n });\n return {\n Literal(node) {\n if (node.value === undefined) {\n return;\n }\n if (typeof node.value !== 'string') {\n return;\n }\n const value = `${node.value}`;\n checkForUuid(value, context, node);\n },\n TemplateElement(node) {\n if (!node.value) {\n return;\n }\n if (typeof node.value.cooked !== 'string') {\n return;\n }\n checkForUuid(node.value.cooked, context, node);\n },\n };\n },\n} as Rule.RuleModule;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=no-uuid.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-uuid.spec.d.ts","sourceRoot":"","sources":["../src/no-uuid.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ // no-uuid.spec.ts
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ /*
8
+ * Copyright (c) 2022 Check Digit, LLC
9
+ *
10
+ * This code is licensed under the MIT license (see LICENSE.txt for details).
11
+ */
12
+ const eslint_1 = require("eslint");
13
+ const no_uuid_1 = __importDefault(require("./no-uuid"));
14
+ const UUID_FOUND = 'UUID_FOUND';
15
+ const UUIDS_FOUND = 'UUIDS_FOUND';
16
+ const UUID_FOUND_MSG = {
17
+ messageId: UUID_FOUND,
18
+ };
19
+ const UUIDS_FOUND_MSG = {
20
+ messageId: UUIDS_FOUND,
21
+ };
22
+ const STRING_TEST = `
23
+ const NOT_A_UUID = "I'm not a uuid, I think";
24
+ `;
25
+ // eslint-disable-next-line no-template-curly-in-string
26
+ const TEMPLATE_TEST = "const NOT_A_UUID = `A template that isn't a uuid. ${1+1} = 2`";
27
+ const STRING_WITH_NON_UUID = `
28
+ const foo = 'C73BCDCC-2669-4Bf6-XXX-81d3-E4AE73FB11FD';
29
+ `;
30
+ const CONTAINS_UUID_IN_STRING = `
31
+ const foo = 'c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd';
32
+ `;
33
+ const CONTAINS_MULTIPLE_UUIDS_IN_STRING = `
34
+ const foo = 'c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd aa 123e4567-e89b-12d3-a456-426655440000';
35
+ `;
36
+ const CONTAINS_UUID_IN_COMMENT = `
37
+ // this test will be using this uuid -> C73BCDCC-2669-4Bf6-81d3-E4AE73FB11FD
38
+ const foo = 'nothing wrong here';
39
+ `;
40
+ const CONTAINS_MULTIPLE_UUIDS_IN_COMMENT = `
41
+ // this test will be using these uuids -> c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd and 123e4567-e89b-12d3-a456-426655440000
42
+ const foo = 'nothing wrong here';
43
+ `;
44
+ describe('no-uuid', () => {
45
+ const ruleTester = new eslint_1.RuleTester({ parserOptions: { ecmaVersion: 2020 } });
46
+ ruleTester.run('no-uuid', no_uuid_1.default, {
47
+ valid: [
48
+ {
49
+ code: STRING_TEST,
50
+ },
51
+ {
52
+ code: TEMPLATE_TEST,
53
+ },
54
+ {
55
+ code: STRING_WITH_NON_UUID,
56
+ },
57
+ ],
58
+ invalid: [
59
+ {
60
+ code: CONTAINS_UUID_IN_STRING,
61
+ errors: [UUID_FOUND_MSG],
62
+ },
63
+ {
64
+ code: CONTAINS_MULTIPLE_UUIDS_IN_STRING,
65
+ errors: [UUIDS_FOUND_MSG],
66
+ },
67
+ {
68
+ code: CONTAINS_UUID_IN_COMMENT,
69
+ errors: [UUID_FOUND_MSG],
70
+ },
71
+ {
72
+ code: CONTAINS_MULTIPLE_UUIDS_IN_COMMENT,
73
+ errors: [UUIDS_FOUND_MSG],
74
+ },
75
+ ],
76
+ });
77
+ });
78
+ //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AAM,EAAE,CAAC,cAAc,CAAC;aACzB;YACD;gBACE,IAAI,EAAE,kCAAkC;gBACxC,MAAM,EAAE,CAAC,eAAe,CAAC;aAC1B;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// no-uuid.spec.ts\n\n/*\n * Copyright (c) 2022 Check Digit, LLC\n *\n * This code is licensed under the MIT license (see LICENSE.txt for details).\n */\n\nimport { RuleTester } from 'eslint';\n\nimport rule from './no-uuid';\n\nconst UUID_FOUND = 'UUID_FOUND';\nconst UUIDS_FOUND = 'UUIDS_FOUND';\n\nconst UUID_FOUND_MSG = {\n messageId: UUID_FOUND,\n};\n\nconst UUIDS_FOUND_MSG = {\n messageId: UUIDS_FOUND,\n};\n\nconst STRING_TEST = `\nconst NOT_A_UUID = \"I'm not a uuid, I think\";\n`;\n\n// eslint-disable-next-line no-template-curly-in-string\nconst TEMPLATE_TEST = \"const NOT_A_UUID = `A template that isn't a uuid. ${1+1} = 2`\";\n\nconst STRING_WITH_NON_UUID = `\n const foo = 'C73BCDCC-2669-4Bf6-XXX-81d3-E4AE73FB11FD';\n`;\n\nconst CONTAINS_UUID_IN_STRING = `\nconst foo = 'c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd';\n`;\n\nconst CONTAINS_MULTIPLE_UUIDS_IN_STRING = `\nconst foo = 'c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd aa 123e4567-e89b-12d3-a456-426655440000';\n`;\n\nconst CONTAINS_UUID_IN_COMMENT = `\n// this test will be using this uuid -> C73BCDCC-2669-4Bf6-81d3-E4AE73FB11FD\nconst foo = 'nothing wrong here';\n`;\n\nconst CONTAINS_MULTIPLE_UUIDS_IN_COMMENT = `\n// this test will be using these uuids -> c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd and 123e4567-e89b-12d3-a456-426655440000\nconst foo = 'nothing wrong here';\n`;\n\ndescribe('no-uuid', () => {\n const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2020 } });\n ruleTester.run('no-uuid', rule, {\n valid: [\n {\n code: STRING_TEST,\n },\n {\n code: TEMPLATE_TEST,\n },\n {\n code: STRING_WITH_NON_UUID,\n },\n ],\n invalid: [\n {\n code: CONTAINS_UUID_IN_STRING,\n errors: [UUID_FOUND_MSG],\n },\n {\n code: CONTAINS_MULTIPLE_UUIDS_IN_STRING,\n errors: [UUIDS_FOUND_MSG],\n },\n {\n code: CONTAINS_UUID_IN_COMMENT,\n errors: [UUID_FOUND_MSG],\n },\n {\n code: CONTAINS_MULTIPLE_UUIDS_IN_COMMENT,\n errors: [UUIDS_FOUND_MSG],\n },\n ],\n });\n});\n"]}