eslint-plugin-th-rules 3.1.0 → 3.1.2
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/dist/configs/bundles/recommended-react.d.ts +3 -1
- package/dist/configs/bundles/recommended-react.d.ts.map +1 -0
- package/dist/configs/bundles/recommended-react.js +2 -1
- package/dist/configs/bundles/recommended-typescript-react.d.ts +3 -1
- package/dist/configs/bundles/recommended-typescript-react.d.ts.map +1 -0
- package/dist/configs/bundles/recommended-typescript-react.js +1 -0
- package/dist/configs/bundles/recommended-typescript.d.ts +3 -1
- package/dist/configs/bundles/recommended-typescript.d.ts.map +1 -0
- package/dist/configs/bundles/recommended-typescript.js +1 -0
- package/dist/configs/bundles/recommended.d.ts +3 -1
- package/dist/configs/bundles/recommended.d.ts.map +1 -0
- package/dist/configs/bundles/recommended.js +1 -0
- package/dist/configs/core/base.d.ts +2 -0
- package/dist/configs/core/base.d.ts.map +1 -0
- package/dist/configs/core/base.js +8 -4
- package/dist/configs/core/react.d.ts +2 -0
- package/dist/configs/core/react.d.ts.map +1 -0
- package/dist/configs/core/react.js +1 -0
- package/dist/configs/core/typescript.d.ts +2 -0
- package/dist/configs/core/typescript.d.ts.map +1 -0
- package/dist/configs/core/typescript.js +1 -0
- package/dist/configs/externals/base.d.ts +2 -0
- package/dist/configs/externals/base.d.ts.map +1 -0
- package/dist/configs/externals/base.js +1 -0
- package/dist/configs/externals/opinionated.d.ts +3 -1
- package/dist/configs/externals/opinionated.d.ts.map +1 -0
- package/dist/configs/externals/opinionated.js +1 -0
- package/dist/index.d.ts +12 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -10
- package/dist/plugin.d.ts +80 -3
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +19 -13
- package/dist/rules/no-boolean-coercion.d.ts +3 -2
- package/dist/rules/no-boolean-coercion.d.ts.map +1 -0
- package/dist/rules/no-boolean-coercion.js +2 -7
- package/dist/rules/no-comments.d.ts +1 -0
- package/dist/rules/no-comments.d.ts.map +1 -0
- package/dist/rules/no-comments.js +0 -1
- package/dist/rules/no-default-export.d.ts +1 -0
- package/dist/rules/no-default-export.d.ts.map +1 -0
- package/dist/rules/no-destructuring.d.ts +1 -0
- package/dist/rules/no-destructuring.d.ts.map +1 -0
- package/dist/rules/prefer-is-empty.d.ts +1 -0
- package/dist/rules/prefer-is-empty.d.ts.map +1 -0
- package/dist/rules/prefer-is-empty.js +25 -28
- package/dist/rules/schemas-in-schemas-file.d.ts +1 -0
- package/dist/rules/schemas-in-schemas-file.d.ts.map +1 -0
- package/dist/rules/schemas-in-schemas-file.js +21 -25
- package/dist/rules/top-level-functions.d.ts +1 -0
- package/dist/rules/top-level-functions.d.ts.map +1 -0
- package/dist/rules/types-in-dts.d.ts +1 -0
- package/dist/rules/types-in-dts.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { type Linter } from 'eslint';
|
|
2
|
-
export declare const recommendedReact: Linter.Config
|
|
2
|
+
export declare const recommendedReact: Linter.Config[];
|
|
3
|
+
export default recommendedReact;
|
|
4
|
+
//# sourceMappingURL=recommended-react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-react.d.ts","sourceRoot":"","sources":["../../../src/configs/bundles/recommended-react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,QAAQ,CAAC;AAKnC,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAMvB,CAAC;AAEtB,eAAe,gBAAgB,CAAC"}
|
|
@@ -7,6 +7,7 @@ export const recommendedReact = resolveFlatConfig([
|
|
|
7
7
|
...recommended,
|
|
8
8
|
react.configs.flat.recommended,
|
|
9
9
|
react.configs.flat['jsx-runtime'],
|
|
10
|
-
reactHooks.configs.recommended,
|
|
10
|
+
reactHooks.configs.flat.recommended,
|
|
11
11
|
...coreReact,
|
|
12
12
|
]);
|
|
13
|
+
export default recommendedReact;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { type Linter } from 'eslint';
|
|
2
|
-
export declare const recommendedTypescriptReact: Linter.Config
|
|
2
|
+
export declare const recommendedTypescriptReact: Linter.Config[];
|
|
3
|
+
export default recommendedTypescriptReact;
|
|
4
|
+
//# sourceMappingURL=recommended-typescript-react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-typescript-react.d.ts","sourceRoot":"","sources":["../../../src/configs/bundles/recommended-typescript-react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,QAAQ,CAAC;AAMnC,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAIjC,CAAC;AAEtB,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { type Linter } from 'eslint';
|
|
2
|
-
export declare const recommendedTypescript: Linter.Config
|
|
2
|
+
export declare const recommendedTypescript: Linter.Config[];
|
|
3
|
+
export default recommendedTypescript;
|
|
4
|
+
//# sourceMappingURL=recommended-typescript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-typescript.d.ts","sourceRoot":"","sources":["../../../src/configs/bundles/recommended-typescript.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,QAAQ,CAAC;AAInC,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAG5B,CAAC;AAEtB,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { type Linter } from 'eslint';
|
|
2
|
-
export declare const recommended: Linter.Config
|
|
2
|
+
export declare const recommended: Linter.Config[];
|
|
3
|
+
export default recommended;
|
|
4
|
+
//# sourceMappingURL=recommended.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../../src/configs/bundles/recommended.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,QAAQ,CAAC;AAKnC,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAIlB,CAAC;AAEtB,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/configs/core/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAGzD,eAAO,MAAM,QAAQ,EAAE,iBAAiB,EAwBvC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -15,9 +15,13 @@ export const coreBase = [
|
|
|
15
15
|
...globals.jest,
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
-
rules:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
rules: (() => {
|
|
19
|
+
const rules = {};
|
|
20
|
+
for (const ruleName of Object.keys(plugin.rules)) {
|
|
21
|
+
rules[`th-rules/${ruleName}`] = 'error';
|
|
22
|
+
}
|
|
23
|
+
return rules;
|
|
24
|
+
})(),
|
|
22
25
|
},
|
|
23
26
|
];
|
|
27
|
+
export default coreBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/configs/core/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAEzD,eAAO,MAAM,SAAS,EAAE,iBAAiB,EAOxC,CAAC;AACF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../../src/configs/core/typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAExE,eAAO,MAAM,cAAc,EAAE,iBAAiB,EAiB7C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/configs/externals/base.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAEzD,eAAO,MAAM,aAAa,EAAE,iBAAiB,EAW5C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opinionated.d.ts","sourceRoot":"","sources":["../../../src/configs/externals/opinionated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAEzD,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,EAWnD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { type Linter, type Rule } from 'eslint';
|
|
2
|
+
export declare const configs: {
|
|
3
|
+
recommended: Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
4
|
+
recommendedReact: Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
5
|
+
recommendedTypescript: Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
6
|
+
recommendedTypescriptReact: Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
7
|
+
};
|
|
2
8
|
export { coreBase } from './configs/core/base.js';
|
|
3
9
|
export { coreTypescript } from './configs/core/typescript.js';
|
|
4
10
|
export { coreReact } from './configs/core/react.js';
|
|
5
11
|
export { externalsBase } from './configs/externals/base.js';
|
|
6
12
|
export { externalsOpinionated } from './configs/externals/opinionated.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
recommendedTypescript: import("eslint").Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
11
|
-
recommendedTypescriptReact: import("eslint").Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
12
|
-
};
|
|
13
|
-
declare const _default: {
|
|
14
|
-
rules: any;
|
|
15
|
-
configs: {
|
|
16
|
-
recommended: import("eslint").Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
17
|
-
recommendedReact: import("eslint").Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
18
|
-
recommendedTypescript: import("eslint").Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
19
|
-
recommendedTypescriptReact: import("eslint").Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
|
|
20
|
-
};
|
|
13
|
+
declare const index: {
|
|
14
|
+
rules: Record<string, Rule.RuleModule>;
|
|
15
|
+
configs: Record<string, Linter.Config[]>;
|
|
21
16
|
};
|
|
22
|
-
export default
|
|
17
|
+
export default index;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,MAAM,EAAE,KAAK,IAAI,EAAC,MAAM,QAAQ,CAAC;AAQ9C,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAEF,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AAExE,QAAA,MAAM,KAAK,EAAkC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;CAAC,CAAC;AAChI,eAAe,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
// Public bundles
|
|
1
|
+
/* eslint-disable import-x/order */
|
|
3
2
|
import { recommended } from './configs/bundles/recommended.js';
|
|
4
3
|
import { recommendedReact } from './configs/bundles/recommended-react.js';
|
|
5
4
|
import { recommendedTypescript } from './configs/bundles/recommended-typescript.js';
|
|
6
5
|
import { recommendedTypescriptReact } from './configs/bundles/recommended-typescript-react.js';
|
|
7
|
-
|
|
8
|
-
export { rules } from './plugin.js';
|
|
9
|
-
export { coreBase } from './configs/core/base.js';
|
|
10
|
-
export { coreTypescript } from './configs/core/typescript.js';
|
|
11
|
-
export { coreReact } from './configs/core/react.js';
|
|
12
|
-
export { externalsBase } from './configs/externals/base.js';
|
|
13
|
-
export { externalsOpinionated } from './configs/externals/opinionated.js';
|
|
6
|
+
import { rules } from './plugin.js';
|
|
14
7
|
export const configs = {
|
|
15
8
|
recommended,
|
|
16
9
|
recommendedReact,
|
|
17
10
|
recommendedTypescript,
|
|
18
11
|
recommendedTypescriptReact,
|
|
19
12
|
};
|
|
20
|
-
export
|
|
13
|
+
export { coreBase } from './configs/core/base.js';
|
|
14
|
+
export { coreTypescript } from './configs/core/typescript.js';
|
|
15
|
+
export { coreReact } from './configs/core/react.js';
|
|
16
|
+
export { externalsBase } from './configs/externals/base.js';
|
|
17
|
+
export { externalsOpinionated } from './configs/externals/opinionated.js';
|
|
18
|
+
const index = { rules, configs };
|
|
19
|
+
export default index;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
|
-
export declare const rules:
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const rules: {
|
|
2
|
+
noBooleanCoercion: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useIsEmpty" | "useIsNil", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
noComments: import("@typescript-eslint/utils/ts-eslint").RuleModule<"commentNotAllowed", [({
|
|
6
|
+
allow?: string[];
|
|
7
|
+
disallow?: string[];
|
|
8
|
+
} | undefined)?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
noDefaultExport: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unnamed", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
noDestructuring: import("@typescript-eslint/utils/ts-eslint").RuleModule<"tooDeep" | "tooMany" | "tooLong", [{
|
|
15
|
+
maximumDestructuredVariables: number;
|
|
16
|
+
maximumLineLength: number;
|
|
17
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
preferIsEmpty: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useIsEmpty", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
schemasInSchemasFile: import("@typescript-eslint/utils/ts-eslint").RuleModule<"moveSchema", [{
|
|
24
|
+
allowedSuffixes: string[];
|
|
25
|
+
onlyWhenAssigned: boolean;
|
|
26
|
+
allowInTests: boolean;
|
|
27
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
topLevelFunctions: import("@typescript-eslint/utils/ts-eslint").RuleModule<"arrow" | "funcExpr" | "anonDecl", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
typesInDts: import("@typescript-eslint/utils/ts-eslint").RuleModule<"moveToDts", [{
|
|
34
|
+
allowEnums: boolean;
|
|
35
|
+
allowDeclare: boolean;
|
|
36
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
37
|
+
name: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
declare const plugin: {
|
|
41
|
+
rules: {
|
|
42
|
+
noBooleanCoercion: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useIsEmpty" | "useIsNil", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
noComments: import("@typescript-eslint/utils/ts-eslint").RuleModule<"commentNotAllowed", [({
|
|
46
|
+
allow?: string[];
|
|
47
|
+
disallow?: string[];
|
|
48
|
+
} | undefined)?], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
noDefaultExport: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unnamed", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
52
|
+
name: string;
|
|
53
|
+
};
|
|
54
|
+
noDestructuring: import("@typescript-eslint/utils/ts-eslint").RuleModule<"tooDeep" | "tooMany" | "tooLong", [{
|
|
55
|
+
maximumDestructuredVariables: number;
|
|
56
|
+
maximumLineLength: number;
|
|
57
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
58
|
+
name: string;
|
|
59
|
+
};
|
|
60
|
+
preferIsEmpty: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useIsEmpty", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
61
|
+
name: string;
|
|
62
|
+
};
|
|
63
|
+
schemasInSchemasFile: import("@typescript-eslint/utils/ts-eslint").RuleModule<"moveSchema", [{
|
|
64
|
+
allowedSuffixes: string[];
|
|
65
|
+
onlyWhenAssigned: boolean;
|
|
66
|
+
allowInTests: boolean;
|
|
67
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
68
|
+
name: string;
|
|
69
|
+
};
|
|
70
|
+
topLevelFunctions: import("@typescript-eslint/utils/ts-eslint").RuleModule<"arrow" | "funcExpr" | "anonDecl", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
typesInDts: import("@typescript-eslint/utils/ts-eslint").RuleModule<"moveToDts", [{
|
|
74
|
+
allowEnums: boolean;
|
|
75
|
+
allowDeclare: boolean;
|
|
76
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
77
|
+
name: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
4
80
|
};
|
|
5
81
|
export default plugin;
|
|
82
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASjB,CAAC;AAEF,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAU,CAAC;AACvB,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import noBooleanCoercion from './rules/no-boolean-coercion.js';
|
|
2
|
+
import noComments from './rules/no-comments.js';
|
|
3
|
+
import noDefaultExport from './rules/no-default-export.js';
|
|
4
|
+
import noDestructuring from './rules/no-destructuring.js';
|
|
5
|
+
import preferIsEmpty from './rules/prefer-is-empty.js';
|
|
6
|
+
import schemasInSchemasFile from './rules/schemas-in-schemas-file.js';
|
|
7
|
+
import topLevelFunctions from './rules/top-level-functions.js';
|
|
8
|
+
import typesInDts from './rules/types-in-dts.js';
|
|
9
|
+
export const rules = {
|
|
10
|
+
noBooleanCoercion,
|
|
11
|
+
noComments,
|
|
12
|
+
noDefaultExport,
|
|
13
|
+
noDestructuring,
|
|
14
|
+
preferIsEmpty,
|
|
15
|
+
schemasInSchemasFile,
|
|
16
|
+
topLevelFunctions,
|
|
17
|
+
typesInDts,
|
|
18
|
+
};
|
|
19
|
+
const plugin = { rules };
|
|
14
20
|
export default plugin;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
declare const
|
|
2
|
+
declare const noBooleanCoercion: ESLintUtils.RuleModule<"useIsEmpty" | "useIsNil", [], unknown, ESLintUtils.RuleListener> & {
|
|
3
3
|
name: string;
|
|
4
4
|
};
|
|
5
|
-
export default
|
|
5
|
+
export default noBooleanCoercion;
|
|
6
|
+
//# sourceMappingURL=no-boolean-coercion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-boolean-coercion.d.ts","sourceRoot":"","sources":["../../src/rules/no-boolean-coercion.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EAEX,MAAM,0BAA0B,CAAC;AAIlC,QAAA,MAAM,iBAAiB;;CAiHrB,CAAC;AACH,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ESLintUtils, } from '@typescript-eslint/utils';
|
|
2
2
|
const createRule = ESLintUtils.RuleCreator(() => 'https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/no-boolean-coercion.md');
|
|
3
|
-
|
|
3
|
+
const noBooleanCoercion = createRule({
|
|
4
4
|
name: 'no-boolean-coercion',
|
|
5
5
|
meta: {
|
|
6
6
|
type: 'problem',
|
|
@@ -19,9 +19,6 @@ export default createRule({
|
|
|
19
19
|
const { sourceCode } = context;
|
|
20
20
|
const services = ESLintUtils.getParserServices(context);
|
|
21
21
|
const checker = services?.program?.getTypeChecker?.();
|
|
22
|
-
// --------------------------------------------------------------------
|
|
23
|
-
// Helpers
|
|
24
|
-
// --------------------------------------------------------------------
|
|
25
22
|
function isBooleanCall(node) {
|
|
26
23
|
return (node.type === 'CallExpression'
|
|
27
24
|
&& node.callee.type === 'Identifier'
|
|
@@ -73,9 +70,6 @@ export default createRule({
|
|
|
73
70
|
],
|
|
74
71
|
});
|
|
75
72
|
}
|
|
76
|
-
// --------------------------------------------------------------------
|
|
77
|
-
// Visitors
|
|
78
|
-
// --------------------------------------------------------------------
|
|
79
73
|
return {
|
|
80
74
|
CallExpression(node) {
|
|
81
75
|
if (isBooleanCall(node)) {
|
|
@@ -96,3 +90,4 @@ export default createRule({
|
|
|
96
90
|
};
|
|
97
91
|
},
|
|
98
92
|
});
|
|
93
|
+
export default noBooleanCoercion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-comments.d.ts","sourceRoot":"","sources":["../../src/rules/no-comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAEpE,KAAK,OAAO,GAAG;IACb;QACC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH,CAAC;AAYF,QAAA,MAAM,UAAU;;CAoFd,CAAC;AACH,eAAe,UAAU,CAAC"}
|
|
@@ -43,7 +43,6 @@ const noComments = ESLintUtils.RuleCreator(() => 'https://github.com/tomerh2001/
|
|
|
43
43
|
const userDisallowedPatterns = (option.disallow ?? []).map(pattern => new RegExp(pattern));
|
|
44
44
|
function isCommentAllowed(comment) {
|
|
45
45
|
const text = comment.value.trim();
|
|
46
|
-
// Allow JSDoc
|
|
47
46
|
if (comment.type === 'Block' && comment.value.startsWith('*')) {
|
|
48
47
|
return true;
|
|
49
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-default-export.d.ts","sourceRoot":"","sources":["../../src/rules/no-default-export.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAEpE,QAAA,MAAM,eAAe;;CAmEnB,CAAC;AACH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-destructuring.d.ts","sourceRoot":"","sources":["../../src/rules/no-destructuring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAIpE,QAAA,MAAM,eAAe;;;;;CAwJnB,CAAC;AACH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-is-empty.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-is-empty.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAEpF,QAAA,MAAM,aAAa;;CAiHjB,CAAC;AACH,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
/* eslint-disable complexity */
|
|
3
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
4
|
+
import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
|
|
2
5
|
const preferIsEmpty = ESLintUtils.RuleCreator(() => 'https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/prefer-is-empty.md')({
|
|
3
6
|
name: 'prefer-is-empty',
|
|
4
7
|
meta: {
|
|
@@ -14,21 +17,18 @@ const preferIsEmpty = ESLintUtils.RuleCreator(() => 'https://github.com/tomerh20
|
|
|
14
17
|
},
|
|
15
18
|
defaultOptions: [],
|
|
16
19
|
create(context) {
|
|
17
|
-
const sourceCode = context.getSourceCode();
|
|
18
20
|
function isLengthAccess(node) {
|
|
19
|
-
return (
|
|
20
|
-
&& node.type ===
|
|
21
|
-
&& node.property.type === 'Identifier'
|
|
21
|
+
return (node?.type === AST_NODE_TYPES.MemberExpression
|
|
22
|
+
&& node.property.type === AST_NODE_TYPES.Identifier
|
|
22
23
|
&& node.property.name === 'length'
|
|
23
24
|
&& !node.computed);
|
|
24
25
|
}
|
|
25
26
|
function isNumericLiteral(node) {
|
|
26
|
-
return (
|
|
27
|
-
&& node.type === 'Literal'
|
|
27
|
+
return (node?.type === AST_NODE_TYPES.Literal
|
|
28
28
|
&& typeof node.value === 'number');
|
|
29
29
|
}
|
|
30
30
|
function report(node, collectionNode, operator, value, isEmptyCheck) {
|
|
31
|
-
const collectionText = sourceCode.getText(collectionNode.object);
|
|
31
|
+
const collectionText = context.sourceCode.getText(collectionNode.object);
|
|
32
32
|
const replacement = isEmptyCheck
|
|
33
33
|
? `_.isEmpty(${collectionText})`
|
|
34
34
|
: `!_.isEmpty(${collectionText})`;
|
|
@@ -57,32 +57,29 @@ const preferIsEmpty = ESLintUtils.RuleCreator(() => 'https://github.com/tomerh20
|
|
|
57
57
|
}
|
|
58
58
|
return {
|
|
59
59
|
BinaryExpression(node) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|| (operator === '<' && value === 1)) {
|
|
66
|
-
report(node, left, operator, value, true);
|
|
60
|
+
if (isLengthAccess(node.left) && isNumericLiteral(node.right)) {
|
|
61
|
+
if ((node.operator === '===' && node.right.value === 0)
|
|
62
|
+
|| (node.operator === '<=' && node.right.value === 0)
|
|
63
|
+
|| (node.operator === '<' && node.right.value === 1)) {
|
|
64
|
+
report(node, node.left, node.operator, node.right.value, true);
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
|
-
if ((operator === '>' && value === 0)
|
|
70
|
-
|| (operator === '>=' && value === 1)
|
|
71
|
-
|| ((operator === '!=' || operator === '!==') && value === 0)) {
|
|
72
|
-
report(node, left, operator, value, false);
|
|
67
|
+
if ((node.operator === '>' && node.right.value === 0)
|
|
68
|
+
|| (node.operator === '>=' && node.right.value === 1)
|
|
69
|
+
|| ((node.operator === '!=' || node.operator === '!==') && node.right.value === 0)) {
|
|
70
|
+
report(node, node.left, node.operator, node.right.value, false);
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
|
-
if (isNumericLiteral(left) && isLengthAccess(right)) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|| (operator === '
|
|
79
|
-
|
|
80
|
-
report(node, right, operator, value, true);
|
|
73
|
+
if (isNumericLiteral(node.left) && isLengthAccess(node.right)) {
|
|
74
|
+
if ((node.operator === '===' && node.left.value === 0)
|
|
75
|
+
|| (node.operator === '>=' && node.left.value === 0)
|
|
76
|
+
|| (node.operator === '>' && node.left.value === 0)) {
|
|
77
|
+
report(node, node.right, node.operator, node.left.value, true);
|
|
81
78
|
return;
|
|
82
79
|
}
|
|
83
|
-
if ((operator === '<' && value === 1)
|
|
84
|
-
|| (operator === '<=' && value === 0)) {
|
|
85
|
-
report(node, right, operator, value, false);
|
|
80
|
+
if ((node.operator === '<' && node.left.value === 1)
|
|
81
|
+
|| (node.operator === '<=' && node.left.value === 0)) {
|
|
82
|
+
report(node, node.right, node.operator, node.left.value, false);
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas-in-schemas-file.d.ts","sourceRoot":"","sources":["../../src/rules/schemas-in-schemas-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAEpF,QAAA,MAAM,oBAAoB;;;;;;CA+LxB,CAAC;AACH,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
|
|
2
3
|
const schemasInSchemasFile = ESLintUtils.RuleCreator(() => 'https://github.com/tomerh2001/eslint-plugin-th-rules/blob/main/docs/rules/schemas-in-schemas-file.md')({
|
|
3
4
|
name: 'schemas-in-schemas-file',
|
|
4
5
|
meta: {
|
|
@@ -33,9 +34,9 @@ const schemasInSchemasFile = ESLintUtils.RuleCreator(() => 'https://github.com/t
|
|
|
33
34
|
},
|
|
34
35
|
],
|
|
35
36
|
create(context, [options]) {
|
|
36
|
-
const allowedSuffixes = options.allowedSuffixes
|
|
37
|
-
const onlyWhenAssigned =
|
|
38
|
-
const allowInTests =
|
|
37
|
+
const allowedSuffixes = options.allowedSuffixes && options.allowedSuffixes.length > 0 ? options.allowedSuffixes : ['.schemas.ts'];
|
|
38
|
+
const onlyWhenAssigned = options.onlyWhenAssigned ?? false;
|
|
39
|
+
const allowInTests = options.allowInTests ?? false;
|
|
39
40
|
const zodIdentifiers = new Set();
|
|
40
41
|
function filenameAllowed(filename) {
|
|
41
42
|
if (!filename || filename === '<input>') {
|
|
@@ -48,67 +49,62 @@ const schemasInSchemasFile = ESLintUtils.RuleCreator(() => 'https://github.com/t
|
|
|
48
49
|
return allowedSuffixes.some(suffix => filename.endsWith(suffix));
|
|
49
50
|
}
|
|
50
51
|
function isZodModuleImport(node) {
|
|
51
|
-
return (node.source.
|
|
52
|
-
&& node.source.value === 'zod');
|
|
52
|
+
return (node.source.value === 'zod');
|
|
53
53
|
}
|
|
54
54
|
function collectZodIdentifiersFromImport(node) {
|
|
55
55
|
if (!isZodModuleImport(node)) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
for (const spec of node.specifiers) {
|
|
59
|
-
if (spec.type ===
|
|
60
|
-
&& spec.imported.type ===
|
|
61
|
-
&& spec.imported.name === 'z'
|
|
62
|
-
&& spec.local.type === 'Identifier') {
|
|
59
|
+
if (spec.type === AST_NODE_TYPES.ImportSpecifier
|
|
60
|
+
&& spec.imported.type === AST_NODE_TYPES.Identifier
|
|
61
|
+
&& spec.imported.name === 'z') {
|
|
63
62
|
zodIdentifiers.add(spec.local.name);
|
|
64
63
|
}
|
|
65
|
-
if (spec.type ===
|
|
66
|
-
&& spec.local.type === 'Identifier') {
|
|
64
|
+
if (spec.type === AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
67
65
|
zodIdentifiers.add(spec.local.name);
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
function isZodBuilderCall(node) {
|
|
72
70
|
const { callee } = node;
|
|
73
|
-
if (callee.type !==
|
|
71
|
+
if (callee.type !== AST_NODE_TYPES.MemberExpression
|
|
74
72
|
|| callee.computed) {
|
|
75
73
|
return false;
|
|
76
74
|
}
|
|
77
75
|
const { object } = callee;
|
|
78
76
|
const { property } = callee;
|
|
79
|
-
return (object.type ===
|
|
77
|
+
return (object.type === AST_NODE_TYPES.Identifier
|
|
80
78
|
&& zodIdentifiers.has(object.name)
|
|
81
|
-
&& property.type ===
|
|
79
|
+
&& property.type === AST_NODE_TYPES.Identifier);
|
|
82
80
|
}
|
|
83
81
|
function isZodChainedBuilderCall(node) {
|
|
84
82
|
const { callee } = node;
|
|
85
|
-
if (callee.type !==
|
|
83
|
+
if (callee.type !== AST_NODE_TYPES.MemberExpression
|
|
86
84
|
|| callee.computed) {
|
|
87
85
|
return false;
|
|
88
86
|
}
|
|
89
87
|
let current = callee.object;
|
|
90
|
-
while (current.type ===
|
|
88
|
+
while (current.type === AST_NODE_TYPES.MemberExpression
|
|
91
89
|
&& !current.computed) {
|
|
92
90
|
current = current.object;
|
|
93
91
|
}
|
|
94
|
-
return (current.type ===
|
|
92
|
+
return (current.type === AST_NODE_TYPES.Identifier
|
|
95
93
|
&& zodIdentifiers.has(current.name));
|
|
96
94
|
}
|
|
97
95
|
function getAssignmentTargetName(callNode) {
|
|
98
96
|
const { parent } = callNode;
|
|
99
|
-
if (parent
|
|
100
|
-
&& parent.id.type ===
|
|
97
|
+
if (parent.type === AST_NODE_TYPES.VariableDeclarator
|
|
98
|
+
&& parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
101
99
|
return parent.id.name;
|
|
102
100
|
}
|
|
103
|
-
if (parent
|
|
104
|
-
&& parent.left.type ===
|
|
101
|
+
if (parent.type === AST_NODE_TYPES.AssignmentExpression
|
|
102
|
+
&& parent.left.type === AST_NODE_TYPES.Identifier) {
|
|
105
103
|
return parent.left.name;
|
|
106
104
|
}
|
|
107
|
-
return null;
|
|
108
105
|
}
|
|
109
106
|
function report(node) {
|
|
110
|
-
|
|
111
|
-
if (filenameAllowed(filename)) {
|
|
107
|
+
if (filenameAllowed(context.filename)) {
|
|
112
108
|
return;
|
|
113
109
|
}
|
|
114
110
|
const targetName = getAssignmentTargetName(node);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-level-functions.d.ts","sourceRoot":"","sources":["../../src/rules/top-level-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAEpE,QAAA,MAAM,iBAAiB;;CA8NrB,CAAC;AACH,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-in-dts.d.ts","sourceRoot":"","sources":["../../src/rules/types-in-dts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AASpE,QAAA,MAAM,UAAU;;;;;CAmGd,CAAC;AACH,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-th-rules",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "A List of custom ESLint rules created by Tomer Horowitz",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
|
62
62
|
"@typescript-eslint/parser": "^8.53.0",
|
|
63
63
|
"@typescript-eslint/rule-tester": "^8.53.0",
|
|
64
|
+
"@typescript-eslint/utils": "^8.53.0",
|
|
64
65
|
"bun-types": "latest",
|
|
65
66
|
"eslint": "^9.39.2",
|
|
66
67
|
"eslint-doc-generator": "^3.0.2",
|