@averay/codeformat 0.1.14 → 0.2.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/.editorconfig +1 -0
- package/.stylelintignore +1 -0
- package/CODE_OF_CONDUCT.md +83 -0
- package/README.md +2 -2
- package/bin-codeformat.sh +11 -7
- package/eslint.config.js +2 -2
- package/lib/convertWarnsToErrors.ts +43 -0
- package/package.json +36 -45
- package/rulesets/eslint/ruleset-shared.ts +346 -0
- package/rulesets/eslint/ruleset-typescript.ts +226 -0
- package/rulesets/stylelint/ruleset-css.ts +22 -0
- package/rulesets/stylelint/ruleset-scss.ts +33 -0
- package/src/extensions.ts +7 -0
- package/src/index.ts +4 -0
- package/src/makeEslintConfig.ts +98 -0
- package/src/makeStylelintConfig.ts +37 -0
- package/stylelint.config.cjs +1 -1
- package/tsconfig.base.json +28 -0
- package/tsconfig.json +10 -0
- package/types.d.ts +97 -0
- package/dist/codeformat.cjs +0 -792
- package/dist/codeformat.cjs.map +0 -1
- package/dist/codeformat.mjs +0 -753
- package/dist/codeformat.mjs.map +0 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/* eslint unicorn/no-useless-spread: "off" -- Keep the unprefixed core rules together. */
|
|
2
|
+
/* eslint sort-keys: "error" -- Organise rules */
|
|
3
|
+
|
|
4
|
+
import js from '@eslint/js';
|
|
5
|
+
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
6
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
7
|
+
import importPlugin from 'eslint-plugin-import';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
...js.configs.recommended.rules,
|
|
11
|
+
...importPlugin.configs.typescript.rules,
|
|
12
|
+
...typescriptPlugin.configs['eslint-recommended']?.rules,
|
|
13
|
+
...typescriptPlugin.configs['recommended']?.rules,
|
|
14
|
+
...typescriptPlugin.configs['recommended-requiring-type-checking']?.rules,
|
|
15
|
+
...typescriptPlugin.configs['strict']?.rules,
|
|
16
|
+
|
|
17
|
+
...{
|
|
18
|
+
'array-callback-return': 'off',
|
|
19
|
+
'consistent-return': 'off',
|
|
20
|
+
'default-case': 'off',
|
|
21
|
+
'default-param-last': 'off',
|
|
22
|
+
'dot-notation': 'off',
|
|
23
|
+
'lines-between-class-members': 'off',
|
|
24
|
+
'no-array-constructor': 'off',
|
|
25
|
+
'no-dupe-class-members': 'off',
|
|
26
|
+
'no-duplicate-imports': 'off',
|
|
27
|
+
'no-empty-function': 'off',
|
|
28
|
+
'no-implied-eval': 'off',
|
|
29
|
+
'no-invalid-this': 'off',
|
|
30
|
+
'no-loop-func': 'off',
|
|
31
|
+
'no-loss-of-precision': 'off',
|
|
32
|
+
'no-magic-numbers': 'off',
|
|
33
|
+
'no-redeclare': 'off',
|
|
34
|
+
'no-restricted-imports': 'off',
|
|
35
|
+
'no-return-await': 'off',
|
|
36
|
+
'no-shadow': 'off',
|
|
37
|
+
'no-throw-literal': 'off',
|
|
38
|
+
'no-unused-expressions': 'off',
|
|
39
|
+
'no-unused-vars': 'off',
|
|
40
|
+
'no-use-before-define': 'off',
|
|
41
|
+
'no-useless-constructor': 'off',
|
|
42
|
+
'padding-line-between-statements': 'off',
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
46
|
+
'@typescript-eslint/array-type': 'error',
|
|
47
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
48
|
+
'@typescript-eslint/ban-ts-comment': 'error',
|
|
49
|
+
'@typescript-eslint/class-literal-property-style': 'off', // Breaks subclassed getters
|
|
50
|
+
'@typescript-eslint/consistent-indexed-object-style': 'error',
|
|
51
|
+
'@typescript-eslint/consistent-type-assertions': [
|
|
52
|
+
'error',
|
|
53
|
+
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' },
|
|
54
|
+
],
|
|
55
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
|
56
|
+
'@typescript-eslint/consistent-type-exports': ['error', { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
57
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
58
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
59
|
+
'@typescript-eslint/dot-notation': 'error',
|
|
60
|
+
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
|
|
61
|
+
'@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
|
|
62
|
+
'@typescript-eslint/explicit-module-boundary-types': ['error', { allowArgumentsExplicitlyTypedAsAny: true }],
|
|
63
|
+
'@typescript-eslint/member-ordering': 'off',
|
|
64
|
+
'@typescript-eslint/method-signature-style': 'off',
|
|
65
|
+
'@typescript-eslint/naming-convention': [
|
|
66
|
+
'error',
|
|
67
|
+
/* eslint-disable sort-keys -- Logically ordered */
|
|
68
|
+
{
|
|
69
|
+
selector: 'default',
|
|
70
|
+
format: ['camelCase'],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
selector: 'variable',
|
|
74
|
+
modifiers: ['const'],
|
|
75
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
selector: 'variable',
|
|
79
|
+
modifiers: ['const'],
|
|
80
|
+
filter: { regex: /^_(static|\d+)?$/u.source, match: true },
|
|
81
|
+
format: ['camelCase'],
|
|
82
|
+
leadingUnderscore: 'allow',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
selector: 'parameter',
|
|
86
|
+
format: ['camelCase'],
|
|
87
|
+
leadingUnderscore: 'allow',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
selector: 'property',
|
|
91
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
selector: 'classProperty',
|
|
95
|
+
modifiers: ['static'],
|
|
96
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
selector: 'enumMember',
|
|
100
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
selector: 'function',
|
|
104
|
+
format: ['camelCase', 'PascalCase'],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
selector: 'typeLike',
|
|
108
|
+
format: ['PascalCase'],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
selector: ['objectLiteralProperty'],
|
|
112
|
+
format: [],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
selector: ['classProperty', 'objectLiteralMethod'],
|
|
116
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
selector: 'typeParameter',
|
|
120
|
+
format: ['PascalCase'],
|
|
121
|
+
custom: { regex: /^([A-Z]|T[A-Z][a-zA-Z]+|key)$/u.source, match: true },
|
|
122
|
+
},
|
|
123
|
+
/* eslint-enable sort-keys -- Logically ordered */
|
|
124
|
+
],
|
|
125
|
+
'@typescript-eslint/no-array-constructor': 'error',
|
|
126
|
+
'@typescript-eslint/no-base-to-string': 'error',
|
|
127
|
+
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
|
|
128
|
+
'@typescript-eslint/no-confusing-void-expression': 'error',
|
|
129
|
+
'@typescript-eslint/no-dupe-class-members': 'error',
|
|
130
|
+
'@typescript-eslint/no-dynamic-delete': 'off',
|
|
131
|
+
'@typescript-eslint/no-empty-function': 'error',
|
|
132
|
+
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
|
|
133
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
134
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
135
|
+
'@typescript-eslint/no-extraneous-class': 'error',
|
|
136
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
137
|
+
'@typescript-eslint/no-for-in-array': 'error',
|
|
138
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
139
|
+
'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
|
|
140
|
+
'@typescript-eslint/no-invalid-this': 'error',
|
|
141
|
+
'@typescript-eslint/no-invalid-void-type': 'error',
|
|
142
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
143
|
+
'@typescript-eslint/no-loss-of-precision': 'error',
|
|
144
|
+
'@typescript-eslint/no-magic-numbers': [
|
|
145
|
+
'error',
|
|
146
|
+
{
|
|
147
|
+
detectObjects: true,
|
|
148
|
+
enforceConst: true,
|
|
149
|
+
ignore: [-1, 0, 1],
|
|
150
|
+
ignoreArrayIndexes: true,
|
|
151
|
+
ignoreClassFieldInitialValues: true,
|
|
152
|
+
ignoreDefaultValues: true,
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
'@typescript-eslint/no-meaningless-void-operator': 'error',
|
|
156
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
157
|
+
'@typescript-eslint/no-misused-promises': 'error',
|
|
158
|
+
'@typescript-eslint/no-namespace': 'error',
|
|
159
|
+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
|
160
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
161
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
162
|
+
'@typescript-eslint/no-redeclare': 'error',
|
|
163
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
164
|
+
'@typescript-eslint/no-restricted-imports': 'error',
|
|
165
|
+
'@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
|
|
166
|
+
'@typescript-eslint/no-this-alias': 'error',
|
|
167
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
|
168
|
+
'@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
|
|
169
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
|
170
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
|
171
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
172
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
|
173
|
+
'@typescript-eslint/no-unused-expressions': 'error',
|
|
174
|
+
'@typescript-eslint/no-unused-vars': [
|
|
175
|
+
'error',
|
|
176
|
+
{
|
|
177
|
+
argsIgnorePattern: /^_\w*$/u.source,
|
|
178
|
+
caughtErrorsIgnorePattern: /^_\w*$/u.source,
|
|
179
|
+
varsIgnorePattern: /^(_\d*|React)$/u.source,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
183
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
184
|
+
'@typescript-eslint/no-useless-empty-export': 'error',
|
|
185
|
+
'@typescript-eslint/no-var-requires': 'error',
|
|
186
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
|
|
187
|
+
'@typescript-eslint/only-throw-error': 'error',
|
|
188
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
189
|
+
'@typescript-eslint/prefer-enum-initializers': 'error',
|
|
190
|
+
'@typescript-eslint/prefer-for-of': 'error',
|
|
191
|
+
'@typescript-eslint/prefer-function-type': 'error',
|
|
192
|
+
'@typescript-eslint/prefer-includes': 'error',
|
|
193
|
+
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
|
194
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
195
|
+
'@typescript-eslint/prefer-nullish-coalescing': [
|
|
196
|
+
'error',
|
|
197
|
+
{ ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false },
|
|
198
|
+
],
|
|
199
|
+
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
200
|
+
'@typescript-eslint/prefer-readonly': 'error',
|
|
201
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
|
202
|
+
'@typescript-eslint/prefer-return-this-type': 'error',
|
|
203
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
|
204
|
+
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
|
205
|
+
'@typescript-eslint/promise-function-async': 'error',
|
|
206
|
+
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
207
|
+
'@typescript-eslint/restrict-plus-operands': 'error',
|
|
208
|
+
'@typescript-eslint/restrict-template-expressions': 'error',
|
|
209
|
+
'@typescript-eslint/return-await': 'error',
|
|
210
|
+
'@typescript-eslint/strict-boolean-expressions': [
|
|
211
|
+
'error',
|
|
212
|
+
{ allowNullableObject: false, allowNullableString: false, allowNumber: false, allowString: false },
|
|
213
|
+
],
|
|
214
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
215
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
216
|
+
'@typescript-eslint/unbound-method': 'off', // Does not support @autobind nor recognise binding in constructors
|
|
217
|
+
'@typescript-eslint/unified-signatures': 'off',
|
|
218
|
+
|
|
219
|
+
'jsdoc/no-types': 'error',
|
|
220
|
+
'jsdoc/require-param-type': 'off',
|
|
221
|
+
'jsdoc/require-returns-type': 'off',
|
|
222
|
+
} satisfies TSESLint.FlatConfig.Rules;
|
|
223
|
+
|
|
224
|
+
export const moduleDeclarations = {
|
|
225
|
+
'no-duplicate-imports': 'off', // Allow imports within multiple module declarations.
|
|
226
|
+
} satisfies TSESLint.FlatConfig.Rules;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* eslint sort-keys: "error" -- Organise rules. */
|
|
2
|
+
/* eslint unicorn/no-useless-spread: "off" -- Keep the unprefixed core rules together. */
|
|
3
|
+
|
|
4
|
+
import propertiesOrder from '@averay/css-properties-sort-order';
|
|
5
|
+
import recommended from 'stylelint-config-recommended';
|
|
6
|
+
import standard from 'stylelint-config-standard';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
...recommended.rules,
|
|
10
|
+
...standard.rules,
|
|
11
|
+
|
|
12
|
+
...{
|
|
13
|
+
'at-rule-empty-line-before': null,
|
|
14
|
+
'color-named': 'never',
|
|
15
|
+
'comment-empty-line-before': null,
|
|
16
|
+
'function-url-no-scheme-relative': true,
|
|
17
|
+
'rule-empty-line-before': null,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
'order/order': ['custom-properties', 'declarations'],
|
|
21
|
+
'order/properties-order': [propertiesOrder, { unspecified: 'bottomAlphabetical' }],
|
|
22
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint sort-keys: "error" -- Organise rules. */
|
|
2
|
+
/* eslint unicorn/no-useless-spread: "off" -- Keep the unprefixed core rules together. */
|
|
3
|
+
|
|
4
|
+
import recommended from 'stylelint-config-recommended-scss';
|
|
5
|
+
import standard from 'stylelint-config-standard-scss';
|
|
6
|
+
|
|
7
|
+
const CUSTOM_KEYWORD_PATTERN = /^_?[a-z][\da-z]*((-|--|__)[\da-z]+)*$/u;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
...recommended.rules,
|
|
11
|
+
...standard.rules,
|
|
12
|
+
|
|
13
|
+
// Disable Prettier-conflicting legacy rules.
|
|
14
|
+
...{
|
|
15
|
+
'scss/at-else-closing-brace-newline-after': null,
|
|
16
|
+
'scss/at-else-closing-brace-space-after': null,
|
|
17
|
+
'scss/at-else-empty-line-before': null,
|
|
18
|
+
'scss/at-else-if-parentheses-space-before': null,
|
|
19
|
+
'scss/at-function-parentheses-space-before': null,
|
|
20
|
+
'scss/at-if-closing-brace-newline-after': null,
|
|
21
|
+
'scss/at-if-closing-brace-space-after': null,
|
|
22
|
+
'scss/at-mixin-parentheses-space-before': null,
|
|
23
|
+
'scss/dollar-variable-colon-newline-after': null,
|
|
24
|
+
'scss/dollar-variable-colon-space-after': null,
|
|
25
|
+
'scss/dollar-variable-colon-space-before': null,
|
|
26
|
+
'scss/operator-no-newline-after': null,
|
|
27
|
+
'scss/operator-no-newline-before': null,
|
|
28
|
+
'scss/operator-no-unspaced': null,
|
|
29
|
+
},
|
|
30
|
+
'scss/at-function-pattern': CUSTOM_KEYWORD_PATTERN.source,
|
|
31
|
+
'scss/at-mixin-pattern': CUSTOM_KEYWORD_PATTERN.source,
|
|
32
|
+
'scss/dollar-variable-pattern': CUSTOM_KEYWORD_PATTERN.source,
|
|
33
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* eslint sort-keys: "error" -- Organise rules */
|
|
2
|
+
|
|
3
|
+
import stylisticPlugin from '@stylistic/eslint-plugin';
|
|
4
|
+
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
5
|
+
import typescriptParser from '@typescript-eslint/parser';
|
|
6
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
7
|
+
import prettierConfig from 'eslint-config-prettier';
|
|
8
|
+
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
|
|
9
|
+
import importPlugin from 'eslint-plugin-import';
|
|
10
|
+
import jsdocPlugin from 'eslint-plugin-jsdoc';
|
|
11
|
+
import promisePlugin from 'eslint-plugin-promise';
|
|
12
|
+
import regexpPlugin from 'eslint-plugin-regexp';
|
|
13
|
+
import sonarjsPlugin from 'eslint-plugin-sonarjs';
|
|
14
|
+
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
15
|
+
|
|
16
|
+
import convertWarnsToErrors from '../lib/convertWarnsToErrors.ts';
|
|
17
|
+
import rulesetEslintShared from '../rulesets/eslint/ruleset-shared.ts';
|
|
18
|
+
import rulesetEslintTypescript, {
|
|
19
|
+
moduleDeclarations as rulesetEslintTypescriptModuleDeclarations,
|
|
20
|
+
} from '../rulesets/eslint/ruleset-typescript.ts';
|
|
21
|
+
|
|
22
|
+
import extensions from './extensions.ts';
|
|
23
|
+
|
|
24
|
+
interface Options {
|
|
25
|
+
/** The ECMA version to use. */
|
|
26
|
+
ecmaVersion?: TSESLint.FlatConfig.EcmaVersion;
|
|
27
|
+
/** The relative path to the project's `tsconfig.json` file. */
|
|
28
|
+
tsconfigPath?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param options Project-specific customisations.
|
|
33
|
+
* @returns The complete ESLint config.
|
|
34
|
+
*/
|
|
35
|
+
export default function makeEslintConfig({
|
|
36
|
+
ecmaVersion = 'latest',
|
|
37
|
+
tsconfigPath,
|
|
38
|
+
}: Options = {}): TSESLint.FlatConfig.Config[] {
|
|
39
|
+
return [
|
|
40
|
+
// JavaScript & TypeScript
|
|
41
|
+
{
|
|
42
|
+
files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
|
|
43
|
+
languageOptions: {
|
|
44
|
+
parserOptions: {
|
|
45
|
+
ecmaVersion,
|
|
46
|
+
sourceType: 'module',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
linterOptions: {
|
|
50
|
+
reportUnusedDisableDirectives: true,
|
|
51
|
+
},
|
|
52
|
+
plugins: {
|
|
53
|
+
'@stylistic': stylisticPlugin,
|
|
54
|
+
'eslint-comments': eslintCommentsPlugin,
|
|
55
|
+
import: importPlugin,
|
|
56
|
+
jsdoc: jsdocPlugin,
|
|
57
|
+
promise: promisePlugin,
|
|
58
|
+
regexp: regexpPlugin,
|
|
59
|
+
sonarjs: sonarjsPlugin,
|
|
60
|
+
unicorn: unicornPlugin,
|
|
61
|
+
},
|
|
62
|
+
rules: convertWarnsToErrors(rulesetEslintShared),
|
|
63
|
+
settings: {
|
|
64
|
+
'import/parsers': {
|
|
65
|
+
espree: extensions.js.map((extension) => `.${extension}`),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
// TypeScript
|
|
71
|
+
{
|
|
72
|
+
files: [`**/*.{${extensions.ts.join(',')}}`],
|
|
73
|
+
languageOptions: {
|
|
74
|
+
parser: typescriptParser,
|
|
75
|
+
parserOptions: tsconfigPath == null ? {} : { project: tsconfigPath },
|
|
76
|
+
},
|
|
77
|
+
plugins: {
|
|
78
|
+
'@typescript-eslint': typescriptPlugin,
|
|
79
|
+
},
|
|
80
|
+
rules: convertWarnsToErrors(rulesetEslintTypescript),
|
|
81
|
+
settings: {
|
|
82
|
+
...importPlugin.configs.typescript.settings,
|
|
83
|
+
'import/parsers': {
|
|
84
|
+
'@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
|
|
85
|
+
},
|
|
86
|
+
'import/resolver': {
|
|
87
|
+
'eslint-import-resolver-typescript': tsconfigPath == null ? {} : { project: tsconfigPath },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
files: ['**/*.d.ts'],
|
|
93
|
+
rules: rulesetEslintTypescriptModuleDeclarations,
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
prettierConfig,
|
|
97
|
+
];
|
|
98
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint sort-keys: "error" -- Organise rules */
|
|
2
|
+
|
|
3
|
+
import postcssScss from 'postcss-scss';
|
|
4
|
+
import { type Config } from 'stylelint';
|
|
5
|
+
import orderPlugin from 'stylelint-order';
|
|
6
|
+
import scssPlugin from 'stylelint-scss';
|
|
7
|
+
|
|
8
|
+
import rulesetStylelintCss from '../rulesets/stylelint/ruleset-css.ts';
|
|
9
|
+
import rulesetStylelintScss from '../rulesets/stylelint/ruleset-scss.ts';
|
|
10
|
+
|
|
11
|
+
import extensions from './extensions.ts';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @returns The complete Stylelint config.
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type,@typescript-eslint/explicit-module-boundary-types -- Preserve specific object shape.
|
|
17
|
+
export default function makeStylelintConfig() {
|
|
18
|
+
return {
|
|
19
|
+
defaultSeverity: 'error',
|
|
20
|
+
ignoreFiles: ['**/*.min.*'],
|
|
21
|
+
plugins: [orderPlugin],
|
|
22
|
+
reportDescriptionlessDisables: true,
|
|
23
|
+
reportInvalidScopeDisables: true,
|
|
24
|
+
reportNeedlessDisables: true,
|
|
25
|
+
rules: rulesetStylelintCss,
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line sort-keys -- Logically positioned.
|
|
28
|
+
overrides: [
|
|
29
|
+
{
|
|
30
|
+
customSyntax: postcssScss,
|
|
31
|
+
files: extensions.scss.map((ext) => `**/*.${ext}`), // Does not support glob braces
|
|
32
|
+
plugins: [scssPlugin],
|
|
33
|
+
rules: rulesetStylelintScss,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
} satisfies Config;
|
|
37
|
+
}
|
package/stylelint.config.cjs
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Output
|
|
4
|
+
"noEmit": true,
|
|
5
|
+
// Module resolution
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"moduleResolution": "Bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
// Type checking
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"allowUnreachableCode": false,
|
|
16
|
+
"allowUnusedLabels": false,
|
|
17
|
+
"checkJs": true,
|
|
18
|
+
"exactOptionalPropertyTypes": false,
|
|
19
|
+
"noImplicitOverride": true,
|
|
20
|
+
"noImplicitReturns": true,
|
|
21
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
22
|
+
"noUncheckedIndexedAccess": true,
|
|
23
|
+
"noUnusedLocals": true,
|
|
24
|
+
"noUnusedParameters": true,
|
|
25
|
+
"skipLibCheck": true,
|
|
26
|
+
"strict": true
|
|
27
|
+
}
|
|
28
|
+
}
|
package/tsconfig.json
ADDED
package/types.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
declare module '@stylistic/eslint-plugin' {
|
|
2
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
3
|
+
|
|
4
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
5
|
+
configs: Record<'recommended-flat', TSESLint.FlatConfig.Config>;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module 'eslint-config-prettier' {
|
|
10
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
11
|
+
|
|
12
|
+
export default {} as TSESLint.FlatConfig.Config;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module 'eslint-plugin-eslint-comments' {
|
|
16
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
17
|
+
|
|
18
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
19
|
+
configs: Record<'recommended', TSESLint.FlatConfig.Config>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module 'eslint-plugin-import' {
|
|
24
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
25
|
+
|
|
26
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
27
|
+
configs: Record<'recommended' | 'react' | 'react-native' | 'electron' | 'typescript', TSESLint.FlatConfig.Config>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module 'eslint-plugin-jsdoc' {
|
|
32
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
33
|
+
|
|
34
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
35
|
+
configs: Record<'recommended', TSESLint.FlatConfig.Config>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module 'eslint-plugin-promise' {
|
|
40
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
41
|
+
|
|
42
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
43
|
+
configs: Record<'recommended', TSESLint.FlatConfig.Config>;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare module 'eslint-plugin-sonarjs' {
|
|
48
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
49
|
+
|
|
50
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
51
|
+
configs: Record<'recommended', TSESLint.FlatConfig.Config>;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare module 'eslint-plugin-unicorn' {
|
|
56
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
57
|
+
|
|
58
|
+
export default {} as TSESLint.FlatConfig.Plugin & {
|
|
59
|
+
configs: Record<'recommended', TSESLint.FlatConfig.Config>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module 'stylelint-config-recommended' {
|
|
64
|
+
import { type Config } from 'stylelint';
|
|
65
|
+
|
|
66
|
+
export default {} as Config;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare module 'stylelint-config-recommended-scss' {
|
|
70
|
+
import { type Config } from 'stylelint';
|
|
71
|
+
|
|
72
|
+
export default {} as Config;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare module 'stylelint-config-standard' {
|
|
76
|
+
import { type Config } from 'stylelint';
|
|
77
|
+
|
|
78
|
+
export default {} as Config;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare module 'stylelint-config-standard-scss' {
|
|
82
|
+
import { type Config } from 'stylelint';
|
|
83
|
+
|
|
84
|
+
export default {} as Config;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare module 'stylelint-order' {
|
|
88
|
+
import { type Plugin } from 'stylelint';
|
|
89
|
+
|
|
90
|
+
export default {} as Plugin;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare module 'stylelint-scss' {
|
|
94
|
+
import { type Plugin } from 'stylelint';
|
|
95
|
+
|
|
96
|
+
export default {} as Plugin;
|
|
97
|
+
}
|