@checkdigit/eslint-plugin 6.8.0 → 6.9.0-PR.89-6297
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/README.md +1 -0
- package/dist-cjs/index.cjs +529 -562
- package/dist-cjs/metafile.json +29 -5
- package/dist-mjs/index.mjs +5 -1
- package/dist-mjs/no-random-v4-uuid.mjs +60 -0
- package/dist-types/index.d.ts +3 -0
- package/dist-types/no-random-v4-uuid.d.ts +4 -0
- package/package.json +1 -92
- package/src/index.ts +4 -0
- package/src/no-random-v4-uuid.ts +85 -0
package/dist-cjs/metafile.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"package.json": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 2898,
|
|
5
5
|
"imports": [],
|
|
6
6
|
"format": "esm",
|
|
7
7
|
"with": {
|
|
@@ -12298,6 +12298,22 @@
|
|
|
12298
12298
|
"imports": [],
|
|
12299
12299
|
"format": "esm"
|
|
12300
12300
|
},
|
|
12301
|
+
"src/no-random-v4-uuid.ts": {
|
|
12302
|
+
"bytes": 2647,
|
|
12303
|
+
"imports": [
|
|
12304
|
+
{
|
|
12305
|
+
"path": "node_modules/@typescript-eslint/utils/dist/index.js",
|
|
12306
|
+
"kind": "import-statement",
|
|
12307
|
+
"original": "@typescript-eslint/utils"
|
|
12308
|
+
},
|
|
12309
|
+
{
|
|
12310
|
+
"path": "src/get-documentation-url.ts",
|
|
12311
|
+
"kind": "import-statement",
|
|
12312
|
+
"original": "./get-documentation-url"
|
|
12313
|
+
}
|
|
12314
|
+
],
|
|
12315
|
+
"format": "esm"
|
|
12316
|
+
},
|
|
12301
12317
|
"src/no-test-import.ts": {
|
|
12302
12318
|
"bytes": 1874,
|
|
12303
12319
|
"imports": [],
|
|
@@ -12334,7 +12350,7 @@
|
|
|
12334
12350
|
"format": "esm"
|
|
12335
12351
|
},
|
|
12336
12352
|
"src/index.ts": {
|
|
12337
|
-
"bytes":
|
|
12353
|
+
"bytes": 3701,
|
|
12338
12354
|
"imports": [
|
|
12339
12355
|
{
|
|
12340
12356
|
"path": "src/invalid-json-stringify.ts",
|
|
@@ -12371,6 +12387,11 @@
|
|
|
12371
12387
|
"kind": "import-statement",
|
|
12372
12388
|
"original": "./no-card-numbers"
|
|
12373
12389
|
},
|
|
12390
|
+
{
|
|
12391
|
+
"path": "src/no-random-v4-uuid.ts",
|
|
12392
|
+
"kind": "import-statement",
|
|
12393
|
+
"original": "./no-random-v4-uuid"
|
|
12394
|
+
},
|
|
12374
12395
|
{
|
|
12375
12396
|
"path": "src/no-test-import.ts",
|
|
12376
12397
|
"kind": "import-statement",
|
|
@@ -15175,10 +15196,10 @@
|
|
|
15175
15196
|
"bytesInOutput": 2215
|
|
15176
15197
|
},
|
|
15177
15198
|
"src/index.ts": {
|
|
15178
|
-
"bytesInOutput":
|
|
15199
|
+
"bytesInOutput": 2456
|
|
15179
15200
|
},
|
|
15180
15201
|
"package.json": {
|
|
15181
|
-
"bytesInOutput":
|
|
15202
|
+
"bytesInOutput": 2998
|
|
15182
15203
|
},
|
|
15183
15204
|
"src/get-documentation-url.ts": {
|
|
15184
15205
|
"bytesInOutput": 146
|
|
@@ -15207,6 +15228,9 @@
|
|
|
15207
15228
|
"src/no-card-numbers.ts": {
|
|
15208
15229
|
"bytesInOutput": 3356
|
|
15209
15230
|
},
|
|
15231
|
+
"src/no-random-v4-uuid.ts": {
|
|
15232
|
+
"bytesInOutput": 2051
|
|
15233
|
+
},
|
|
15210
15234
|
"src/no-test-import.ts": {
|
|
15211
15235
|
"bytesInOutput": 1458
|
|
15212
15236
|
},
|
|
@@ -15229,7 +15253,7 @@
|
|
|
15229
15253
|
"bytesInOutput": 3362
|
|
15230
15254
|
}
|
|
15231
15255
|
},
|
|
15232
|
-
"bytes":
|
|
15256
|
+
"bytes": 4236477
|
|
15233
15257
|
}
|
|
15234
15258
|
}
|
|
15235
15259
|
}
|
package/dist-mjs/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import requireTypeOutOfTypeOnlyImports, {
|
|
|
10
10
|
} from "./require-type-out-of-type-only-imports.mjs";
|
|
11
11
|
import filePathComment from "./file-path-comment.mjs";
|
|
12
12
|
import noCardNumbers from "./no-card-numbers.mjs";
|
|
13
|
+
import noRandomV4UUID from "./no-random-v4-uuid.mjs";
|
|
13
14
|
import noTestImport from "./no-test-import.mjs";
|
|
14
15
|
import noUuid from "./no-uuid.mjs";
|
|
15
16
|
import noWallabyComment from "./no-wallaby-comment.mjs";
|
|
@@ -21,6 +22,7 @@ var src_default = {
|
|
|
21
22
|
rules: {
|
|
22
23
|
"file-path-comment": filePathComment,
|
|
23
24
|
"no-card-numbers": noCardNumbers,
|
|
25
|
+
"no-random-v4-uuid": noRandomV4UUID,
|
|
24
26
|
"no-uuid": noUuid,
|
|
25
27
|
"require-strict-assert": requireStrictAssert,
|
|
26
28
|
"no-test-import": noTestImport,
|
|
@@ -39,6 +41,7 @@ var src_default = {
|
|
|
39
41
|
rules: {
|
|
40
42
|
"@checkdigit/no-card-numbers": "error",
|
|
41
43
|
"@checkdigit/file-path-comment": "error",
|
|
44
|
+
"@checkdigit/no-random-v4-uuid": "error",
|
|
42
45
|
"@checkdigit/no-uuid": "error",
|
|
43
46
|
"@checkdigit/require-strict-assert": "error",
|
|
44
47
|
"@checkdigit/no-wallaby-comment": "error",
|
|
@@ -57,6 +60,7 @@ var src_default = {
|
|
|
57
60
|
rules: {
|
|
58
61
|
"@checkdigit/no-card-numbers": "error",
|
|
59
62
|
"@checkdigit/file-path-comment": "off",
|
|
63
|
+
"@checkdigit/no-random-v4-uuid": "error",
|
|
60
64
|
"@checkdigit/no-uuid": "error",
|
|
61
65
|
"@checkdigit/require-strict-assert": "error",
|
|
62
66
|
"@checkdigit/no-wallaby-comment": "off",
|
|
@@ -73,4 +77,4 @@ var src_default = {
|
|
|
73
77
|
export {
|
|
74
78
|
src_default as default
|
|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FBQSxJQUNGO0FBQUEsRUFDRjtBQUNGOyIsCiAgIm5hbWVzIjogW10KfQo=
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/no-random-v4-uuid.ts
|
|
2
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
|
+
import getDocumentationUrl from "./get-documentation-url.mjs";
|
|
4
|
+
var ruleId = "no-random-v4-uuid";
|
|
5
|
+
var NO_RANDOM_V4_UUID = "NO_RANDOM_V4_UUID";
|
|
6
|
+
var createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
|
|
7
|
+
var processImportDeclaration = (node, uuid4Alias, uuidDefaultAlias) => {
|
|
8
|
+
node.specifiers.forEach((specifier) => {
|
|
9
|
+
switch (specifier.type) {
|
|
10
|
+
case AST_NODE_TYPES.ImportSpecifier:
|
|
11
|
+
if (specifier.imported.name === "v4") {
|
|
12
|
+
uuid4Alias.current = specifier.local.name;
|
|
13
|
+
}
|
|
14
|
+
break;
|
|
15
|
+
case AST_NODE_TYPES.ImportDefaultSpecifier:
|
|
16
|
+
uuidDefaultAlias.current = specifier.local.name;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var isUuid4Call = (node, uuid4Alias, uuidDefaultAlias) => node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === uuid4Alias || node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.object.name === uuidDefaultAlias && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "v4";
|
|
22
|
+
var rule = createRule({
|
|
23
|
+
name: ruleId,
|
|
24
|
+
meta: {
|
|
25
|
+
type: "problem",
|
|
26
|
+
docs: {
|
|
27
|
+
description: "Disallow the use of `uuid.v4` for generating random v4 UUIDs"
|
|
28
|
+
},
|
|
29
|
+
schema: [],
|
|
30
|
+
messages: {
|
|
31
|
+
[NO_RANDOM_V4_UUID]: "Avoid using `uuid.v4` for generating random v4 UUIDs."
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
defaultOptions: [],
|
|
35
|
+
create(context) {
|
|
36
|
+
const uuid4Alias = { current: null };
|
|
37
|
+
const uuidDefaultAlias = { current: null };
|
|
38
|
+
return {
|
|
39
|
+
ImportDeclaration(node) {
|
|
40
|
+
if (node.source.value === "uuid") {
|
|
41
|
+
processImportDeclaration(node, uuid4Alias, uuidDefaultAlias);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
CallExpression(node) {
|
|
45
|
+
if (isUuid4Call(node, uuid4Alias.current, uuidDefaultAlias.current)) {
|
|
46
|
+
context.report({
|
|
47
|
+
node,
|
|
48
|
+
messageId: NO_RANDOM_V4_UUID
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var no_random_v4_uuid_default = rule;
|
|
56
|
+
export {
|
|
57
|
+
no_random_v4_uuid_default as default,
|
|
58
|
+
ruleId
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL25vLXJhbmRvbS12NC11dWlkLnRzIl0sCiAgIm1hcHBpbmdzIjogIjtBQVFBLFNBQVMsZ0JBQWdCLG1CQUE2QjtBQUN0RCxPQUFPLHlCQUF5QjtBQUV6QixJQUFNLFNBQVM7QUFDdEIsSUFBTSxvQkFBb0I7QUFFMUIsSUFBTSxhQUFhLFlBQVksWUFBWSxDQUFDLFNBQVMsb0JBQW9CLElBQUksQ0FBQztBQUc5RSxJQUFNLDJCQUEyQixDQUMvQixNQUNBLFlBQ0EscUJBQ0c7QUFDSCxPQUFLLFdBQVcsUUFBUSxDQUFDLGNBQWM7QUFDckMsWUFBUSxVQUFVLE1BQU07QUFBQSxNQUN0QixLQUFLLGVBQWU7QUFDbEIsWUFBSSxVQUFVLFN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NQUNBLGVBQWUsTUFBK0I7QUFDNUMsWUFBSSxZQUFZLE1BQU0sV0FBVyxTQUFTLGlCQUFpQixPQUFPLEdBQUc7QUFDbkUsa0JBQVEsT0FBTztBQUFBLFlBQ2I7QUFBQSxZQUNBLFdBQVc7QUFBQSxVQUNiLENBQUM7QUFBQSxRQUNIO0FBQUEsTUFDRjtBQUFBLElBQ0Y7QUFBQSxFQUNGO0FBQ0YsQ0FBQztBQUVELElBQU8sNEJBQVE7IiwKICAibmFtZXMiOiBbXQp9Cg==
|
package/dist-types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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
|
+
'no-random-v4-uuid': import("@typescript-eslint/utils/ts-eslint").RuleModule<"NO_RANDOM_V4_UUID", never[], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
6
|
'no-uuid': import("eslint").Rule.RuleModule;
|
|
6
7
|
'require-strict-assert': import("eslint").Rule.RuleModule;
|
|
7
8
|
'no-test-import': import("eslint").Rule.RuleModule;
|
|
@@ -20,6 +21,7 @@ declare const _default: {
|
|
|
20
21
|
rules: {
|
|
21
22
|
'@checkdigit/no-card-numbers': string;
|
|
22
23
|
'@checkdigit/file-path-comment': string;
|
|
24
|
+
'@checkdigit/no-random-v4-uuid': string;
|
|
23
25
|
'@checkdigit/no-uuid': string;
|
|
24
26
|
'@checkdigit/require-strict-assert': string;
|
|
25
27
|
'@checkdigit/no-wallaby-comment': string;
|
|
@@ -38,6 +40,7 @@ declare const _default: {
|
|
|
38
40
|
rules: {
|
|
39
41
|
'@checkdigit/no-card-numbers': string;
|
|
40
42
|
'@checkdigit/file-path-comment': string;
|
|
43
|
+
'@checkdigit/no-random-v4-uuid': string;
|
|
41
44
|
'@checkdigit/no-uuid': string;
|
|
42
45
|
'@checkdigit/require-strict-assert': string;
|
|
43
46
|
'@checkdigit/no-wallaby-comment': string;
|
package/package.json
CHANGED
|
@@ -1,92 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@checkdigit/eslint-plugin",
|
|
3
|
-
"version": "6.8.0",
|
|
4
|
-
"description": "Check Digit eslint plugins",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"eslint",
|
|
7
|
-
"eslintplugin"
|
|
8
|
-
],
|
|
9
|
-
"homepage": "https://github.com/checkdigit/eslint-plugin#readme",
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/checkdigit/eslint-plugin/issues"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/checkdigit/eslint-plugin"
|
|
16
|
-
},
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"author": "Check Digit, LLC",
|
|
19
|
-
"sideEffects": false,
|
|
20
|
-
"type": "module",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": {
|
|
23
|
-
"types": "./dist-types/index.d.ts",
|
|
24
|
-
"require": "./dist-cjs/index.cjs",
|
|
25
|
-
"import": "./dist-mjs/index.mjs",
|
|
26
|
-
"default": "./dist-mjs/index.mjs"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
"src",
|
|
31
|
-
"dist-types",
|
|
32
|
-
"dist-cjs",
|
|
33
|
-
"dist-mjs",
|
|
34
|
-
"!src/**/*.test.ts",
|
|
35
|
-
"!src/**/*.spec.ts",
|
|
36
|
-
"!dist-types/**/*.test.d.ts",
|
|
37
|
-
"!dist-types/**/*.spec.d.ts",
|
|
38
|
-
"!dist-cjs/**/*.test.cjs",
|
|
39
|
-
"!dist-cjs/**/*.spec.cjs",
|
|
40
|
-
"!dist-mjs/**/*.test.mjs",
|
|
41
|
-
"!dist-mjs/**/*.spec.mjs",
|
|
42
|
-
"SECURITY.md"
|
|
43
|
-
],
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build:dist-cjs": "rimraf dist-cjs && npx builder --type=commonjs --sourceMap --entryPoint=index.ts --outDir=dist-cjs --outFile=index.cjs --external=espree && echo \"module.exports = module.exports.default;\" >> dist-cjs/index.cjs && node dist-cjs/index.cjs",
|
|
46
|
-
"build:dist-mjs": "rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs",
|
|
47
|
-
"build:dist-types": "rimraf dist-types && npx builder --type=types --outDir=dist-types",
|
|
48
|
-
"ci:compile": "tsc --noEmit",
|
|
49
|
-
"ci:coverage": "NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true",
|
|
50
|
-
"ci:lint": "npm run lint",
|
|
51
|
-
"ci:style": "npm run prettier",
|
|
52
|
-
"ci:test": "NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false",
|
|
53
|
-
"lint": "eslint --max-warnings 0 --ignore-path .gitignore .",
|
|
54
|
-
"lint:fix": "eslint --ignore-path .gitignore . --fix",
|
|
55
|
-
"prepublishOnly": "npm run build:dist-types && npm run build:dist-cjs && npm run build:dist-mjs",
|
|
56
|
-
"prettier": "prettier --ignore-path .gitignore --list-different .",
|
|
57
|
-
"prettier:fix": "prettier --ignore-path .gitignore --write .",
|
|
58
|
-
"test": "npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"
|
|
59
|
-
},
|
|
60
|
-
"prettier": "@checkdigit/prettier-config",
|
|
61
|
-
"jest": {
|
|
62
|
-
"preset": "@checkdigit/jest-config"
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"@typescript-eslint/type-utils": "7.18.0",
|
|
66
|
-
"@typescript-eslint/utils": "7.18.0",
|
|
67
|
-
"ts-api-utils": "^1.3.0"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@checkdigit/jest-config": "^6.0.2",
|
|
71
|
-
"@checkdigit/prettier-config": "^5.5.1",
|
|
72
|
-
"@checkdigit/typescript-config": "6.0.0",
|
|
73
|
-
"@types/eslint": "8.56.10",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
75
|
-
"@typescript-eslint/parser": "7.18.0",
|
|
76
|
-
"@typescript-eslint/rule-tester": "7.18.0",
|
|
77
|
-
"eslint-config-prettier": "^9.1.0",
|
|
78
|
-
"eslint-plugin-eslint-plugin": "^6.2.0",
|
|
79
|
-
"eslint-plugin-import": "^2.31.0",
|
|
80
|
-
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
81
|
-
"eslint-plugin-no-secrets": "^1.0.2",
|
|
82
|
-
"eslint-plugin-node": "^11.1.0",
|
|
83
|
-
"eslint-plugin-sonarjs": "0.24.0",
|
|
84
|
-
"http-status-codes": "^2.3.0"
|
|
85
|
-
},
|
|
86
|
-
"peerDependencies": {
|
|
87
|
-
"eslint": ">=8 <9"
|
|
88
|
-
},
|
|
89
|
-
"engines": {
|
|
90
|
-
"node": ">=20.14"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
1
|
+
{"name":"@checkdigit/eslint-plugin","version":"6.9.0-PR.89-6297","description":"Check Digit eslint plugins","keywords":["eslint","eslintplugin"],"homepage":"https://github.com/checkdigit/eslint-plugin#readme","bugs":{"url":"https://github.com/checkdigit/eslint-plugin/issues"},"repository":{"type":"git","url":"https://github.com/checkdigit/eslint-plugin"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","require":"./dist-cjs/index.cjs","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-cjs","dist-mjs","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-cjs/**/*.test.cjs","!dist-cjs/**/*.spec.cjs","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-cjs":"rimraf dist-cjs && npx builder --type=commonjs --sourceMap --entryPoint=index.ts --outDir=dist-cjs --outFile=index.cjs --external=espree && echo \"module.exports = module.exports.default;\" >> dist-cjs/index.cjs && node dist-cjs/index.cjs","build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","lint":"eslint --max-warnings 0 --ignore-path .gitignore .","lint:fix":"eslint --ignore-path .gitignore . --fix","prepublishOnly":"npm run build:dist-types && npm run build:dist-cjs && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","jest":{"preset":"@checkdigit/jest-config"},"dependencies":{"@typescript-eslint/type-utils":"7.18.0","@typescript-eslint/utils":"7.18.0","ts-api-utils":"^1.3.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^5.5.1","@checkdigit/typescript-config":"6.0.0","@types/eslint":"8.56.10","@typescript-eslint/eslint-plugin":"7.18.0","@typescript-eslint/parser":"7.18.0","@typescript-eslint/rule-tester":"7.18.0","eslint-config-prettier":"^9.1.0","eslint-plugin-eslint-plugin":"^6.2.0","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^1.0.2","eslint-plugin-node":"^11.1.0","eslint-plugin-sonarjs":"0.24.0","http-status-codes":"^2.3.0"},"peerDependencies":{"eslint":">=8 <9"},"engines":{"node":">=20.14"}}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import requireTypeOutOfTypeOnlyImports, {
|
|
|
17
17
|
} from './require-type-out-of-type-only-imports';
|
|
18
18
|
import filePathComment from './file-path-comment';
|
|
19
19
|
import noCardNumbers from './no-card-numbers';
|
|
20
|
+
import noRandomV4UUID from './no-random-v4-uuid';
|
|
20
21
|
import noTestImport from './no-test-import';
|
|
21
22
|
import noUuid from './no-uuid';
|
|
22
23
|
import noWallabyComment from './no-wallaby-comment';
|
|
@@ -29,6 +30,7 @@ export default {
|
|
|
29
30
|
rules: {
|
|
30
31
|
'file-path-comment': filePathComment,
|
|
31
32
|
'no-card-numbers': noCardNumbers,
|
|
33
|
+
'no-random-v4-uuid': noRandomV4UUID,
|
|
32
34
|
'no-uuid': noUuid,
|
|
33
35
|
'require-strict-assert': requireStrictAssert,
|
|
34
36
|
'no-test-import': noTestImport,
|
|
@@ -47,6 +49,7 @@ export default {
|
|
|
47
49
|
rules: {
|
|
48
50
|
'@checkdigit/no-card-numbers': 'error',
|
|
49
51
|
'@checkdigit/file-path-comment': 'error',
|
|
52
|
+
'@checkdigit/no-random-v4-uuid': 'error',
|
|
50
53
|
'@checkdigit/no-uuid': 'error',
|
|
51
54
|
'@checkdigit/require-strict-assert': 'error',
|
|
52
55
|
'@checkdigit/no-wallaby-comment': 'error',
|
|
@@ -65,6 +68,7 @@ export default {
|
|
|
65
68
|
rules: {
|
|
66
69
|
'@checkdigit/no-card-numbers': 'error',
|
|
67
70
|
'@checkdigit/file-path-comment': 'off',
|
|
71
|
+
'@checkdigit/no-random-v4-uuid': 'error',
|
|
68
72
|
'@checkdigit/no-uuid': 'error',
|
|
69
73
|
'@checkdigit/require-strict-assert': 'error',
|
|
70
74
|
'@checkdigit/no-wallaby-comment': 'off',
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// no-random-v4-uuid.ts
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2022-2024 Check Digit, LLC
|
|
5
|
+
*
|
|
6
|
+
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { AST_NODE_TYPES, ESLintUtils, TSESTree } from '@typescript-eslint/utils';
|
|
10
|
+
import getDocumentationUrl from './get-documentation-url';
|
|
11
|
+
|
|
12
|
+
export const ruleId = 'no-random-v4-uuid';
|
|
13
|
+
const NO_RANDOM_V4_UUID = 'NO_RANDOM_V4_UUID';
|
|
14
|
+
|
|
15
|
+
const createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
|
|
16
|
+
|
|
17
|
+
// process the import declaration to get the alias for uuid.v4 and uuid.
|
|
18
|
+
const processImportDeclaration = (
|
|
19
|
+
node: TSESTree.ImportDeclaration,
|
|
20
|
+
uuid4Alias: { current: string | null },
|
|
21
|
+
uuidDefaultAlias: { current: string | null },
|
|
22
|
+
) => {
|
|
23
|
+
node.specifiers.forEach((specifier) => {
|
|
24
|
+
switch (specifier.type) {
|
|
25
|
+
case AST_NODE_TYPES.ImportSpecifier:
|
|
26
|
+
if (specifier.imported.name === 'v4') {
|
|
27
|
+
uuid4Alias.current = specifier.local.name;
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case AST_NODE_TYPES.ImportDefaultSpecifier:
|
|
31
|
+
uuidDefaultAlias.current = specifier.local.name;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// checks if the function call is either directly using the alias for uuid.v4 or using uuid.v4 as a member expression.
|
|
38
|
+
const isUuid4Call = (
|
|
39
|
+
node: TSESTree.CallExpression,
|
|
40
|
+
uuid4Alias: string | null,
|
|
41
|
+
uuidDefaultAlias: string | null,
|
|
42
|
+
): boolean =>
|
|
43
|
+
(node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === uuid4Alias) ||
|
|
44
|
+
(node.callee.type === AST_NODE_TYPES.MemberExpression &&
|
|
45
|
+
node.callee.object.type === AST_NODE_TYPES.Identifier &&
|
|
46
|
+
node.callee.object.name === uuidDefaultAlias &&
|
|
47
|
+
node.callee.property.type === AST_NODE_TYPES.Identifier &&
|
|
48
|
+
node.callee.property.name === 'v4');
|
|
49
|
+
|
|
50
|
+
const rule = createRule({
|
|
51
|
+
name: ruleId,
|
|
52
|
+
meta: {
|
|
53
|
+
type: 'problem',
|
|
54
|
+
docs: {
|
|
55
|
+
description: 'Disallow the use of `uuid.v4` for generating random v4 UUIDs',
|
|
56
|
+
},
|
|
57
|
+
schema: [],
|
|
58
|
+
messages: {
|
|
59
|
+
[NO_RANDOM_V4_UUID]: 'Avoid using `uuid.v4` for generating random v4 UUIDs.',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
defaultOptions: [],
|
|
63
|
+
create(context) {
|
|
64
|
+
const uuid4Alias = { current: null };
|
|
65
|
+
const uuidDefaultAlias = { current: null };
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
ImportDeclaration(node: TSESTree.ImportDeclaration) {
|
|
69
|
+
if (node.source.value === 'uuid') {
|
|
70
|
+
processImportDeclaration(node, uuid4Alias, uuidDefaultAlias);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
CallExpression(node: TSESTree.CallExpression) {
|
|
74
|
+
if (isUuid4Call(node, uuid4Alias.current, uuidDefaultAlias.current)) {
|
|
75
|
+
context.report({
|
|
76
|
+
node,
|
|
77
|
+
messageId: NO_RANDOM_V4_UUID,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export default rule;
|