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