@checkdigit/eslint-plugin 6.7.0-PR.79-33df → 6.7.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/README.md +0 -1
- package/dist-cjs/index.cjs +140 -55
- package/dist-cjs/metafile.json +30 -25
- package/dist-mjs/index.mjs +8 -7
- package/dist-mjs/require-type-out-of-type-only-imports.mjs +48 -0
- package/dist-types/index.d.ts +2 -3
- package/dist-types/require-type-out-of-type-only-imports.d.ts +4 -0
- package/package.json +92 -1
- package/src/index.ts +5 -4
- package/src/library/format.ts +1 -1
- package/src/library/tree.ts +1 -1
- package/src/library/ts-tree.ts +1 -1
- package/src/library/variable.ts +1 -1
- package/src/require-type-out-of-type-only-imports.ts +63 -0
- package/dist-mjs/no-enum.mjs +0 -52
- package/dist-types/no-enum.d.ts +0 -4
- package/src/no-enum.ts +0 -68
package/dist-cjs/metafile.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"package.json": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 3348,
|
|
5
5
|
"imports": [],
|
|
6
6
|
"format": "esm",
|
|
7
7
|
"with": {
|
|
@@ -12205,7 +12205,7 @@
|
|
|
12205
12205
|
"format": "cjs"
|
|
12206
12206
|
},
|
|
12207
12207
|
"src/library/ts-tree.ts": {
|
|
12208
|
-
"bytes":
|
|
12208
|
+
"bytes": 2883,
|
|
12209
12209
|
"imports": [
|
|
12210
12210
|
{
|
|
12211
12211
|
"path": "node_modules/@typescript-eslint/utils/dist/index.js",
|
|
@@ -12246,6 +12246,22 @@
|
|
|
12246
12246
|
],
|
|
12247
12247
|
"format": "esm"
|
|
12248
12248
|
},
|
|
12249
|
+
"src/require-type-out-of-type-only-imports.ts": {
|
|
12250
|
+
"bytes": 1901,
|
|
12251
|
+
"imports": [
|
|
12252
|
+
{
|
|
12253
|
+
"path": "node_modules/@typescript-eslint/utils/dist/index.js",
|
|
12254
|
+
"kind": "import-statement",
|
|
12255
|
+
"original": "@typescript-eslint/utils"
|
|
12256
|
+
},
|
|
12257
|
+
{
|
|
12258
|
+
"path": "src/get-documentation-url.ts",
|
|
12259
|
+
"kind": "import-statement",
|
|
12260
|
+
"original": "./get-documentation-url"
|
|
12261
|
+
}
|
|
12262
|
+
],
|
|
12263
|
+
"format": "esm"
|
|
12264
|
+
},
|
|
12249
12265
|
"src/file-path-comment.ts": {
|
|
12250
12266
|
"bytes": 2234,
|
|
12251
12267
|
"imports": [],
|
|
@@ -12256,17 +12272,6 @@
|
|
|
12256
12272
|
"imports": [],
|
|
12257
12273
|
"format": "esm"
|
|
12258
12274
|
},
|
|
12259
|
-
"src/no-enum.ts": {
|
|
12260
|
-
"bytes": 1564,
|
|
12261
|
-
"imports": [
|
|
12262
|
-
{
|
|
12263
|
-
"path": "node_modules/@typescript-eslint/utils/dist/index.js",
|
|
12264
|
-
"kind": "import-statement",
|
|
12265
|
-
"original": "@typescript-eslint/utils"
|
|
12266
|
-
}
|
|
12267
|
-
],
|
|
12268
|
-
"format": "esm"
|
|
12269
|
-
},
|
|
12270
12275
|
"src/no-test-import.ts": {
|
|
12271
12276
|
"bytes": 1874,
|
|
12272
12277
|
"imports": [],
|
|
@@ -12303,7 +12308,7 @@
|
|
|
12303
12308
|
"format": "esm"
|
|
12304
12309
|
},
|
|
12305
12310
|
"src/index.ts": {
|
|
12306
|
-
"bytes":
|
|
12311
|
+
"bytes": 3317,
|
|
12307
12312
|
"imports": [
|
|
12308
12313
|
{
|
|
12309
12314
|
"path": "src/invalid-json-stringify.ts",
|
|
@@ -12320,6 +12325,11 @@
|
|
|
12320
12325
|
"kind": "import-statement",
|
|
12321
12326
|
"original": "./require-resolve-full-response"
|
|
12322
12327
|
},
|
|
12328
|
+
{
|
|
12329
|
+
"path": "src/require-type-out-of-type-only-imports.ts",
|
|
12330
|
+
"kind": "import-statement",
|
|
12331
|
+
"original": "./require-type-out-of-type-only-imports"
|
|
12332
|
+
},
|
|
12323
12333
|
{
|
|
12324
12334
|
"path": "src/file-path-comment.ts",
|
|
12325
12335
|
"kind": "import-statement",
|
|
@@ -12330,11 +12340,6 @@
|
|
|
12330
12340
|
"kind": "import-statement",
|
|
12331
12341
|
"original": "./no-card-numbers"
|
|
12332
12342
|
},
|
|
12333
|
-
{
|
|
12334
|
-
"path": "src/no-enum.ts",
|
|
12335
|
-
"kind": "import-statement",
|
|
12336
|
-
"original": "./no-enum"
|
|
12337
|
-
},
|
|
12338
12343
|
{
|
|
12339
12344
|
"path": "src/no-test-import.ts",
|
|
12340
12345
|
"kind": "import-statement",
|
|
@@ -15134,10 +15139,10 @@
|
|
|
15134
15139
|
"bytesInOutput": 2215
|
|
15135
15140
|
},
|
|
15136
15141
|
"src/index.ts": {
|
|
15137
|
-
"bytesInOutput":
|
|
15142
|
+
"bytesInOutput": 2218
|
|
15138
15143
|
},
|
|
15139
15144
|
"package.json": {
|
|
15140
|
-
"bytesInOutput":
|
|
15145
|
+
"bytesInOutput": 3297
|
|
15141
15146
|
},
|
|
15142
15147
|
"src/get-documentation-url.ts": {
|
|
15143
15148
|
"bytesInOutput": 146
|
|
@@ -15154,15 +15159,15 @@
|
|
|
15154
15159
|
"src/require-resolve-full-response.ts": {
|
|
15155
15160
|
"bytesInOutput": 7342
|
|
15156
15161
|
},
|
|
15162
|
+
"src/require-type-out-of-type-only-imports.ts": {
|
|
15163
|
+
"bytesInOutput": 1627
|
|
15164
|
+
},
|
|
15157
15165
|
"src/file-path-comment.ts": {
|
|
15158
15166
|
"bytesInOutput": 1961
|
|
15159
15167
|
},
|
|
15160
15168
|
"src/no-card-numbers.ts": {
|
|
15161
15169
|
"bytesInOutput": 3356
|
|
15162
15170
|
},
|
|
15163
|
-
"src/no-enum.ts": {
|
|
15164
|
-
"bytesInOutput": 1317
|
|
15165
|
-
},
|
|
15166
15171
|
"src/no-test-import.ts": {
|
|
15167
15172
|
"bytesInOutput": 1458
|
|
15168
15173
|
},
|
|
@@ -15185,7 +15190,7 @@
|
|
|
15185
15190
|
"bytesInOutput": 3362
|
|
15186
15191
|
}
|
|
15187
15192
|
},
|
|
15188
|
-
"bytes":
|
|
15193
|
+
"bytes": 4229326
|
|
15189
15194
|
}
|
|
15190
15195
|
}
|
|
15191
15196
|
}
|
package/dist-mjs/index.mjs
CHANGED
|
@@ -4,9 +4,11 @@ import noPromiseInstanceMethod, { ruleId as noPromiseInstanceMethodRuleId } from
|
|
|
4
4
|
import requireResolveFullResponse, {
|
|
5
5
|
ruleId as requireResolveFullResponseRuleId
|
|
6
6
|
} from "./require-resolve-full-response.mjs";
|
|
7
|
+
import requireTypeOutOfTypeOnlyImports, {
|
|
8
|
+
ruleId as requireTypeOutOfTypeOnlyImportsRuleId
|
|
9
|
+
} from "./require-type-out-of-type-only-imports.mjs";
|
|
7
10
|
import filePathComment from "./file-path-comment.mjs";
|
|
8
11
|
import noCardNumbers from "./no-card-numbers.mjs";
|
|
9
|
-
import noEnum from "./no-enum.mjs";
|
|
10
12
|
import noTestImport from "./no-test-import.mjs";
|
|
11
13
|
import noUuid from "./no-uuid.mjs";
|
|
12
14
|
import noWallabyComment from "./no-wallaby-comment.mjs";
|
|
@@ -18,7 +20,6 @@ var src_default = {
|
|
|
18
20
|
rules: {
|
|
19
21
|
"file-path-comment": filePathComment,
|
|
20
22
|
"no-card-numbers": noCardNumbers,
|
|
21
|
-
"no-enum": noEnum,
|
|
22
23
|
"no-uuid": noUuid,
|
|
23
24
|
"require-strict-assert": requireStrictAssert,
|
|
24
25
|
"no-test-import": noTestImport,
|
|
@@ -28,13 +29,13 @@ var src_default = {
|
|
|
28
29
|
"object-literal-response": objectLiteralResponse,
|
|
29
30
|
[invalidJsonStringifyRuleId]: invalidJsonStringify,
|
|
30
31
|
[noPromiseInstanceMethodRuleId]: noPromiseInstanceMethod,
|
|
31
|
-
[requireResolveFullResponseRuleId]: requireResolveFullResponse
|
|
32
|
+
[requireResolveFullResponseRuleId]: requireResolveFullResponse,
|
|
33
|
+
[requireTypeOutOfTypeOnlyImportsRuleId]: requireTypeOutOfTypeOnlyImports
|
|
32
34
|
},
|
|
33
35
|
configs: {
|
|
34
36
|
all: {
|
|
35
37
|
rules: {
|
|
36
38
|
"@checkdigit/no-card-numbers": "error",
|
|
37
|
-
"@checkdigit/no-enum": "error",
|
|
38
39
|
"@checkdigit/file-path-comment": "error",
|
|
39
40
|
"@checkdigit/no-uuid": "error",
|
|
40
41
|
"@checkdigit/require-strict-assert": "error",
|
|
@@ -45,13 +46,13 @@ var src_default = {
|
|
|
45
46
|
"@checkdigit/no-test-import": "error",
|
|
46
47
|
[`@checkdigit/${invalidJsonStringifyRuleId}`]: "error",
|
|
47
48
|
[`@checkdigit/${noPromiseInstanceMethodRuleId}`]: "error",
|
|
48
|
-
[`@checkdigit/${requireResolveFullResponseRuleId}`]: "error"
|
|
49
|
+
[`@checkdigit/${requireResolveFullResponseRuleId}`]: "error",
|
|
50
|
+
[`@checkdigit/${requireTypeOutOfTypeOnlyImportsRuleId}`]: "error"
|
|
49
51
|
}
|
|
50
52
|
},
|
|
51
53
|
recommended: {
|
|
52
54
|
rules: {
|
|
53
55
|
"@checkdigit/no-card-numbers": "error",
|
|
54
|
-
"@checkdigit/no-enum": "error",
|
|
55
56
|
"@checkdigit/file-path-comment": "off",
|
|
56
57
|
"@checkdigit/no-uuid": "error",
|
|
57
58
|
"@checkdigit/require-strict-assert": "error",
|
|
@@ -69,4 +70,4 @@ var src_default = {
|
|
|
69
70
|
export {
|
|
70
71
|
src_default as default
|
|
71
72
|
};
|
|
72
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgIm1hcHBpbmdzIjogIjtBQVFBLE9BQU8sd0JBQXdCLFVBQVUsa0NBQWtDO0FBQzNFLE9BQU8sMkJBQTJCLFVBQVUscUNBQXFD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EIsRUFBRSxHQUFHO0FBQUEsUUFDL0MsQ0FBQyxlQUFlLDZCQUE2QixFQUFFLEdBQUc7QUFBQSxRQUNsRCxDQUFDLGVBQWUsZ0NBQWdDLEVBQUUsR0FBRztBQUFBLFFBQ3JELENBQUMsZUFBZSxxQ0FBcUMsRUFBRSxHQUFHO0FBQUEsTUFDNUQ7QUFBQSxJQUNGO0FBQUEsSUFDQSxhQUFhO0FBQUEsTUFDWCxPQUFPO0FBQUEsUUFDTCwrQkFBK0I7QUFBQSxRQUMvQixpQ0FBaUM7QUFBQSxRQUNqQyx1QkFBdUI7QUFBQSxRQUN2QixxQ0FBcUM7QUFBQSxRQUNyQyxrQ0FBa0M7QUFBQSxRQUNsQywwQ0FBMEM7QUFBQSxRQUMxQyx1REFBdUQ7QUFBQSxRQUN2RCx1Q0FBdUM7QUFBQSxRQUN2Qyw4QkFBOEI7QUFBQSxRQUM5QixDQUFDLGVBQWUsMEJBQTBCLEVBQUUsR0FBRztBQUFBLFFBQy9DLENBQUMsZUFBZSw2QkFBNkIsRUFBRSxHQUFHO0FBQUEsTUFDcEQ7QUFBQSxJQUNGO0FBQUEsRUFDRjtBQUNGOyIsCiAgIm5hbWVzIjogW10KfQo=
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/require-type-out-of-type-only-imports.ts
|
|
2
|
+
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
|
|
3
|
+
import getDocumentationUrl from "./get-documentation-url.mjs";
|
|
4
|
+
var ruleId = "require-type-out-of-type-only-imports";
|
|
5
|
+
var createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
|
|
6
|
+
var rule = createRule({
|
|
7
|
+
name: ruleId,
|
|
8
|
+
meta: {
|
|
9
|
+
type: "suggestion",
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Require "type" to be out side of type-only imports.'
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
moveTypeOutside: 'Update the type-only imports to use "tpe" outside of the curly braces.'
|
|
15
|
+
},
|
|
16
|
+
fixable: "code",
|
|
17
|
+
schema: []
|
|
18
|
+
},
|
|
19
|
+
defaultOptions: [],
|
|
20
|
+
create(context) {
|
|
21
|
+
const sourceCode = context.sourceCode;
|
|
22
|
+
return {
|
|
23
|
+
ImportDeclaration(declaration) {
|
|
24
|
+
if (declaration.importKind === "type" || !declaration.specifiers.every(
|
|
25
|
+
(specifier) => specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type"
|
|
26
|
+
)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
context.report({
|
|
30
|
+
messageId: "moveTypeOutside",
|
|
31
|
+
node: declaration,
|
|
32
|
+
*fix(fixer) {
|
|
33
|
+
const moduleName = declaration.source.value;
|
|
34
|
+
const mergedSpecifiers = declaration.specifiers.filter((specifier) => specifier.type !== TSESTree.AST_NODE_TYPES.ImportDefaultSpecifier).map((specifier) => sourceCode.getText(specifier).replace("type ", ""));
|
|
35
|
+
const updatedImportDeclaration = `import type { ${mergedSpecifiers.join(", ")} } from '${moduleName}';`;
|
|
36
|
+
yield fixer.replaceText(declaration, updatedImportDeclaration);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var require_type_out_of_type_only_imports_default = rule;
|
|
44
|
+
export {
|
|
45
|
+
require_type_out_of_type_only_imports_default as default,
|
|
46
|
+
ruleId
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL3JlcXVpcmUtdHlwZS1vdXQtb2YtdHlwZS1vbmx5LWltcG9ydHMudHMiXSwKICAibWFwcGluZ3MiOiAiO0FBUUEsU0FBUyxhQUFhLGdCQUFnQjtBQUN0QyxPQUFPLHlCQUF5QjtBQUV6QixJQUFNLFNBQVM7QUFFdEIsSUFBTSxhQUFhLF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BQy9EO0FBQUEsUUFDRixDQUFDO0FBQUEsTUFDSDtBQUFBLElBQ0Y7QUFBQSxFQUNGO0FBQ0YsQ0FBQztBQUVELElBQU8sZ0RBQVE7IiwKICAibmFtZXMiOiBbXQp9Cg==
|
package/dist-types/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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-enum': import("@typescript-eslint/utils/ts-eslint").RuleModule<"NO_ENUM", never[], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
6
5
|
'no-uuid': import("eslint").Rule.RuleModule;
|
|
7
6
|
'require-strict-assert': import("eslint").Rule.RuleModule;
|
|
8
7
|
'no-test-import': import("eslint").Rule.RuleModule;
|
|
@@ -13,12 +12,12 @@ declare const _default: {
|
|
|
13
12
|
"invalid-json-stringify": import("eslint").Rule.RuleModule;
|
|
14
13
|
"no-promise-instance-method": import("eslint").Rule.RuleModule;
|
|
15
14
|
"require-resolve-full-response": import("@typescript-eslint/utils/ts-eslint").RuleModule<"invalidOptions" | "unknownError", never[], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
15
|
+
"require-type-out-of-type-only-imports": import("@typescript-eslint/utils/ts-eslint").RuleModule<"moveTypeOutside", never[], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
16
16
|
};
|
|
17
17
|
configs: {
|
|
18
18
|
all: {
|
|
19
19
|
rules: {
|
|
20
20
|
'@checkdigit/no-card-numbers': string;
|
|
21
|
-
'@checkdigit/no-enum': string;
|
|
22
21
|
'@checkdigit/file-path-comment': string;
|
|
23
22
|
'@checkdigit/no-uuid': string;
|
|
24
23
|
'@checkdigit/require-strict-assert': string;
|
|
@@ -30,12 +29,12 @@ declare const _default: {
|
|
|
30
29
|
"@checkdigit/invalid-json-stringify": string;
|
|
31
30
|
"@checkdigit/no-promise-instance-method": string;
|
|
32
31
|
"@checkdigit/require-resolve-full-response": string;
|
|
32
|
+
"@checkdigit/require-type-out-of-type-only-imports": string;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
recommended: {
|
|
36
36
|
rules: {
|
|
37
37
|
'@checkdigit/no-card-numbers': string;
|
|
38
|
-
'@checkdigit/no-enum': string;
|
|
39
38
|
'@checkdigit/file-path-comment': string;
|
|
40
39
|
'@checkdigit/no-uuid': string;
|
|
41
40
|
'@checkdigit/require-strict-assert': string;
|
package/package.json
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@checkdigit/eslint-plugin",
|
|
3
|
+
"version": "6.7.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.0",
|
|
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.29.1",
|
|
80
|
+
"eslint-plugin-no-only-tests": "^3.1.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
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,9 +11,11 @@ import noPromiseInstanceMethod, { ruleId as noPromiseInstanceMethodRuleId } from
|
|
|
11
11
|
import requireResolveFullResponse, {
|
|
12
12
|
ruleId as requireResolveFullResponseRuleId,
|
|
13
13
|
} from './require-resolve-full-response';
|
|
14
|
+
import requireTypeOutOfTypeOnlyImports, {
|
|
15
|
+
ruleId as requireTypeOutOfTypeOnlyImportsRuleId,
|
|
16
|
+
} from './require-type-out-of-type-only-imports';
|
|
14
17
|
import filePathComment from './file-path-comment';
|
|
15
18
|
import noCardNumbers from './no-card-numbers';
|
|
16
|
-
import noEnum from './no-enum';
|
|
17
19
|
import noTestImport from './no-test-import';
|
|
18
20
|
import noUuid from './no-uuid';
|
|
19
21
|
import noWallabyComment from './no-wallaby-comment';
|
|
@@ -26,7 +28,6 @@ export default {
|
|
|
26
28
|
rules: {
|
|
27
29
|
'file-path-comment': filePathComment,
|
|
28
30
|
'no-card-numbers': noCardNumbers,
|
|
29
|
-
'no-enum': noEnum,
|
|
30
31
|
'no-uuid': noUuid,
|
|
31
32
|
'require-strict-assert': requireStrictAssert,
|
|
32
33
|
'no-test-import': noTestImport,
|
|
@@ -37,12 +38,12 @@ export default {
|
|
|
37
38
|
[invalidJsonStringifyRuleId]: invalidJsonStringify,
|
|
38
39
|
[noPromiseInstanceMethodRuleId]: noPromiseInstanceMethod,
|
|
39
40
|
[requireResolveFullResponseRuleId]: requireResolveFullResponse,
|
|
41
|
+
[requireTypeOutOfTypeOnlyImportsRuleId]: requireTypeOutOfTypeOnlyImports,
|
|
40
42
|
},
|
|
41
43
|
configs: {
|
|
42
44
|
all: {
|
|
43
45
|
rules: {
|
|
44
46
|
'@checkdigit/no-card-numbers': 'error',
|
|
45
|
-
'@checkdigit/no-enum': 'error',
|
|
46
47
|
'@checkdigit/file-path-comment': 'error',
|
|
47
48
|
'@checkdigit/no-uuid': 'error',
|
|
48
49
|
'@checkdigit/require-strict-assert': 'error',
|
|
@@ -54,12 +55,12 @@ export default {
|
|
|
54
55
|
[`@checkdigit/${invalidJsonStringifyRuleId}`]: 'error',
|
|
55
56
|
[`@checkdigit/${noPromiseInstanceMethodRuleId}`]: 'error',
|
|
56
57
|
[`@checkdigit/${requireResolveFullResponseRuleId}`]: 'error',
|
|
58
|
+
[`@checkdigit/${requireTypeOutOfTypeOnlyImportsRuleId}`]: 'error',
|
|
57
59
|
},
|
|
58
60
|
},
|
|
59
61
|
recommended: {
|
|
60
62
|
rules: {
|
|
61
63
|
'@checkdigit/no-card-numbers': 'error',
|
|
62
|
-
'@checkdigit/no-enum': 'error',
|
|
63
64
|
'@checkdigit/file-path-comment': 'off',
|
|
64
65
|
'@checkdigit/no-uuid': 'error',
|
|
65
66
|
'@checkdigit/require-strict-assert': 'error',
|
package/src/library/format.ts
CHANGED
package/src/library/tree.ts
CHANGED
package/src/library/ts-tree.ts
CHANGED
package/src/library/variable.ts
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// require-type-out-of-type-only-imports.ts
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2021-2024 Check Digit, LLC
|
|
5
|
+
*
|
|
6
|
+
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
|
|
10
|
+
import getDocumentationUrl from './get-documentation-url';
|
|
11
|
+
|
|
12
|
+
export const ruleId = 'require-type-out-of-type-only-imports';
|
|
13
|
+
|
|
14
|
+
const createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
|
|
15
|
+
|
|
16
|
+
const rule = createRule({
|
|
17
|
+
name: ruleId,
|
|
18
|
+
meta: {
|
|
19
|
+
type: 'suggestion',
|
|
20
|
+
docs: {
|
|
21
|
+
description: 'Require "type" to be out side of type-only imports.',
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
24
|
+
moveTypeOutside: 'Update the type-only imports to use "tpe" outside of the curly braces.',
|
|
25
|
+
},
|
|
26
|
+
fixable: 'code',
|
|
27
|
+
schema: [],
|
|
28
|
+
},
|
|
29
|
+
defaultOptions: [],
|
|
30
|
+
create(context) {
|
|
31
|
+
const sourceCode = context.sourceCode;
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
ImportDeclaration(declaration) {
|
|
35
|
+
if (
|
|
36
|
+
declaration.importKind === 'type' ||
|
|
37
|
+
!declaration.specifiers.every(
|
|
38
|
+
(specifier) =>
|
|
39
|
+
specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === 'type',
|
|
40
|
+
)
|
|
41
|
+
) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
context.report({
|
|
46
|
+
messageId: 'moveTypeOutside',
|
|
47
|
+
node: declaration,
|
|
48
|
+
*fix(fixer) {
|
|
49
|
+
const moduleName = declaration.source.value;
|
|
50
|
+
const mergedSpecifiers = declaration.specifiers
|
|
51
|
+
.filter((specifier) => specifier.type !== TSESTree.AST_NODE_TYPES.ImportDefaultSpecifier)
|
|
52
|
+
.map((specifier) => sourceCode.getText(specifier).replace('type ', ''));
|
|
53
|
+
const updatedImportDeclaration = `import type { ${mergedSpecifiers.join(', ')} } from '${moduleName}';`;
|
|
54
|
+
|
|
55
|
+
yield fixer.replaceText(declaration, updatedImportDeclaration);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export default rule;
|
package/dist-mjs/no-enum.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// src/no-enum.ts
|
|
2
|
-
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
|
|
3
|
-
var ruleId = "no-enum";
|
|
4
|
-
var NO_ENUM = "NO_ENUM";
|
|
5
|
-
var createRule = ESLintUtils.RuleCreator((name) => name);
|
|
6
|
-
function isJsonSchemaProperty(node) {
|
|
7
|
-
if (!node) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (node.type === TSESTree.AST_NODE_TYPES.Property && node.key.type === TSESTree.AST_NODE_TYPES.Identifier && node.key.name === "properties") {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return isJsonSchemaProperty(node.parent);
|
|
14
|
-
}
|
|
15
|
-
var rule = createRule({
|
|
16
|
-
name: ruleId,
|
|
17
|
-
meta: {
|
|
18
|
-
type: "problem",
|
|
19
|
-
docs: {
|
|
20
|
-
description: "Disallow the use of `enum` in TypeScript"
|
|
21
|
-
},
|
|
22
|
-
schema: [],
|
|
23
|
-
messages: {
|
|
24
|
-
[NO_ENUM]: "Avoid using `enum` in TypeScript."
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
defaultOptions: [],
|
|
28
|
-
create(context) {
|
|
29
|
-
return {
|
|
30
|
-
TSEnumDeclaration(node) {
|
|
31
|
-
context.report({
|
|
32
|
-
node,
|
|
33
|
-
messageId: NO_ENUM
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
Property(node) {
|
|
37
|
-
if (node.key.type === TSESTree.AST_NODE_TYPES.Identifier && node.key.name === "enum" && node.value.type === TSESTree.AST_NODE_TYPES.ArrayExpression && !isJsonSchemaProperty(node.parent)) {
|
|
38
|
-
context.report({
|
|
39
|
-
node,
|
|
40
|
-
messageId: NO_ENUM
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
var no_enum_default = rule;
|
|
48
|
-
export {
|
|
49
|
-
no_enum_default as default,
|
|
50
|
-
ruleId
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL25vLWVudW0udHMiXSwKICAibWFwcGluZ3MiOiAiO0FBUUEsU0FBUyxhQUFhLGdCQUFnQjtBQUUvQixJQUFNLFNBQVM7QUFDdEIsSUFBTSxVQUFVO0FBRWhCLElBQU0sYUFBYSxZQUFZLFlBQVksQ0FBQyxTQUFTLElBQUk7QUFFekQsU0FBUyxxQkFBcUIsTUFBK0I7QUFDM0QsTUFBSSxDQUFDLE1BQU07QUFDVCxXQUFPO0FBQUEsRUFDVDtBQUNBLE1BQ0UsS0FBSyxTQUFTLFNBQVMsZUFBZSxZQ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
|
|
1
|
-
// no-enum.ts
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2021-2024 Check Digit, LLC
|
|
5
|
-
*
|
|
6
|
-
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
|
|
10
|
-
|
|
11
|
-
export const ruleId = 'no-enum';
|
|
12
|
-
const NO_ENUM = 'NO_ENUM';
|
|
13
|
-
|
|
14
|
-
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
15
|
-
|
|
16
|
-
function isJsonSchemaProperty(node?: TSESTree.Node): boolean {
|
|
17
|
-
if (!node) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
if (
|
|
21
|
-
node.type === TSESTree.AST_NODE_TYPES.Property &&
|
|
22
|
-
node.key.type === TSESTree.AST_NODE_TYPES.Identifier &&
|
|
23
|
-
node.key.name === 'properties'
|
|
24
|
-
) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return isJsonSchemaProperty(node.parent);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const rule = createRule({
|
|
31
|
-
name: ruleId,
|
|
32
|
-
meta: {
|
|
33
|
-
type: 'problem',
|
|
34
|
-
docs: {
|
|
35
|
-
description: 'Disallow the use of `enum` in TypeScript',
|
|
36
|
-
},
|
|
37
|
-
schema: [],
|
|
38
|
-
messages: {
|
|
39
|
-
[NO_ENUM]: 'Avoid using `enum` in TypeScript.',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
defaultOptions: [],
|
|
43
|
-
create(context) {
|
|
44
|
-
return {
|
|
45
|
-
TSEnumDeclaration(node: TSESTree.TSEnumDeclaration) {
|
|
46
|
-
context.report({
|
|
47
|
-
node,
|
|
48
|
-
messageId: NO_ENUM,
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
Property(node: TSESTree.Property) {
|
|
52
|
-
if (
|
|
53
|
-
node.key.type === TSESTree.AST_NODE_TYPES.Identifier &&
|
|
54
|
-
node.key.name === 'enum' &&
|
|
55
|
-
node.value.type === TSESTree.AST_NODE_TYPES.ArrayExpression &&
|
|
56
|
-
!isJsonSchemaProperty(node.parent)
|
|
57
|
-
) {
|
|
58
|
-
context.report({
|
|
59
|
-
node,
|
|
60
|
-
messageId: NO_ENUM,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
export default rule;
|