@alexlit/config-eslint 161.4.0 → 162.1.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.
@@ -18,44 +18,57 @@ const EXTENSIONS = [
18
18
  '.json',
19
19
  ];
20
20
 
21
- /** @see [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x) */
22
- export const importX = defineConfig([
23
- { ...plugin.flatConfigs.recommended, files: FILES, ignores: DATA_FILES },
21
+ /**
22
+ * Правила для импортов и модулей.
23
+ *
24
+ * @returns {import('eslint').Linter.Config[]}
25
+ *
26
+ * @see [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x)
27
+ */
28
+ export const importX = () =>
29
+ defineConfig([
30
+ { ...plugin.flatConfigs.recommended, files: FILES, ignores: DATA_FILES },
24
31
 
25
- {
26
- files: FILES,
27
- languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
28
- plugins: { 'import-x': plugin },
29
- rules: {
30
- 'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
31
- 'import-x/first': 'error',
32
- 'import-x/newline-after-import': 'warn',
33
- 'import-x/no-absolute-path': 'error',
34
- 'import-x/no-cycle': 'error',
35
- 'import-x/no-extraneous-dependencies': 'error',
36
- 'import-x/no-named-as-default': 'off',
37
- 'import-x/no-named-as-default-member': 'off',
38
- 'import-x/no-nodejs-modules': 'off',
39
- 'import-x/no-self-import': 'error',
40
- 'import-x/no-unresolved': 'off',
41
- 'import-x/no-useless-path-segments': ['error', { noUselessIndex: true }],
42
- 'import-x/unambiguous': 'error',
32
+ {
33
+ files: FILES,
34
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
35
+ plugins: { 'import-x': plugin },
36
+ rules: {
37
+ 'import-x/consistent-type-specifier-style': [
38
+ 'error',
39
+ 'prefer-top-level',
40
+ ],
41
+ 'import-x/first': 'error',
42
+ 'import-x/newline-after-import': 'warn',
43
+ 'import-x/no-absolute-path': 'error',
44
+ 'import-x/no-cycle': 'error',
45
+ 'import-x/no-extraneous-dependencies': 'error',
46
+ 'import-x/no-named-as-default': 'off',
47
+ 'import-x/no-named-as-default-member': 'off',
48
+ 'import-x/no-nodejs-modules': 'off',
49
+ 'import-x/no-self-import': 'error',
50
+ 'import-x/no-unresolved': 'off',
51
+ 'import-x/no-useless-path-segments': [
52
+ 'error',
53
+ { noUselessIndex: true },
54
+ ],
55
+ 'import-x/unambiguous': 'error',
56
+ },
57
+ settings: {
58
+ 'import-x/extensions': EXTENSIONS,
59
+ 'import-x/ignore': ['node_modules', String.raw`\.vue$`],
60
+ 'import-x/parsers': { '.vue': [vueParser] },
61
+ 'import-x/resolver-next': [
62
+ createNodeResolver({ extensions: EXTENSIONS, tsconfig: 'auto' }),
63
+ ],
64
+ },
43
65
  },
44
- settings: {
45
- 'import-x/extensions': EXTENSIONS,
46
- 'import-x/ignore': ['node_modules', String.raw`\.vue$`],
47
- 'import-x/parsers': { '.vue': [vueParser] },
48
- 'import-x/resolver-next': [
49
- createNodeResolver({ extensions: EXTENSIONS, tsconfig: 'auto' }),
50
- ],
51
- },
52
- },
53
66
 
54
- {
55
- files: VUE_FILES,
56
- rules: {
57
- 'import-x/no-useless-path-segments': 'off',
58
- 'import-x/unambiguous': 'off',
67
+ {
68
+ files: VUE_FILES,
69
+ rules: {
70
+ 'import-x/no-useless-path-segments': 'off',
71
+ 'import-x/unambiguous': 'off',
72
+ },
59
73
  },
60
- },
61
- ]);
74
+ ]);
@@ -5,90 +5,101 @@ import { FILES, TEST_FILES } from '../base.js';
5
5
  import { NO_RESTRICTED_SYNTAX } from '../rules/restricted-syntax.js';
6
6
  import { STYLE_RULES } from '../rules/style.js';
7
7
 
8
- /** @see [eslint](https://eslint.org) */
9
- export const javascript = defineConfig([
10
- { files: FILES, ...plugin.configs.recommended },
11
- {
12
- files: FILES,
13
- rules: {
14
- 'arrow-body-style': ['error', 'as-needed'],
15
- ...STYLE_RULES,
16
- 'default-case-last': 'error',
17
- 'dot-notation': ['error'],
18
- 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
19
- 'no-alert': 'error',
20
- 'no-console': 'warn',
21
- 'no-duplicate-imports': [
22
- 'error',
23
- { allowSeparateTypeImports: true, includeExports: false },
24
- ],
25
- 'no-else-return': 'error',
26
- 'no-implicit-coercion': 'error',
27
- 'no-param-reassign': ['error', { props: false }],
28
- 'no-restricted-exports': [
29
- 'error',
30
- {
31
- restrictedNamedExports: ['then'],
32
- restrictedNamedExportsPattern: '^_',
33
- },
34
- ],
35
- 'no-restricted-globals': [
36
- 'error',
37
- // `event`, `top` and `parent` are global browser properties.
38
- // Reach for `window.event` / `window.top` / `window.parent` instead.
39
- { message: 'Use `window.event` instead.', name: 'event' },
40
- { message: 'Use `window.parent` instead.', name: 'parent' },
41
- { message: 'Use `window.top` instead.', name: 'top' },
42
- ],
43
- 'no-restricted-imports': [
44
- 'error',
45
- {
46
- patterns: [
47
- // Алиасы
48
- { group: ['~/', '~~/'], message: 'Используйте "@" вместо "~".' },
49
- // Расширения
50
- {
51
- message: 'Не указывайте расширения .ts или .js в путях импорта.',
52
- regex: String.raw`\.[jt]sx?$`,
53
- },
54
- // Относительные импорты
55
- { group: ['..', '*/..'], message: 'Используйте абсолютный путь.' },
56
- {
57
- message: 'Не используйте индексный импорт.',
58
- regex: String.raw`^\.$`,
59
- },
60
- {
61
- group: ['**/index'],
62
- message: 'Не используйте индексный импорт.',
63
- },
64
- // Внешние локальные ресурсы
65
- {
66
- group: ['@/**/_*', '@@/**/_*', '~/**/_*', '~~/**/_*'],
67
- message: 'Этот локальный ресурс не преднаназначен для импорта.',
68
- },
69
- // Устаревший функционал
70
- {
71
- message: 'Этот функционал устарел.',
72
- regex: '(_deprecated|_legacy)',
73
- },
74
- ],
75
- },
76
- ],
77
- 'no-restricted-syntax': ['error', ...NO_RESTRICTED_SYNTAX],
78
- 'no-useless-rename': 'error',
79
- 'prefer-arrow-callback': [
80
- 'error',
81
- { allowNamedFunctions: false, allowUnboundThis: false },
82
- ],
83
- 'prefer-const': 'warn',
84
- 'prefer-template': 'warn',
85
- 'require-await': 'error',
8
+ /**
9
+ * Базовые правила JavaScript.
10
+ *
11
+ * @returns {import('eslint').Linter.Config[]}
12
+ *
13
+ * @see [eslint](https://eslint.org)
14
+ */
15
+ export const javascript = () =>
16
+ defineConfig([
17
+ { files: FILES, ...plugin.configs.recommended },
18
+ {
19
+ files: FILES,
20
+ rules: {
21
+ 'arrow-body-style': ['error', 'as-needed'],
22
+ ...STYLE_RULES,
23
+ 'default-case-last': 'error',
24
+ 'dot-notation': ['error'],
25
+ 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
26
+ 'no-alert': 'error',
27
+ 'no-console': 'warn',
28
+ 'no-duplicate-imports': [
29
+ 'error',
30
+ { allowSeparateTypeImports: true, includeExports: false },
31
+ ],
32
+ 'no-else-return': 'error',
33
+ 'no-implicit-coercion': 'error',
34
+ 'no-param-reassign': ['error', { props: false }],
35
+ 'no-restricted-exports': [
36
+ 'error',
37
+ {
38
+ restrictedNamedExports: ['then'],
39
+ restrictedNamedExportsPattern: '^_',
40
+ },
41
+ ],
42
+ 'no-restricted-globals': [
43
+ 'error',
44
+ // `event`, `top` and `parent` are global browser properties.
45
+ // Reach for `window.event` / `window.top` / `window.parent` instead.
46
+ { message: 'Use `window.event` instead.', name: 'event' },
47
+ { message: 'Use `window.parent` instead.', name: 'parent' },
48
+ { message: 'Use `window.top` instead.', name: 'top' },
49
+ ],
50
+ 'no-restricted-imports': [
51
+ 'error',
52
+ {
53
+ patterns: [
54
+ // Алиасы
55
+ { group: ['~/', '~~/'], message: 'Используйте "@" вместо "~".' },
56
+ // Расширения
57
+ {
58
+ message:
59
+ 'Не указывайте расширения .ts или .js в путях импорта.',
60
+ regex: String.raw`\.[jt]sx?$`,
61
+ },
62
+ // Относительные импорты
63
+ {
64
+ group: ['..', '*/..'],
65
+ message: 'Используйте абсолютный путь.',
66
+ },
67
+ {
68
+ message: 'Не используйте индексный импорт.',
69
+ regex: String.raw`^\.$`,
70
+ },
71
+ {
72
+ group: ['**/index'],
73
+ message: 'Не используйте индексный импорт.',
74
+ },
75
+ // Внешние локальные ресурсы
76
+ {
77
+ group: ['@/**/_*', '@@/**/_*', '~/**/_*', '~~/**/_*'],
78
+ message: 'Этот локальный ресурс не преднаназначен для импорта.',
79
+ },
80
+ // Устаревший функционал
81
+ {
82
+ message: 'Этот функционал устарел.',
83
+ regex: '(_deprecated|_legacy)',
84
+ },
85
+ ],
86
+ },
87
+ ],
88
+ 'no-restricted-syntax': ['error', ...NO_RESTRICTED_SYNTAX],
89
+ 'no-useless-rename': 'error',
90
+ 'prefer-arrow-callback': [
91
+ 'error',
92
+ { allowNamedFunctions: false, allowUnboundThis: false },
93
+ ],
94
+ 'prefer-const': 'warn',
95
+ 'prefer-template': 'warn',
96
+ 'require-await': 'error',
97
+ },
86
98
  },
87
- },
88
99
 
89
- {
90
- // Tests are allowed to log and to alert
91
- files: TEST_FILES,
92
- rules: { 'no-alert': 'off', 'no-console': 'off' },
93
- },
94
- ]);
100
+ {
101
+ // Tests are allowed to log and to alert
102
+ files: TEST_FILES,
103
+ rules: { 'no-alert': 'off', 'no-console': 'off' },
104
+ },
105
+ ]);
package/plugins/jsdoc.js CHANGED
@@ -3,21 +3,28 @@ import { defineConfig } from 'eslint/config';
3
3
 
4
4
  import { FILES } from '../base.js';
5
5
 
6
- /** @see [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) */
7
- export const jsdoc = defineConfig([
8
- { files: FILES, ...plugin.configs['flat/recommended'] },
9
- {
10
- files: FILES,
11
- rules: {
12
- 'jsdoc/lines-before-block': 'off',
13
- 'jsdoc/no-undefined-types': 'off',
14
- 'jsdoc/require-jsdoc': 'off',
15
- 'jsdoc/require-param-description': 'off',
16
- 'jsdoc/require-param-type': 'off',
17
- 'jsdoc/require-returns': 'off',
18
- 'jsdoc/require-returns-description': 'off',
19
- 'jsdoc/require-returns-type': 'off',
20
- 'jsdoc/tag-lines': 'off',
6
+ /**
7
+ * Правила для JSDoc-комментариев.
8
+ *
9
+ * @returns {import('eslint').Linter.Config[]}
10
+ *
11
+ * @see [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)
12
+ */
13
+ export const jsdoc = () =>
14
+ defineConfig([
15
+ { files: FILES, ...plugin.configs['flat/recommended'] },
16
+ {
17
+ files: FILES,
18
+ rules: {
19
+ 'jsdoc/lines-before-block': 'off',
20
+ 'jsdoc/no-undefined-types': 'off',
21
+ 'jsdoc/require-jsdoc': 'off',
22
+ 'jsdoc/require-param-description': 'off',
23
+ 'jsdoc/require-param-type': 'off',
24
+ 'jsdoc/require-returns': 'off',
25
+ 'jsdoc/require-returns-description': 'off',
26
+ 'jsdoc/require-returns-type': 'off',
27
+ 'jsdoc/tag-lines': 'off',
28
+ },
21
29
  },
22
- },
23
- ]);
30
+ ]);
package/plugins/json.js CHANGED
@@ -4,30 +4,37 @@ import * as yamlParser from 'yaml-eslint-parser';
4
4
 
5
5
  import { YAML_FILES } from '../base.js';
6
6
 
7
- /** @see [ESLint/JSON](https://github.com/eslint/json) */
8
- export const json = defineConfig([
9
- {
10
- extends: ['json/recommended'],
11
- files: ['**/*.json'],
12
- ignores: ['**/package-lock.json'],
13
- language: 'json/json',
14
- plugins: { json: plugin },
15
- },
7
+ /**
8
+ * Правила для JSON, JSONC, JSON5 и YAML-файлов.
9
+ *
10
+ * @returns {import('eslint').Linter.Config[]}
11
+ *
12
+ * @see [ESLint/JSON](https://github.com/eslint/json)
13
+ */
14
+ export const json = () =>
15
+ defineConfig([
16
+ {
17
+ extends: ['json/recommended'],
18
+ files: ['**/*.json'],
19
+ ignores: ['**/package-lock.json'],
20
+ language: 'json/json',
21
+ plugins: { json: plugin },
22
+ },
16
23
 
17
- {
18
- extends: ['json/recommended'],
19
- files: ['**/*.jsonc'],
20
- language: 'json/jsonc',
21
- languageOptions: { allowTrailingCommas: true },
22
- plugins: { json: plugin },
23
- },
24
+ {
25
+ extends: ['json/recommended'],
26
+ files: ['**/*.jsonc'],
27
+ language: 'json/jsonc',
28
+ languageOptions: { allowTrailingCommas: true },
29
+ plugins: { json: plugin },
30
+ },
24
31
 
25
- {
26
- extends: ['json/recommended'],
27
- files: ['**/*.json5'],
28
- language: 'json/json5',
29
- plugins: { json: plugin },
30
- },
32
+ {
33
+ extends: ['json/recommended'],
34
+ files: ['**/*.json5'],
35
+ language: 'json/json5',
36
+ plugins: { json: plugin },
37
+ },
31
38
 
32
- { files: YAML_FILES, languageOptions: { parser: yamlParser } },
33
- ]);
39
+ { files: YAML_FILES, languageOptions: { parser: yamlParser } },
40
+ ]);
@@ -3,107 +3,120 @@ import { defineConfig } from 'eslint/config';
3
3
 
4
4
  import { FILES } from '../base.js';
5
5
 
6
- /** @see [eslint-plugin-perfectionist](https://perfectionist.dev) */
7
- export const perfectionist = defineConfig([
8
- { ...plugin.configs['recommended-natural'], files: FILES },
9
- {
10
- files: FILES,
11
- rules: {
12
- 'perfectionist/sort-imports': [
13
- 'warn',
14
- {
15
- customGroups: [
16
- // hash (nuxt)
17
- { elementNamePattern: ['^#'], groupName: 'hash' },
6
+ /**
7
+ * Правила сортировки импортов, объектов, интерфейсов и типов.
8
+ *
9
+ * @returns {import('eslint').Linter.Config[]}
10
+ *
11
+ * @see [eslint-plugin-perfectionist](https://perfectionist.dev)
12
+ */
13
+ export const perfectionist = () =>
14
+ defineConfig([
15
+ { ...plugin.configs['recommended-natural'], files: FILES },
16
+ {
17
+ files: FILES,
18
+ rules: {
19
+ 'perfectionist/sort-imports': [
20
+ 'warn',
21
+ {
22
+ customGroups: [
23
+ // hash (nuxt)
24
+ { elementNamePattern: ['^#'], groupName: 'hash' },
18
25
 
19
- // @@/
20
- { elementNamePattern: ['^@@/'], groupName: 'double-at' },
26
+ // @@/
27
+ { elementNamePattern: ['^@@/'], groupName: 'double-at' },
21
28
 
22
- // universal
23
- { elementNamePattern: ['^@/api'], groupName: 'universal-api' },
24
- {
25
- elementNamePattern: ['^@/assets'],
26
- groupName: 'universal-assets',
27
- },
28
- {
29
- elementNamePattern: ['^@/components'],
30
- groupName: 'universal-components',
31
- },
32
- {
33
- elementNamePattern: ['^@/composables'],
34
- groupName: 'universal-composables',
35
- },
36
- {
37
- elementNamePattern: ['^@/constants'],
38
- groupName: 'universal-constants',
39
- },
40
- {
41
- elementNamePattern: ['^@/directives'],
42
- groupName: 'universal-directives',
43
- },
44
- {
45
- elementNamePattern: ['^@/layouts'],
46
- groupName: 'universal-layouts',
47
- },
48
- { elementNamePattern: ['^@/pages'], groupName: 'universal-pages' },
49
- {
50
- elementNamePattern: ['^@/plugins'],
51
- groupName: 'universal-plugins',
52
- },
53
- {
54
- elementNamePattern: ['^@/stores'],
55
- groupName: 'universal-stores',
56
- },
57
- { elementNamePattern: ['^@/utils'], groupName: 'universal-utils' },
58
- ],
59
- groups: [
60
- 'type-import',
61
- ['value-builtin', 'value-external'],
29
+ // universal
30
+ { elementNamePattern: ['^@/api'], groupName: 'universal-api' },
31
+ {
32
+ elementNamePattern: ['^@/assets'],
33
+ groupName: 'universal-assets',
34
+ },
35
+ {
36
+ elementNamePattern: ['^@/components'],
37
+ groupName: 'universal-components',
38
+ },
39
+ {
40
+ elementNamePattern: ['^@/composables'],
41
+ groupName: 'universal-composables',
42
+ },
43
+ {
44
+ elementNamePattern: ['^@/constants'],
45
+ groupName: 'universal-constants',
46
+ },
47
+ {
48
+ elementNamePattern: ['^@/directives'],
49
+ groupName: 'universal-directives',
50
+ },
51
+ {
52
+ elementNamePattern: ['^@/layouts'],
53
+ groupName: 'universal-layouts',
54
+ },
55
+ {
56
+ elementNamePattern: ['^@/pages'],
57
+ groupName: 'universal-pages',
58
+ },
59
+ {
60
+ elementNamePattern: ['^@/plugins'],
61
+ groupName: 'universal-plugins',
62
+ },
63
+ {
64
+ elementNamePattern: ['^@/stores'],
65
+ groupName: 'universal-stores',
66
+ },
67
+ {
68
+ elementNamePattern: ['^@/utils'],
69
+ groupName: 'universal-utils',
70
+ },
71
+ ],
72
+ groups: [
73
+ 'type-import',
74
+ ['value-builtin', 'value-external'],
62
75
 
63
- // hash (nuxt)
64
- 'hash',
76
+ // hash (nuxt)
77
+ 'hash',
65
78
 
66
- // @@/
67
- 'double-at',
79
+ // @@/
80
+ 'double-at',
68
81
 
69
- // universal
70
- 'universal-api',
71
- 'universal-assets',
72
- 'universal-components',
73
- 'universal-composables',
74
- 'universal-constants',
75
- 'universal-directives',
76
- 'universal-layouts',
77
- 'universal-pages',
78
- 'universal-plugins',
79
- 'universal-stores',
80
- 'universal-utils',
82
+ // universal
83
+ 'universal-api',
84
+ 'universal-assets',
85
+ 'universal-components',
86
+ 'universal-composables',
87
+ 'universal-constants',
88
+ 'universal-directives',
89
+ 'universal-layouts',
90
+ 'universal-pages',
91
+ 'universal-plugins',
92
+ 'universal-stores',
93
+ 'universal-utils',
81
94
 
82
- 'type-internal',
83
- 'value-internal',
95
+ 'type-internal',
96
+ 'value-internal',
84
97
 
85
- ['type-parent', 'type-sibling', 'type-index'],
86
- ['value-parent', 'value-sibling', 'value-index'],
98
+ ['type-parent', 'type-sibling', 'type-index'],
99
+ ['value-parent', 'value-sibling', 'value-index'],
87
100
 
88
- 'ts-equals-import',
89
- 'unknown',
90
- ],
91
- internalPattern: ['^@@/.*', '^@/.*'],
92
- type: 'natural',
93
- },
94
- ],
95
- 'perfectionist/sort-interfaces': [
96
- 'warn',
97
- { newlinesBetween: 0, partitionByComment: false, type: 'natural' },
98
- ],
99
- 'perfectionist/sort-object-types': [
100
- 'warn',
101
- { newlinesBetween: 0, partitionByComment: false, type: 'natural' },
102
- ],
103
- 'perfectionist/sort-objects': [
104
- 'warn',
105
- { newlinesBetween: 0, partitionByComment: false, type: 'natural' },
106
- ],
101
+ 'ts-equals-import',
102
+ 'unknown',
103
+ ],
104
+ internalPattern: ['^@@/.*', '^@/.*'],
105
+ type: 'natural',
106
+ },
107
+ ],
108
+ 'perfectionist/sort-interfaces': [
109
+ 'warn',
110
+ { newlinesBetween: 0, partitionByComment: false, type: 'natural' },
111
+ ],
112
+ 'perfectionist/sort-object-types': [
113
+ 'warn',
114
+ { newlinesBetween: 0, partitionByComment: false, type: 'natural' },
115
+ ],
116
+ 'perfectionist/sort-objects': [
117
+ 'warn',
118
+ { newlinesBetween: 0, partitionByComment: false, type: 'natural' },
119
+ ],
120
+ },
107
121
  },
108
- },
109
- ]);
122
+ ]);
package/plugins/pinia.js CHANGED
@@ -3,14 +3,21 @@ import { defineConfig } from 'eslint/config';
3
3
 
4
4
  import { FILES } from '../base.js';
5
5
 
6
- /** @see [eslint-plugin-pinia](https://github.com/lisilinhart/eslint-plugin-pinia) */
7
- export const pinia = defineConfig([
8
- {
9
- ...plugin.configs['recommended-flat'],
10
- files: FILES,
11
- rules: {
12
- ...plugin.configs['recommended-flat'].rules,
13
- 'pinia/prefer-single-store-per-file': 'error',
6
+ /**
7
+ * Правила для Pinia-хранилищ.
8
+ *
9
+ * @returns {import('eslint').Linter.Config[]}
10
+ *
11
+ * @see [eslint-plugin-pinia](https://github.com/lisilinhart/eslint-plugin-pinia)
12
+ */
13
+ export const pinia = () =>
14
+ defineConfig([
15
+ {
16
+ ...plugin.configs['recommended-flat'],
17
+ files: FILES,
18
+ rules: {
19
+ ...plugin.configs['recommended-flat'].rules,
20
+ 'pinia/prefer-single-store-per-file': 'error',
21
+ },
14
22
  },
15
- },
16
- ]);
23
+ ]);