|
1 | | -// eslint.ts |
2 | | -var templateIndentAnnotations = [ |
3 | | - "outdent", |
4 | | - "dedent", |
5 | | - "html", |
6 | | - "tsx", |
7 | | - "ts" |
| 1 | +import js from "@eslint/js"; |
| 2 | +import stylistic from "@stylistic/eslint-plugin"; |
| 3 | +import pluginDeMorgan from "eslint-plugin-de-morgan"; |
| 4 | +import pluginJsdoc from "eslint-plugin-jsdoc"; |
| 5 | +import pluginPerfectionist from "eslint-plugin-perfectionist"; |
| 6 | +import pluginRegexp from "eslint-plugin-regexp"; |
| 7 | +import pluginSimpleImportSort from "eslint-plugin-simple-import-sort"; |
| 8 | +import pluginUnicorn from "eslint-plugin-unicorn"; |
| 9 | +import tseslint from "typescript-eslint"; |
| 10 | +const GLOB_TS = ["*.{ts,tsx,cts,mts}", "**/*.{ts,tsx,cts,mts}"]; |
| 11 | +const templateIndentAnnotations = [ |
| 12 | + "outdent", |
| 13 | + "dedent", |
| 14 | + "html", |
| 15 | + "tsx", |
| 16 | + "ts", |
8 | 17 | ]; |
9 | | -var p11tOptions = { |
10 | | - type: "natural", |
11 | | - ignoreCase: false |
| 18 | +const p11tOptions = { |
| 19 | + type: "natural", |
| 20 | + ignoreCase: false, |
12 | 21 | }; |
13 | | -var p11tGroups = { |
14 | | - customGroups: { |
15 | | - id: ["^_$", "^id$", "^key$", "^self$"], |
16 | | - type: ["^type$", "^kind$"], |
17 | | - meta: [ |
18 | | - "^name$", |
19 | | - "^meta$", |
20 | | - "^title$", |
21 | | - "^description$" |
22 | | - ], |
23 | | - alias: ["^alias$", "^as$"], |
24 | | - rules: ["^node$", "^messageId$"] |
25 | | - }, |
26 | | - groups: ["id", "type", "meta", "alias", "rules", "unknown"] |
| 22 | +const p11tGroups = { |
| 23 | + customGroups: { |
| 24 | + id: ["^_$", "^id$", "^key$", "^self$"], |
| 25 | + type: ["^type$", "^kind$"], |
| 26 | + meta: [ |
| 27 | + "^name$", |
| 28 | + "^meta$", |
| 29 | + "^title$", |
| 30 | + "^description$", |
| 31 | + ], |
| 32 | + alias: ["^alias$", "^as$"], |
| 33 | + rules: ["^node$", "^messageId$"], |
| 34 | + }, |
| 35 | + groups: ["id", "type", "meta", "alias", "rules", "unknown"], |
27 | 36 | }; |
28 | | -var typescript = { |
29 | | - rules: { |
30 | | - eqeqeq: ["error", "smart"], |
31 | | - "no-console": "error", |
32 | | - "no-else-return": "error", |
33 | | - "no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }], |
34 | | - "no-implicit-coercion": ["error", { allow: ["!!"] }], |
35 | | - "no-mixed-operators": "warn", |
36 | | - "no-undef": "off", |
37 | | - "prefer-object-has-own": "error", |
38 | | - // Part: custom rules |
39 | | - "no-restricted-syntax": [ |
40 | | - "error", |
41 | | - { |
42 | | - message: "no optional", |
43 | | - selector: "TSPropertySignature[optional=true]" |
44 | | - } |
45 | | - ], |
46 | | - // Part: typescript-eslint rules |
47 | | - "@typescript-eslint/ban-ts-comment": [ |
48 | | - "error", |
49 | | - { |
50 | | - minimumDescriptionLength: 5, |
51 | | - "ts-check": false, |
52 | | - "ts-expect-error": "allow-with-description", |
53 | | - "ts-ignore": true, |
54 | | - "ts-nocheck": true |
55 | | - } |
56 | | - ], |
57 | | - "@typescript-eslint/ban-types": "off", |
58 | | - "@typescript-eslint/consistent-type-exports": "error", |
59 | | - "@typescript-eslint/consistent-type-imports": "error", |
60 | | - "@typescript-eslint/explicit-function-return-type": "off", |
61 | | - "@typescript-eslint/no-empty-object-type": "off", |
62 | | - "@typescript-eslint/no-misused-promises": "off", |
63 | | - "@typescript-eslint/no-namespace": "off", |
64 | | - "@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn", |
65 | | - "@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }], |
66 | | - "@typescript-eslint/strict-boolean-expressions": ["error", { |
67 | | - allowAny: false, |
68 | | - allowNullableBoolean: false, |
69 | | - allowNullableEnum: false, |
70 | | - allowNullableNumber: false, |
71 | | - allowNullableObject: false, |
72 | | - allowNullableString: false, |
73 | | - allowNumber: true, |
74 | | - allowString: false |
75 | | - }], |
76 | | - // Part: jsdoc rules |
77 | | - "jsdoc/check-param-names": "warn", |
78 | | - "jsdoc/check-tag-names": "warn", |
79 | | - "jsdoc/informative-docs": "off", |
80 | | - "jsdoc/lines-before-block": "off", |
81 | | - "jsdoc/require-jsdoc": "off", |
82 | | - "jsdoc/require-param": "warn", |
83 | | - "jsdoc/require-param-description": "warn", |
84 | | - "jsdoc/require-returns": "off", |
85 | | - "jsdoc/require-yields": "warn", |
86 | | - "jsdoc/tag-lines": "off", |
87 | | - // Part: simple-import-sort rules |
88 | | - "simple-import-sort/exports": "warn", |
89 | | - "simple-import-sort/imports": "warn", |
90 | | - // Part: stylistic rules |
91 | | - "@stylistic/arrow-parens": ["warn", "always"], |
92 | | - "@stylistic/no-multi-spaces": ["warn"], |
93 | | - "@stylistic/operator-linebreak": [ |
94 | | - "warn", |
95 | | - "before" |
96 | | - ], |
97 | | - "@stylistic/quote-props": ["error", "as-needed"], |
98 | | - // Part: perfectionist rules |
99 | | - "perfectionist/sort-exports": "off", |
100 | | - "perfectionist/sort-imports": "off", |
101 | | - "perfectionist/sort-interfaces": [ |
102 | | - "warn", |
103 | | - { |
104 | | - ...p11tOptions, |
105 | | - ...p11tGroups |
106 | | - } |
| 37 | +export const typescript = tseslint.config({ |
| 38 | + extends: [ |
| 39 | + js.configs.recommended, |
| 40 | + ...tseslint.configs.strict, |
| 41 | + pluginDeMorgan.configs.recommended, |
| 42 | + pluginJsdoc.configs["flat/recommended-typescript-error"], |
| 43 | + pluginRegexp.configs["flat/recommended"], |
| 44 | + pluginPerfectionist.configs["recommended-natural"], |
107 | 45 | ], |
108 | | - "perfectionist/sort-intersection-types": "off", |
109 | | - "perfectionist/sort-modules": "off", |
110 | | - "perfectionist/sort-named-exports": "off", |
111 | | - "perfectionist/sort-named-imports": "off", |
112 | | - "perfectionist/sort-object-types": [ |
113 | | - "warn", |
114 | | - { |
115 | | - ...p11tOptions, |
116 | | - ...p11tGroups |
117 | | - } |
118 | | - ], |
119 | | - "perfectionist/sort-objects": [ |
120 | | - "warn", |
121 | | - { |
122 | | - ...p11tOptions, |
123 | | - ...p11tGroups, |
124 | | - partitionByComment: "^Part:.*" |
125 | | - } |
126 | | - ], |
127 | | - "perfectionist/sort-switch-case": "off", |
128 | | - "perfectionist/sort-union-types": "off", |
129 | | - // Part: unicorn rules |
130 | | - "unicorn/template-indent": [ |
131 | | - "warn", |
132 | | - { |
133 | | - comments: templateIndentAnnotations, |
134 | | - tags: templateIndentAnnotations |
135 | | - } |
136 | | - ] |
137 | | - } |
138 | | -}; |
139 | | - |
140 | | -export { typescript }; |
| 46 | + files: GLOB_TS, |
| 47 | + plugins: { |
| 48 | + ["@stylistic"]: stylistic, |
| 49 | + ["simple-import-sort"]: pluginSimpleImportSort, |
| 50 | + ["unicorn"]: pluginUnicorn, |
| 51 | + }, |
| 52 | + rules: { |
| 53 | + eqeqeq: ["error", "smart"], |
| 54 | + "no-console": "error", |
| 55 | + "no-else-return": "error", |
| 56 | + "no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }], |
| 57 | + "no-implicit-coercion": ["error", { allow: ["!!"] }], |
| 58 | + "no-mixed-operators": "warn", |
| 59 | + "no-undef": "off", |
| 60 | + "prefer-object-has-own": "error", |
| 61 | + // Part: custom rules |
| 62 | + "no-restricted-syntax": [ |
| 63 | + "error", |
| 64 | + { |
| 65 | + message: "no optional", |
| 66 | + selector: "TSPropertySignature[optional=true]", |
| 67 | + }, |
| 68 | + ], |
| 69 | + // Part: typescript-eslint rules |
| 70 | + "@typescript-eslint/ban-ts-comment": [ |
| 71 | + "error", |
| 72 | + { |
| 73 | + minimumDescriptionLength: 5, |
| 74 | + "ts-check": false, |
| 75 | + "ts-expect-error": "allow-with-description", |
| 76 | + "ts-ignore": true, |
| 77 | + "ts-nocheck": true, |
| 78 | + }, |
| 79 | + ], |
| 80 | + "@typescript-eslint/ban-types": "off", |
| 81 | + "@typescript-eslint/consistent-type-exports": "error", |
| 82 | + "@typescript-eslint/consistent-type-imports": "error", |
| 83 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 84 | + "@typescript-eslint/no-empty-object-type": "off", |
| 85 | + "@typescript-eslint/no-misused-promises": "off", |
| 86 | + "@typescript-eslint/no-namespace": "off", |
| 87 | + "@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn", |
| 88 | + "@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }], |
| 89 | + "@typescript-eslint/strict-boolean-expressions": ["error", { |
| 90 | + allowAny: false, |
| 91 | + allowNullableBoolean: false, |
| 92 | + allowNullableEnum: false, |
| 93 | + allowNullableNumber: false, |
| 94 | + allowNullableObject: false, |
| 95 | + allowNullableString: false, |
| 96 | + allowNumber: true, |
| 97 | + allowString: false, |
| 98 | + }], |
| 99 | + // Part: jsdoc rules |
| 100 | + "jsdoc/check-param-names": "warn", |
| 101 | + "jsdoc/check-tag-names": "warn", |
| 102 | + "jsdoc/informative-docs": "off", |
| 103 | + "jsdoc/lines-before-block": "off", |
| 104 | + "jsdoc/require-jsdoc": "off", |
| 105 | + "jsdoc/require-param": "warn", |
| 106 | + "jsdoc/require-param-description": "warn", |
| 107 | + "jsdoc/require-returns": "off", |
| 108 | + "jsdoc/require-yields": "warn", |
| 109 | + "jsdoc/tag-lines": "off", |
| 110 | + // Part: simple-import-sort rules |
| 111 | + "simple-import-sort/exports": "warn", |
| 112 | + "simple-import-sort/imports": "warn", |
| 113 | + // Part: stylistic rules |
| 114 | + "@stylistic/arrow-parens": ["warn", "always"], |
| 115 | + "@stylistic/no-multi-spaces": ["warn"], |
| 116 | + "@stylistic/operator-linebreak": [ |
| 117 | + "warn", |
| 118 | + "before", |
| 119 | + ], |
| 120 | + "@stylistic/quote-props": ["error", "as-needed"], |
| 121 | + // Part: perfectionist rules |
| 122 | + "perfectionist/sort-exports": "off", |
| 123 | + "perfectionist/sort-imports": "off", |
| 124 | + "perfectionist/sort-interfaces": [ |
| 125 | + "warn", |
| 126 | + { |
| 127 | + ...p11tOptions, |
| 128 | + ...p11tGroups, |
| 129 | + }, |
| 130 | + ], |
| 131 | + "perfectionist/sort-intersection-types": "off", |
| 132 | + "perfectionist/sort-modules": "off", |
| 133 | + "perfectionist/sort-named-exports": "off", |
| 134 | + "perfectionist/sort-named-imports": "off", |
| 135 | + "perfectionist/sort-object-types": [ |
| 136 | + "warn", |
| 137 | + { |
| 138 | + ...p11tOptions, |
| 139 | + ...p11tGroups, |
| 140 | + }, |
| 141 | + ], |
| 142 | + "perfectionist/sort-objects": [ |
| 143 | + "warn", |
| 144 | + { |
| 145 | + ...p11tOptions, |
| 146 | + ...p11tGroups, |
| 147 | + partitionByComment: "^Part:.*", |
| 148 | + }, |
| 149 | + ], |
| 150 | + "perfectionist/sort-switch-case": "off", |
| 151 | + "perfectionist/sort-union-types": "off", |
| 152 | + // Part: unicorn rules |
| 153 | + "unicorn/template-indent": [ |
| 154 | + "warn", |
| 155 | + { |
| 156 | + comments: templateIndentAnnotations, |
| 157 | + tags: templateIndentAnnotations, |
| 158 | + }, |
| 159 | + ], |
| 160 | + }, |
| 161 | +}); |
0 commit comments