@averay/codeformat 0.2.10 → 0.2.11

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.
Files changed (50) hide show
  1. package/README.md +12 -2
  2. package/dist/bin/tools/knip.js +3 -2
  3. package/dist/bin/tools/knip.js.map +1 -1
  4. package/dist/rulesets/eslint/ruleset-shared.d.ts +1 -1
  5. package/dist/rulesets/eslint/ruleset-shared.js +1 -2
  6. package/dist/rulesets/eslint/ruleset-shared.js.map +1 -1
  7. package/dist/src/index.d.ts +1 -0
  8. package/dist/src/index.js +1 -0
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/makePrettierConfig.d.ts +12 -0
  11. package/dist/src/makePrettierConfig.js +24 -0
  12. package/dist/src/makePrettierConfig.js.map +1 -0
  13. package/package.json +13 -11
  14. package/.php-cs-fixer.cache +0 -1
  15. package/.php-cs-fixer.php +0 -9
  16. package/.prettierrc.json +0 -8
  17. package/.stylelintignore +0 -3
  18. package/CODE_OF_CONDUCT.md +0 -83
  19. package/bin/codeformat.ts +0 -27
  20. package/bin/tools/eslint.ts +0 -17
  21. package/bin/tools/index.ts +0 -6
  22. package/bin/tools/knip.ts +0 -21
  23. package/bin/tools/phpCsFixer.ts +0 -16
  24. package/bin/tools/prettier.ts +0 -20
  25. package/bin/tools/stylelint.ts +0 -16
  26. package/bin/tools/tsc.ts +0 -12
  27. package/bin/utils/Cli.ts +0 -80
  28. package/bin/utils/Output.ts +0 -30
  29. package/bin/utils/ToolRunner.ts +0 -64
  30. package/bin/utils/filesystem.ts +0 -22
  31. package/bin/utils/runners.ts +0 -10
  32. package/bin/utils/types.ts +0 -24
  33. package/composer.json +0 -6
  34. package/composer.lock +0 -3507
  35. package/eslint.config.js +0 -34
  36. package/knip.config.ts +0 -18
  37. package/lib/convertWarnsToErrors.ts +0 -43
  38. package/lib/cssPatterns.ts +0 -20
  39. package/rulesets/eslint/ruleset-shared.ts +0 -362
  40. package/rulesets/eslint/ruleset-typescript.ts +0 -239
  41. package/rulesets/php/ruleset-php-cs-fixer.php +0 -93
  42. package/rulesets/stylelint/ruleset-css.ts +0 -39
  43. package/rulesets/stylelint/ruleset-scss.ts +0 -47
  44. package/src/extensions.ts +0 -7
  45. package/src/index.ts +0 -4
  46. package/src/makeEslintConfig.ts +0 -97
  47. package/src/makeStylelintConfig.ts +0 -46
  48. package/stylelint.config.js +0 -7
  49. package/tsconfig.build.json +0 -13
  50. /package/{src → dist/src}/php/PhpCsFixerConfig.php +0 -0
