@scayle/eslint-config-storefront 4.8.3-alpha.1 → 5.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.
@@ -1,155 +0,0 @@
1
- import { FlatConfigComposer } from 'eslint-flat-config-utils'
2
- import { isPackageExists } from 'local-pkg'
3
- import {
4
- GLOB_TESTS,
5
- combine,
6
- comments,
7
- ignores,
8
- javascript,
9
- jsdoc,
10
- jsonc,
11
- node,
12
- test,
13
- typescript,
14
- } from '@antfu/eslint-config'
15
- import gitignore from 'eslint-config-flat-gitignore'
16
- import tseslint from 'typescript-eslint'
17
- import { sonarjs } from './sonarjs.mjs'
18
- import { promise } from './promise.mjs'
19
- import { importX } from './importX.mjs'
20
-
21
- // Partial eslint config by `@antfu/eslint-config`
22
- // <https://github.com/antfu/eslint-config/blob/main/README.md>
23
-
24
- /**
25
- * @param {object=} config
26
- * @param {boolean=} config.isNuxt
27
- * @param {object=} config.typescript
28
- * @param {string=} config.typescript.tsconfigPath
29
- * @returns {FlatConfigComposer<Linter.FlatConfig<Linter.RulesRecord>, never>} Returns a FlatConfigComposer object to be consumed in projects eslint.config.mjs files
30
- */
31
- export const eslintConfigStorefront = function (
32
- config = {
33
- isNuxt: isPackageExists('@nuxt/eslint'),
34
- typescript: { tsconfigPath: undefined },
35
- },
36
- ) {
37
- const flatConfigComposer = new FlatConfigComposer()
38
- const isNuxtProject = config.isNuxt
39
-
40
- // Pre-defined rule configurations for better performance
41
- const TYPESCRIPT_JSON_RULES = {
42
- '@typescript-eslint/ban-ts-comment': 'off',
43
- '@typescript-eslint/no-array-constructor': 'off',
44
- '@typescript-eslint/no-duplicate-enum-values': 'off',
45
- '@typescript-eslint/no-empty-object-type': 'off',
46
- '@typescript-eslint/no-explicit-any': 'off',
47
- '@typescript-eslint/no-extra-non-null-assertion': 'off',
48
- '@typescript-eslint/no-misused-new': 'off',
49
- '@typescript-eslint/no-namespace': 'off',
50
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
51
- '@typescript-eslint/no-require-imports': 'off',
52
- '@typescript-eslint/no-this-alias': 'off',
53
- '@typescript-eslint/no-unnecessary-type-constraint': 'off',
54
- '@typescript-eslint/no-unsafe-declaration-merging': 'off',
55
- '@typescript-eslint/no-unsafe-function-type': 'off',
56
- '@typescript-eslint/no-unused-expressions': 'off',
57
- '@typescript-eslint/no-unused-vars': 'off',
58
- '@typescript-eslint/no-wrapper-object-types': 'off',
59
- '@typescript-eslint/prefer-as-const': 'off',
60
- '@typescript-eslint/prefer-namespace-keyword': 'off',
61
- '@typescript-eslint/triple-slash-reference': 'off',
62
- }
63
-
64
- const CURLY_RULE = ['error', 'all']
65
-
66
- const TYPESCRIPT_RULES = {
67
- curly: CURLY_RULE,
68
- '@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }],
69
- '@typescript-eslint/no-empty-object-type': [
70
- 'error',
71
- {
72
- allowInterfaces: 'always',
73
- },
74
- ],
75
- '@typescript-eslint/no-unused-vars': [
76
- 'error',
77
- {
78
- args: 'all',
79
- argsIgnorePattern: '^_',
80
- caughtErrors: 'all',
81
- caughtErrorsIgnorePattern: '^_',
82
- destructuredArrayIgnorePattern: '^_',
83
- varsIgnorePattern: '^_',
84
- ignoreRestSiblings: true,
85
- },
86
- ],
87
- }
88
-
89
- const BASE_CONFIGS = [
90
- comments(),
91
- node(),
92
- jsonc(),
93
- test(),
94
- sonarjs(),
95
- promise(),
96
- ]
97
-
98
- const GLOBAL_RULES = {
99
- curly: CURLY_RULE,
100
- 'node/prefer-global/process': 'off',
101
- }
102
-
103
- const TEST_RULES = {
104
- 'no-console': 'off',
105
- '@typescript-eslint/no-explicit-any': 'off',
106
- 'promise/avoid-new': 'off',
107
- }
108
-
109
- const IGNORE_PATTERNS = ['**/fixtures/**/*', '**/*.jsonc']
110
-
111
- // The following rules are already handled by `@nuxt/eslint` and
112
- // don't need to be extended from `@antfu/eslint-config` if it is used
113
- const nonNuxtRules = !isNuxtProject
114
- ? combine(
115
- gitignore(),
116
- ignores(),
117
- importX(),
118
- javascript(),
119
- typescript(config.typescript),
120
- jsdoc(),
121
- tseslint.configs.recommended,
122
- [{ rules: TYPESCRIPT_RULES }],
123
- )
124
- : {}
125
-
126
- const configs = [
127
- combine(...BASE_CONFIGS),
128
- nonNuxtRules,
129
- {
130
- rules: GLOBAL_RULES,
131
- ignores: [IGNORE_PATTERNS[0]],
132
- },
133
- {
134
- files: ['**/*.json'],
135
- rules: TYPESCRIPT_JSON_RULES,
136
- },
137
- {
138
- files: GLOB_TESTS,
139
- rules: TEST_RULES,
140
- },
141
- { ignores: [IGNORE_PATTERNS[1]] },
142
- // Set tsconfigRootDir for all TypeScript files to support monorepo structure
143
- // This ensures ESLint uses the correct tsconfig.json when multiple exist
144
- {
145
- files: ['**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'],
146
- languageOptions: {
147
- parserOptions: {
148
- tsconfigRootDir: process.cwd(),
149
- },
150
- },
151
- },
152
- ]
153
-
154
- return flatConfigComposer.append(...configs)
155
- }
@@ -1,28 +0,0 @@
1
- import pluginPromise from 'eslint-plugin-promise'
2
-
3
- // Pre-defined rule configurations for better performance
4
- const PROMISE_RULES = {
5
- 'promise/no-multiple-resolved': 'error',
6
- 'promise/no-new-statics': 'error',
7
- 'promise/no-return-wrap': 'error',
8
- 'promise/always-return': 'warn',
9
- 'promise/avoid-new': 'warn',
10
- 'promise/catch-or-return': 'warn',
11
- 'promise/no-callback-in-promise': 'warn',
12
- 'promise/no-nesting': 'warn',
13
- 'promise/no-promise-in-callback': 'warn',
14
- 'promise/no-return-in-finally': 'warn',
15
- 'promise/param-names': 'warn',
16
- 'promise/valid-params': 'warn',
17
- 'promise/no-native': 'off',
18
- }
19
-
20
- export function promise() {
21
- return [
22
- {
23
- name: 'storefront/promise/rules',
24
- plugins: { promise: pluginPromise },
25
- rules: PROMISE_RULES,
26
- },
27
- ]
28
- }
@@ -1,19 +0,0 @@
1
- import pluginSonarjs from 'eslint-plugin-sonarjs'
2
-
3
- // Pre-defined rule configurations for better performance
4
- const SONARJS_RULES = {
5
- 'sonarjs/no-duplicate-string': 'off',
6
- 'sonarjs/todo-tag': 'warn',
7
- 'sonarjs/fixme-tag': 'warn',
8
- }
9
-
10
- export function sonarjs() {
11
- return [
12
- pluginSonarjs.configs.recommended,
13
- {
14
- name: 'storefront/sonarjs/rules',
15
- plugins: { pluginSonarjs },
16
- rules: SONARJS_RULES,
17
- },
18
- ]
19
- }