@@ -1,239 +0,0 @@
1
- import js from '@eslint/js';
2
- import typescriptPlugin from '@typescript-eslint/eslint-plugin';
3
- import type { TSESLint } from '@typescript-eslint/utils';
4
- import { importX as importXPlugin } from 'eslint-plugin-import-x';
5
-
6
- export default {
7
- ...js.configs.recommended.rules,
8
- ...importXPlugin.configs.typescript.rules,
9
- ...typescriptPlugin.configs['eslint-recommended']?.rules,
10
- ...typescriptPlugin.configs['recommended']?.rules,
11
- ...typescriptPlugin.configs['recommended-requiring-type-checking']?.rules,
12
- ...typescriptPlugin.configs['strict']?.rules,
13
-
14
- ...{
15
- 'array-callback-return': 'off',
16
- 'consistent-return': 'off',
17
- 'default-case': 'off',
18
- 'default-param-last': 'off',
19
- 'dot-notation': 'off',
20
- 'lines-between-class-members': 'off',
21
- 'no-array-constructor': 'off',
22
- 'no-dupe-class-members': 'off',
23
- 'no-duplicate-imports': 'off',
24
- 'no-empty-function': 'off',
25
- 'no-implied-eval': 'off',
26
- 'no-invalid-this': 'off',
27
- 'no-loop-func': 'off',
28
- 'no-loss-of-precision': 'off',
29
- 'no-magic-numbers': 'off',
30
- 'no-redeclare': 'off',
31
- 'no-restricted-imports': 'off',
32
- 'no-restricted-syntax': ['error', 'WithStatement'],
33
- 'no-return-await': 'off',
34
- 'no-shadow': 'off',
35
- 'no-throw-literal': 'off',
36
- 'no-unused-expressions': 'off',
37
- 'no-unused-vars': 'off',
38
- 'no-use-before-define': 'off',
39
- 'no-useless-constructor': 'off',
40
- 'padding-line-between-statements': 'off',
41
- },
42
-
43
- '@typescript-eslint/adjacent-overload-signatures': 'error',
44
- '@typescript-eslint/array-type': 'error',
45
- '@typescript-eslint/await-thenable': 'error',
46
- '@typescript-eslint/ban-ts-comment': 'error',
47
- '@typescript-eslint/class-literal-property-style': 'off', // Breaks subclassed getters
48
- '@typescript-eslint/consistent-indexed-object-style': 'error',
49
- '@typescript-eslint/consistent-type-assertions': [
50
- 'error',
51
- { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' },
52
- ],
53
- '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
54
- '@typescript-eslint/consistent-type-exports': ['error', { fixMixedExportsWithInlineTypeSpecifier: true }],
55
- '@typescript-eslint/consistent-type-imports': 'error',
56
- '@typescript-eslint/default-param-last': 'error',
57
- '@typescript-eslint/dot-notation': 'error',
58
- '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
59
- '@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
60
- '@typescript-eslint/explicit-module-boundary-types': ['error', { allowArgumentsExplicitlyTypedAsAny: true }],
61
- '@typescript-eslint/member-ordering': 'off',
62
- '@typescript-eslint/method-signature-style': 'off',
63
- '@typescript-eslint/naming-convention': [
64
- 'error',
65
- /* eslint-disable sort-keys -- Logically ordered */
66
- {
67
- selector: 'default',
68
- format: ['strictCamelCase'],
69
- },
70
- {
71
- selector: 'import',
72
- format: null,
73
- },
74
- {
75
- selector: 'variable',
76
- modifiers: ['const'],
77
- format: ['strictCamelCase', 'StrictPascalCase', 'UPPER_CASE'],
78
- },
79
- {
80
- selector: 'variable',
81
- modifiers: ['const'],
82
- filter: { regex: /^_(static|\d+)?$/u.source, match: true },
83
- format: ['strictCamelCase'],
84
- leadingUnderscore: 'allow',
85
- },
86
- {
87
- selector: 'parameter',
88
- format: ['strictCamelCase'],
89
- leadingUnderscore: 'allow',
90
- },
91
- {
92
- selector: 'property',
93
- format: ['strictCamelCase', 'UPPER_CASE'],
94
- },
95
- {
96
- selector: 'classProperty',
97
- modifiers: ['static'],
98
- format: ['strictCamelCase', 'StrictPascalCase', 'UPPER_CASE'],
99
- },
100
- {
101
- selector: 'enumMember',
102
- format: ['strictCamelCase', 'StrictPascalCase', 'UPPER_CASE'],
103
- },
104
- {
105
- selector: 'function',
106
- format: ['strictCamelCase', 'StrictPascalCase'],
107
- },
108
- {
109
- selector: 'typeLike',
110
- format: ['StrictPascalCase'],
111
- },
112
- {
113
- selector: ['objectLiteralProperty'],
114
- format: null,
115
- },
116
- {
117
- selector: ['classProperty', 'objectLiteralMethod'],
118
- format: ['strictCamelCase', 'UPPER_CASE'],
119
- },
120
- {
121
- selector: 'typeParameter',
122
- format: null,
123
- custom: { regex: /^([A-Z]|T[A-Z][a-zA-Z]+|key)$/u.source, match: true },
124
- },
125
- /* eslint-enable sort-keys -- Logically ordered */
126
- ],
127
- '@typescript-eslint/no-array-constructor': 'error',
128
- '@typescript-eslint/no-base-to-string': 'error',
129
- '@typescript-eslint/no-confusing-non-null-assertion': 'error',
130
- '@typescript-eslint/no-confusing-void-expression': 'error',
131
- '@typescript-eslint/no-dupe-class-members': 'error',
132
- '@typescript-eslint/no-dynamic-delete': 'off',
133
- '@typescript-eslint/no-empty-function': 'error',
134
- '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
135
- '@typescript-eslint/no-explicit-any': 'off',
136
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
137
- '@typescript-eslint/no-extraneous-class': 'error',
138
- '@typescript-eslint/no-floating-promises': 'error',
139
- '@typescript-eslint/no-for-in-array': 'error',
140
- '@typescript-eslint/no-implied-eval': 'error',
141
- '@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
142
- '@typescript-eslint/no-invalid-this': 'error',
143
- '@typescript-eslint/no-invalid-void-type': 'error',
144
- '@typescript-eslint/no-loop-func': 'error',
145
- '@typescript-eslint/no-loss-of-precision': 'error',
146
- '@typescript-eslint/no-magic-numbers': [
147
- 'error',
148
- {
149
- detectObjects: true,
150
- enforceConst: true,
151
- ignore: [-1, 0, 1, 2, 100, '0n'],
152
- ignoreArrayIndexes: true,
153
- ignoreClassFieldInitialValues: true,
154
- ignoreDefaultValues: true,
155
- },
156
- ],
157
- '@typescript-eslint/no-meaningless-void-operator': 'error',
158
- '@typescript-eslint/no-misused-new': 'error',
159
- '@typescript-eslint/no-misused-promises': 'error',
160
- '@typescript-eslint/no-namespace': 'error',
161
- '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
162
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
163
- '@typescript-eslint/no-non-null-assertion': 'error',
164
- '@typescript-eslint/no-redeclare': 'error',
165
- '@typescript-eslint/no-require-imports': 'error',
166
- '@typescript-eslint/no-restricted-imports': 'error',
167
- '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
168
- '@typescript-eslint/no-this-alias': 'error',
169
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
170
- '@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
171
- '@typescript-eslint/no-unnecessary-qualifier': 'error',
172
- '@typescript-eslint/no-unnecessary-type-arguments': 'error',
173
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
174
- '@typescript-eslint/no-unnecessary-type-constraint': 'error',
175
- '@typescript-eslint/no-unused-expressions': 'error',
176
- '@typescript-eslint/no-unused-vars': [
177
- 'error',
178
- {
179
- argsIgnorePattern: /^_\w*$/u.source,
180
- caughtErrorsIgnorePattern: /^_\w*$/u.source,
181
- varsIgnorePattern: /^(_\d*|React)$/u.source,
182
- },
183
- ],
184
- '@typescript-eslint/no-use-before-define': 'error',
185
- '@typescript-eslint/no-useless-constructor': 'error',
186
- '@typescript-eslint/no-useless-empty-export': 'error',
187
- '@typescript-eslint/no-var-requires': 'error',
188
- '@typescript-eslint/non-nullable-type-assertion-style': 'error',
189
- '@typescript-eslint/only-throw-error': 'error',
190
- '@typescript-eslint/prefer-as-const': 'error',
191
- '@typescript-eslint/prefer-enum-initializers': 'error',
192
- '@typescript-eslint/prefer-for-of': 'error',
193
- '@typescript-eslint/prefer-function-type': 'error',
194
- '@typescript-eslint/prefer-includes': 'error',
195
- '@typescript-eslint/prefer-literal-enum-member': 'error',
196
- '@typescript-eslint/prefer-namespace-keyword': 'error',
197
- '@typescript-eslint/prefer-nullish-coalescing': [
198
- 'error',
199
- { ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false },
200
- ],
201
- '@typescript-eslint/prefer-optional-chain': 'error',
202
- '@typescript-eslint/prefer-readonly': 'error',
203
- '@typescript-eslint/prefer-reduce-type-parameter': 'error',
204
- '@typescript-eslint/prefer-return-this-type': 'error',
205
- '@typescript-eslint/prefer-string-starts-ends-with': 'error',
206
- '@typescript-eslint/prefer-ts-expect-error': 'error',
207
- '@typescript-eslint/promise-function-async': 'error',
208
- '@typescript-eslint/require-array-sort-compare': 'error',
209
- '@typescript-eslint/restrict-plus-operands': 'error',
210
- '@typescript-eslint/restrict-template-expressions': 'error',
211
- '@typescript-eslint/return-await': 'error',
212
- '@typescript-eslint/strict-boolean-expressions': [
213
- 'error',
214
- { allowNullableObject: false, allowNullableString: false, allowNumber: false, allowString: false },
215
- ],
216
- '@typescript-eslint/switch-exhaustiveness-check': [
217
- 'error',
218
- {
219
- allowDefaultCaseForExhaustiveSwitch: false,
220
- considerDefaultExhaustiveForUnions: true,
221
- requireDefaultForNonUnion: true,
222
- },
223
- ],
224
- '@typescript-eslint/triple-slash-reference': 'error',
225
- '@typescript-eslint/unbound-method': 'off', // Does not support @autobind nor recognise binding in constructors
226
- '@typescript-eslint/unified-signatures': 'off',
227
-
228
- 'import-x/no-unresolved': 'off', // Validated by TypeScript itself and causes issues with some type-generating frameworks
229
-
230
- 'jsdoc/no-types': 'error',
231
- 'jsdoc/require-param-type': 'off',
232
- 'jsdoc/require-returns-type': 'off',
233
-
234
- 'sonarjs/super-invocation': 'off', // Causes issues and is enforced by TypeScript already.
235
- } satisfies TSESLint.FlatConfig.Rules;
236
-
237
- export const moduleDeclarations = {
238
- 'no-duplicate-imports': 'off', // Allow imports within multiple module declarations.
239
- } satisfies TSESLint.FlatConfig.Rules;
@@ -1,93 +0,0 @@
1
- <?php
2
- declare(strict_types=1);
3
-
4
- $base = [
5
- '@PhpCsFixer' => true,
6
- '@Symfony' => true,
7
- ];
8
-
9
- $prettier = [
10
- 'array_indentation' => false,
11
- 'array_syntax' => false,
12
- 'blank_line_before_statement' => false,
13
- 'braces_position' => false,
14
- 'cast_spaces' => false,
15
- 'class_definition' => false,
16
- 'compact_nullable_type_declaration' => false,
17
- 'concat_space' => false,
18
- 'constant_case' => false,
19
- 'control_structure_braces' => false,
20
- 'control_structure_continuation_position' => false,
21
- 'declare_parentheses' => false,
22
- 'function_declaration' => ['closure_fn_spacing' => 'none'],
23
- 'heredoc_indentation' => ['indentation' => 'same_as_start'],
24
- 'indentation_type' => false,
25
- 'line_ending' => false,
26
- 'lowercase_cast' => false,
27
- 'lowercase_keywords' => false,
28
- 'lowercase_static_reference' => false,
29
- 'magic_constant_casing' => false,
30
- 'method_chaining_indentation' => false,
31
- 'multiline_whitespace_before_semicolons' => false,
32
- 'native_type_declaration_casing' => false,
33
- 'new_with_parentheses' => false,
34
- 'no_blank_lines_after_class_opening' => false,
35
- 'no_extra_blank_lines' => false,
36
- 'no_multiline_whitespace_around_double_arrow' => false,
37
- 'no_multiple_statements_per_line' => false,
38
- 'no_spaces_around_offset' => false,
39
- 'no_trailing_comma_in_singleline' => false,
40
- 'no_trailing_whitespace' => false,
41
- 'no_unneeded_control_parentheses' => [
42
- 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield', 'yield_from'],
43
- ],
44
- 'no_whitespace_before_comma_in_array' => false,
45
- 'no_whitespace_in_blank_line' => false,
46
- 'operator_linebreak' => false,
47
- 'single_blank_line_at_eof' => false,
48
- 'single_line_empty_body' => false,
49
- 'single_line_throw' => false,
50
- 'single_space_around_construct' => false,
51
- 'spaces_inside_parentheses' => false,
52
- 'statement_indentation' => false,
53
- 'trim_array_spaces' => false,
54
- 'types_spaces' => false,
55
- 'type_declaration_spaces' => false,
56
- 'whitespace_after_comma_in_array' => false,
57
- ];
58
-
59
- $custom = [
60
- 'blank_line_after_opening_tag' => false,
61
- 'combine_consecutive_issets' => false,
62
- 'combine_consecutive_unsets' => false,
63
- 'fully_qualified_strict_types' => ['leading_backslash_in_global_namespace' => true],
64
- 'increment_style' => ['style' => 'post'],
65
- 'native_function_invocation' => ['include' => ['@internal']],
66
- 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
67
- 'no_useless_else' => false,
68
- 'phpdoc_align' => false,
69
- 'phpdoc_annotation_without_dot' => false,
70
- 'phpdoc_tag_casing' => true,
71
- 'phpdoc_to_comment' => ['ignored_tags' => ['lang', 'noinspection', 'psalm-suppress', 'psalm-type', 'var']],
72
- 'return_assignment' => false,
73
- 'string_implicit_backslashes' => ['single_quoted' => 'escape', 'double_quoted' => 'escape', 'heredoc' => 'escape'],
74
- 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
75
-
76
- 'ordered_class_elements' => [
77
- 'order' => [
78
- 'use_trait',
79
- 'case',
80
- 'constant_public',
81
- 'constant_protected',
82
- 'constant_private',
83
- 'property_static',
84
- 'property',
85
- 'construct',
86
- 'destruct',
87
- // 'method',
88
- // 'method_static',
89
- ],
90
- ],
91
- ];
92
-
93
- return $base + $prettier + $custom;
@@ -1,39 +0,0 @@
1
- import propertiesOrder from '@averay/css-properties-sort-order';
2
- import recommended from 'stylelint-config-recommended';
3
- import standard from 'stylelint-config-standard';
4
-
5
- import patterns from '../../lib/cssPatterns.ts';
6
-
7
- export default {
8
- ...recommended.rules,
9
- ...standard.rules,
10
-
11
- // Core rules
12
- ...{
13
- 'color-named': 'never',
14
- 'function-url-no-scheme-relative': true,
15
- },
16
-
17
- // Disable Prettier conflicts
18
- ...{
19
- 'at-rule-empty-line-before': null,
20
- 'comment-empty-line-before': null,
21
- 'rule-empty-line-before': null,
22
- },
23
-
24
- // Patterns
25
- ...{
26
- 'container-name-pattern': patterns.bem,
27
- 'custom-media-pattern': patterns.bem,
28
- 'custom-property-pattern': patterns.bem,
29
- 'keyframes-name-pattern': patterns.bem,
30
- 'layer-name-pattern': patterns.bem,
31
- 'selector-class-pattern': patterns.bemWithOptionalUnderscoresPrefix,
32
- 'selector-id-pattern': patterns.kebab,
33
- },
34
-
35
- // Extensions
36
- 'csstools/use-logical': 'always',
37
- 'order/order': ['custom-properties', 'declarations'],
38
- 'order/properties-order': [propertiesOrder, { unspecified: 'bottomAlphabetical' }],
39
- };
@@ -1,47 +0,0 @@
1
- import recommended from 'stylelint-config-recommended-scss';
2
- import standard from 'stylelint-config-standard-scss';
3
-
4
- import patterns, { patternOrScssInterpolation } from '../../lib/cssPatterns.ts';
5
-
6
- export default {
7
- ...recommended.rules,
8
- ...standard.rules,
9
-
10
- // Disable Prettier conflicts
11
- ...{
12
- 'scss/at-else-closing-brace-newline-after': null,
13
- 'scss/at-else-closing-brace-space-after': null,
14
- 'scss/at-else-empty-line-before': null,
15
- 'scss/at-else-if-parentheses-space-before': null,
16
- 'scss/at-function-parentheses-space-before': null,
17
- 'scss/at-if-closing-brace-newline-after': null,
18
- 'scss/at-if-closing-brace-space-after': null,
19
- 'scss/at-mixin-parentheses-space-before': null,
20
- 'scss/dollar-variable-colon-newline-after': null,
21
- 'scss/dollar-variable-colon-space-after': null,
22
- 'scss/dollar-variable-colon-space-before': null,
23
- 'scss/operator-no-newline-after': null,
24
- 'scss/operator-no-newline-before': null,
25
- 'scss/operator-no-unspaced': null,
26
- },
27
-
28
- // Naming patterns
29
- ...{
30
- 'scss/at-function-pattern': patterns.bemWithOptionalSingleUnderscorePrefix,
31
- 'scss/at-mixin-pattern': patterns.bemWithOptionalSingleUnderscorePrefix,
32
- 'scss/dollar-variable-pattern': patterns.bemWithOptionalSingleUnderscorePrefix,
33
- 'scss/percent-placeholder-pattern': patterns.bemWithOptionalSingleUnderscorePrefix,
34
- },
35
-
36
- // Support interpolation for @ keywords
37
- ...{
38
- 'container-name-pattern': patternOrScssInterpolation(patterns.bem),
39
- 'custom-media-pattern': patternOrScssInterpolation(patterns.bem),
40
- 'custom-property-pattern': patternOrScssInterpolation(patterns.bem),
41
- 'keyframes-name-pattern': patternOrScssInterpolation(patterns.bem),
42
- 'layer-name-pattern': patternOrScssInterpolation(patterns.bem),
43
- },
44
-
45
- // Customise rulesets
46
- 'scss/at-if-no-null': null,
47
- };
package/src/extensions.ts DELETED
@@ -1,7 +0,0 @@
1
- export default {
2
- js: ['js', 'jsx', 'cjs', 'cjs', 'mjs', 'mjsx'],
3
- ts: ['ts', 'tsx', 'cts', 'cts', 'mts', 'mtsx'],
4
-
5
- css: ['css'],
6
- scss: ['scss'],
7
- } satisfies Record<string, string[]>;
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export { default as globals } from 'globals';
2
- export { default as extensions } from './extensions.ts';
3
- export { default as makeEslintConfig } from './makeEslintConfig.ts';
4
- export { default as makeStylelintConfig } from './makeStylelintConfig.ts';
@@ -1,97 +0,0 @@
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 { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
9
- import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
10
- import { importX as importXPlugin } from 'eslint-plugin-import-x';
11
- import jsdocPlugin from 'eslint-plugin-jsdoc';
12
- import promisePlugin from 'eslint-plugin-promise';
13
- import regexpPlugin from 'eslint-plugin-regexp';
14
- import sonarjsPlugin from 'eslint-plugin-sonarjs';
15
- import unicornPlugin from 'eslint-plugin-unicorn';
16
-
17
- import convertWarnsToErrors from '../lib/convertWarnsToErrors.ts';
18
- import rulesetEslintShared from '../rulesets/eslint/ruleset-shared.ts';
19
- import rulesetEslintTypescript, {
20
- moduleDeclarations as rulesetEslintTypescriptModuleDeclarations,
21
- } from '../rulesets/eslint/ruleset-typescript.ts';
22
-
23
- import extensions from './extensions.ts';
24
-
25
- interface Options {
26
- /** The ECMA version to use. */
27
- ecmaVersion?: TSESLint.FlatConfig.EcmaVersion;
28
- /** The relative path to the project's `tsconfig.json` file. */
29
- tsconfigPath?: string;
30
- }
31
-
32
- /**
33
- * @param options Project-specific customisations.
34
- * @returns The complete ESLint config.
35
- */
36
- export default function makeEslintConfig({
37
- ecmaVersion = 'latest',
38
- tsconfigPath,
39
- }: Options = {}): TSESLint.FlatConfig.Config[] {
40
- return [
41
- // JavaScript & TypeScript
42
- {
43
- files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
44
- languageOptions: {
45
- parserOptions: {
46
- ecmaVersion,
47
- sourceType: 'module',
48
- },
49
- },
50
- linterOptions: {
51
- reportUnusedDisableDirectives: true,
52
- },
53
- plugins: {
54
- '@stylistic': stylisticPlugin,
55
- 'eslint-comments': eslintCommentsPlugin,
56
- 'import-x': importXPlugin,
57
- jsdoc: jsdocPlugin,
58
- promise: promisePlugin,
59
- regexp: regexpPlugin,
60
- sonarjs: sonarjsPlugin,
61
- unicorn: unicornPlugin,
62
- },
63
- rules: convertWarnsToErrors(rulesetEslintShared),
64
- settings: {
65
- 'import-x/parsers': {
66
- espree: extensions.js.map((extension) => `.${extension}`),
67
- },
68
- },
69
- },
70
-
71
- // TypeScript
72
- {
73
- files: [`**/*.{${extensions.ts.join(',')}}`],
74
- languageOptions: {
75
- parser: typescriptParser,
76
- parserOptions: tsconfigPath == null ? {} : { project: tsconfigPath },
77
- },
78
- plugins: {
79
- '@typescript-eslint': typescriptPlugin,
80
- },
81
- rules: convertWarnsToErrors(rulesetEslintTypescript),
82
- settings: {
83
- ...importXPlugin.configs.typescript.settings,
84
- 'import-x/parsers': {
85
- '@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
86
- },
87
- 'import-x/resolver-next': createTypeScriptImportResolver(tsconfigPath == null ? {} : { project: tsconfigPath }),
88
- },
89
- },
90
- {
91
- files: ['**/*.d.ts'],
92
- rules: rulesetEslintTypescriptModuleDeclarations,
93
- },
94
-
95
- prettierConfig,
96
- ];
97
- }
@@ -1,46 +0,0 @@
1
- /* eslint sort-keys: "error" -- Organise rules */
2
-
3
- import postcssScss from 'postcss-scss';
4
- import type { Config, CustomSyntax } from 'stylelint';
5
- import orderPlugin from 'stylelint-order';
6
- import scssPlugin from 'stylelint-scss';
7
- import useLogicalPlugin from 'stylelint-use-logical';
8
-
9
- import rulesetStylelintCss from '../rulesets/stylelint/ruleset-css.ts';
10
- import rulesetStylelintScss from '../rulesets/stylelint/ruleset-scss.ts';
11
-
12
- import extensions from './extensions.ts';
13
-
14
- type ConfigRules = Config['rules'];
15
-
16
- /**
17
- * @returns The complete Stylelint config.
18
- */
19
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type,@typescript-eslint/explicit-module-boundary-types -- Preserve specific object shape.
20
- export default function makeStylelintConfig(cssRules: ConfigRules = {}, scssRules: ConfigRules = {}) {
21
- return {
22
- defaultSeverity: 'error',
23
- ignoreFiles: ['**/*.min.*'],
24
- plugins: [orderPlugin, useLogicalPlugin],
25
- reportDescriptionlessDisables: true,
26
- reportInvalidScopeDisables: true,
27
- reportNeedlessDisables: true,
28
- rules: {
29
- ...rulesetStylelintCss,
30
- ...cssRules,
31
- },
32
-
33
- // eslint-disable-next-line sort-keys -- Logically positioned.
34
- overrides: [
35
- {
36
- customSyntax: postcssScss as unknown as CustomSyntax,
37
- files: extensions.scss.map((ext) => `**/*.${ext}`), // Does not support glob braces
38
- plugins: [scssPlugin],
39
- rules: {
40
- ...rulesetStylelintScss,
41
- ...scssRules,
42
- },
43
- },
44
- ],
45
- } satisfies Config;
46
- }
@@ -1,7 +0,0 @@
1
- /* eslint import-x/no-commonjs: "off" -- Unsupported by Stylelint */
2
-
3
- import { makeStylelintConfig } from './src/index.ts';
4
-
5
- export default {
6
- ...makeStylelintConfig(),
7
- };
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "module": "Node16",
6
- "moduleResolution": "Node16",
7
- "noEmit": false,
8
- "rewriteRelativeImportExtensions": true,
9
- "sourceMap": true
10
- },
11
- "include": ["bin/**/*.ts", "lib/**/*.ts", "rulesets/**/*.ts", "src/**/*.ts"],
12
- "exclude": ["**/*.test.ts"]
13
- }
File without changes