@santi020k/eslint-config-santi020k 2.1.0 → 3.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.
package/dist/index.js CHANGED
@@ -1,489 +1,580 @@
1
- import pluginAstro from 'eslint-plugin-astro';
2
- import eslint from '@eslint/js';
3
- import pluginStylistic from '@stylistic/eslint-plugin';
4
- import configStandard from 'eslint-config-standard';
5
- import pluginImport from 'eslint-plugin-import';
6
- import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
7
- import pluginN from 'eslint-plugin-n';
8
- import pluginPromise from 'eslint-plugin-promise';
9
- import pluginSimpleImport from 'eslint-plugin-simple-import-sort';
10
- import pluginSonarJs from 'eslint-plugin-sonarjs';
11
- import pluginUnusedImport from 'eslint-plugin-unused-imports';
12
- import globals from 'globals';
13
- import { FlatCompat } from '@eslint/eslintrc';
14
- import { getDirname } from 'cross-dirname';
15
- import { fixupConfigRules } from '@eslint/compat';
16
- import pluginReactConfig from 'eslint-plugin-react/configs/recommended.js';
17
- import pluginReactHooks from 'eslint-plugin-react-hooks';
18
- import tsParser from '@typescript-eslint/parser';
19
- import tsEslint from 'typescript-eslint';
20
- import pluginCspell from '@cspell/eslint-plugin';
21
- import pluginMdx from 'eslint-plugin-mdx';
22
- import pluginTailwind from 'eslint-plugin-tailwindcss';
23
- import pluginVitest from 'eslint-plugin-vitest';
1
+ // src/utils/apply-config-if-option-present.ts
2
+ var applyConfigIfOptionPresent = (configs, option, configToAdd) => {
3
+ const isOptionIncluded = configs.includes(option);
4
+ return isOptionIncluded ? configToAdd : [];
5
+ };
24
6
 
25
- /******************************************************************************
26
- Copyright (c) Microsoft Corporation.
27
-
28
- Permission to use, copy, modify, and/or distribute this software for any
29
- purpose with or without fee is hereby granted.
30
-
31
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
32
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
33
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
34
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
35
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37
- PERFORMANCE OF THIS SOFTWARE.
38
- ***************************************************************************** */
39
- /* global Reflect, Promise, SuppressedError, Symbol */
40
-
41
-
42
- var __assign = function() {
43
- __assign = Object.assign || function __assign(t) {
44
- for (var s, i = 1, n = arguments.length; i < n; i++) {
45
- s = arguments[i];
46
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47
- }
48
- return t;
49
- };
50
- return __assign.apply(this, arguments);
51
- };
52
-
53
- function __spreadArray(to, from, pack) {
54
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
- if (ar || !(i in from)) {
56
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
- ar[i] = from[i];
58
- }
59
- }
60
- return to.concat(ar || Array.prototype.slice.call(from));
61
- }
62
-
63
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
64
- var e = new Error(message);
65
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
7
+ // src/utils/has-react-config.ts
8
+ var hasReactConfig = (configs) => {
9
+ if (!configs) return false;
10
+ return ReactConfigs.some((reactConfig2) => configs.includes(reactConfig2));
66
11
  };
67
12
 
13
+ // src/configs/astro/index.config.ts
14
+ import pluginAstro from "eslint-plugin-astro";
15
+
16
+ // src/configs/js/rules.ts
68
17
  var groups = [
69
- // Internal packages.
70
- // Atomic Design and components
71
- ['^(components|@/components|@components)(/.*|$)'],
72
- ['^(ui|@/ui|@ui)(/.*|$)'],
73
- ['^(atoms|@/atoms|@atoms)(/.*|$)'],
74
- ['^(molecules|@/molecules|@molecules)(/.*|$)'],
75
- ['^(organisms|@/organisms|@organisms)(/.*|$)'],
76
- ['^(templates|@/templates|@templates)(/.*|$)'],
77
- ['^(pages|@/pages|@pages)(/.*|$)'],
78
- // Other posible folders
79
- ['^(store|@/store|@store)(/.*|$)'],
80
- ['^(api|@/api|@api)(/.*|$)'],
81
- ['^(contexts|@/contexts|@contexts)(/.*|$)'],
82
- ['^(hooks|@/hooks|@hooks)(/.*|$)'],
83
- ['^(lib|@/lib|@lib)(/.*|$)'],
84
- ['^(services|@/services|@services)(/.*|$)'],
85
- ['^(models|@/models|@models)(/.*|$)'],
86
- ['^(utils|@/utils|@utils)(/.*|$)'],
87
- ['^(ws|@/ws|@ws)(/.*|$)'],
88
- // npm packages
89
- // Anything that starts with a letter (or digit or underscore), or `@` followed by a letter.
90
- ['^\\w'],
91
- // Side effect imports.
92
- ['^\\u0000'],
93
- // Other relative imports. Put same-folder imports and `.` last.
94
- ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
95
- // Parent imports. Put `..` last.
96
- ['^\\.\\.(?!/?$)', '^\\.\\./?$'],
97
- // Style imports.
98
- ['^.+\\.?(css|scss)$']
18
+ // Internal packages.
19
+ // Atomic Design and components
20
+ ["^(components|@/components|@components)(/.*|$)"],
21
+ ["^(ui|@/ui|@ui)(/.*|$)"],
22
+ ["^(atoms|@/atoms|@atoms)(/.*|$)"],
23
+ ["^(molecules|@/molecules|@molecules)(/.*|$)"],
24
+ ["^(organisms|@/organisms|@organisms)(/.*|$)"],
25
+ ["^(templates|@/templates|@templates)(/.*|$)"],
26
+ ["^(pages|@/pages|@pages)(/.*|$)"],
27
+ // Other posible folders
28
+ ["^(store|@/store|@store)(/.*|$)"],
29
+ ["^(api|@/api|@api)(/.*|$)"],
30
+ ["^(contexts|@/contexts|@contexts)(/.*|$)"],
31
+ ["^(hooks|@/hooks|@hooks)(/.*|$)"],
32
+ ["^(lib|@/lib|@lib)(/.*|$)"],
33
+ ["^(services|@/services|@services)(/.*|$)"],
34
+ ["^(models|@/models|@models)(/.*|$)"],
35
+ ["^(utils|@/utils|@utils)(/.*|$)"],
36
+ ["^(ws|@/ws|@ws)(/.*|$)"],
37
+ // npm packages
38
+ // Anything that starts with a letter (or digit or underscore), or `@` followed by a letter.
39
+ ["^\\w"],
40
+ // Side effect imports.
41
+ ["^\\u0000"],
42
+ // Other relative imports. Put same-folder imports and `.` last.
43
+ ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
44
+ // Parent imports. Put `..` last.
45
+ ["^\\.\\.(?!/?$)", "^\\.\\./?$"],
46
+ // Style imports.
47
+ ["^.+\\.?(css|scss)$"]
99
48
  ];
100
- var rules$5 = {
101
- 'unused-imports/no-unused-imports': 'warn',
102
- indent: 'off',
103
- 'brace-style': 'off',
104
- '@stylistic/brace-style': ['warn', '1tbs'],
105
- '@stylistic/indent': ['warn', 2],
106
- '@stylistic/quote-props': ['warn', 'as-needed'],
107
- quotes: 'off',
108
- '@stylistic/quotes': ['warn', 'single'],
109
- '@stylistic/semi': ['warn', 'never'],
110
- 'quote-props': 'off',
111
- 'comma-dangle': 'off',
112
- '@stylistic/comma-dangle': ['warn', 'never'],
113
- '@stylistic/object-curly-spacing': ['warn', 'always'],
114
- '@stylistic/padded-blocks': ['warn', 'never'],
115
- '@stylistic/arrow-parens': ['warn', 'as-needed'],
116
- '@stylistic/dot-location': ['warn', 'property'],
117
- '@stylistic/function-call-argument-newline': ['warn', 'never'],
118
- '@stylistic/object-property-newline': [
119
- 'warn',
120
- { allowAllPropertiesOnSameLine: true }
121
- ],
122
- '@stylistic/multiline-ternary': ['warn', 'always-multiline'],
123
- '@stylistic/member-delimiter-style': ['error', {
124
- multiline: {
125
- delimiter: 'none',
126
- requireLast: false
127
- },
128
- singleline: {
129
- delimiter: 'comma',
130
- requireLast: false
131
- },
132
- overrides: {
133
- interface: {
134
- multiline: {
135
- delimiter: 'none',
136
- requireLast: false
137
- }
138
- }
139
- }
140
- }],
141
- '@stylistic/no-extra-parens': 'off',
142
- '@stylistic/max-len': [
143
- 'warn',
144
- {
145
- code: 120,
146
- tabWidth: 2,
147
- comments: 200,
148
- ignoreStrings: true
149
- }
150
- ],
151
- '@stylistic/max-statements-per-line': ['warn', { max: 1 }],
152
- '@stylistic/array-element-newline': ['warn', 'consistent'],
153
- '@stylistic/no-extra-semi': 'off',
154
- '@stylistic/no-multi-spaces': 'off',
155
- '@stylistic/padding-line-between-statements': [
156
- 'warn',
157
- { blankLine: 'always', prev: '*', next: '*' },
158
- { blankLine: 'any', prev: 'import', next: 'import' },
159
- {
160
- blankLine: 'always',
161
- prev: ['const', 'let', 'var'],
162
- next: ['const', 'let', 'var']
163
- },
164
- {
165
- blankLine: 'never',
166
- prev: ['singleline-const', 'singleline-let', 'singleline-var'],
167
- next: ['singleline-const', 'singleline-let', 'singleline-var']
168
- },
169
- { blankLine: 'always', prev: 'block-like', next: 'const' },
170
- { blankLine: 'always', prev: 'const', next: 'block-like' }
171
- ],
172
- '@stylistic/function-paren-newline': ['warn', 'consistent'],
173
- 'arrow-body-style': ['warn', 'as-needed'],
174
- 'prefer-arrow-callback': ['warn', { allowNamedFunctions: true }],
175
- 'func-style': ['warn', 'expression', { allowArrowFunctions: true }],
176
- 'simple-import-sort/imports': [
177
- 'warn',
178
- {
179
- groups: groups
180
- }
181
- ],
182
- 'jsx-a11y/alt-text': 'warn',
183
- 'no-empty': 'warn',
184
- 'no-nested-ternary': 'warn',
185
- 'no-undef': 'warn',
186
- 'unused-imports/no-unused-vars': [
187
- 'warn',
188
- {
189
- vars: 'all',
190
- varsIgnorePattern: '^_',
191
- args: 'after-used',
192
- argsIgnorePattern: '^_',
193
- destructuredArrayIgnorePattern: '^_',
194
- ignoreRestSiblings: true
195
- }
196
- ],
197
- 'no-void': 'warn',
198
- camelcase: 'warn',
199
- 'array-callback-return': 'warn',
200
- 'no-fallthrough': 'warn',
201
- eqeqeq: 'warn',
202
- 'no-constant-binary-expression': 'warn',
203
- '@stylistic/lines-around-comment': 'warn',
204
- 'import/no-duplicates': 'warn',
205
- 'valid-typeof': 'warn',
206
- 'no-constant-condition': 'warn',
207
- 'no-use-before-define': 'warn',
208
- '@stylistic/implicit-arrow-linebreak': 'warn',
209
- 'import/export': 'warn',
210
- 'no-useless-escape': 'warn',
211
- 'no-useless-return': 'warn',
212
- 'prefer-promise-reject-errors': 'warn',
213
- 'no-useless-constructor': 'warn',
214
- 'no-new': 'warn',
215
- 'prefer-regex-literals': 'warn',
216
- '@stylistic/multiline-comment-style': 'off',
217
- 'space-before-function-paren': 'off'
218
- };
219
-
220
- var rules$4 = {
221
- 'simple-import-sort/imports': [
222
- 'warn',
223
- {
224
- groups: __spreadArray([
225
- // Packages `react` related packages come first.
226
- ['^react'],
227
- ['^(astro)(/.*|$)?']
228
- ], groups, true)
49
+ var rules = {
50
+ "unused-imports/no-unused-imports": "warn",
51
+ indent: "off",
52
+ "brace-style": "off",
53
+ "@stylistic/brace-style": ["warn", "1tbs"],
54
+ "@stylistic/indent": ["warn", 2],
55
+ "@stylistic/quote-props": ["warn", "as-needed"],
56
+ quotes: "off",
57
+ "@stylistic/quotes": ["warn", "single"],
58
+ "@stylistic/semi": ["warn", "never"],
59
+ "quote-props": "off",
60
+ "comma-dangle": "off",
61
+ "@stylistic/comma-dangle": ["warn", "never"],
62
+ "@stylistic/object-curly-spacing": ["warn", "always"],
63
+ "@stylistic/padded-blocks": ["warn", "never"],
64
+ "@stylistic/arrow-parens": ["warn", "as-needed"],
65
+ "@stylistic/dot-location": ["warn", "property"],
66
+ "@stylistic/function-call-argument-newline": ["warn", "never"],
67
+ "@stylistic/object-property-newline": [
68
+ "warn",
69
+ { allowAllPropertiesOnSameLine: true }
70
+ ],
71
+ "@stylistic/multiline-ternary": ["warn", "always-multiline"],
72
+ "@stylistic/member-delimiter-style": ["error", {
73
+ multiline: {
74
+ delimiter: "none",
75
+ requireLast: false
76
+ },
77
+ singleline: {
78
+ delimiter: "comma",
79
+ requireLast: false
80
+ },
81
+ overrides: {
82
+ interface: {
83
+ multiline: {
84
+ delimiter: "none",
85
+ requireLast: false
229
86
  }
230
- ],
231
- // Disable no-unresolved rule for .astro files
232
- 'react/jsx-filename-extension': [1, { extensions: ['.astro'] }], // Accept jsx in astro files
233
- 'react/destructuring-assignment': 'off', // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
234
- 'react/require-default-props': 'off', // Allow non-defined react props as undefined
235
- 'react/jsx-props-no-spreading': 'off', // _app.tsx uses spread operator and also, react-hook-form
236
- 'react/react-in-jsx-scope': 'off',
237
- 'react/no-unknown-property': 'off',
238
- // Disable conflicted rules
239
- '@stylistic/jsx-indent': 'off',
240
- '@stylistic/jsx-one-expression-per-line': 'off',
241
- '@stylistic/jsx-tag-spacing': 'off',
242
- 'react/jsx-key': 'off'
87
+ }
88
+ }
89
+ }],
90
+ "@stylistic/no-extra-parens": "off",
91
+ "@stylistic/max-len": [
92
+ "warn",
93
+ {
94
+ code: 120,
95
+ tabWidth: 2,
96
+ comments: 200,
97
+ ignoreStrings: true
98
+ }
99
+ ],
100
+ "@stylistic/max-statements-per-line": ["warn", { max: 1 }],
101
+ "@stylistic/array-element-newline": ["warn", "consistent"],
102
+ "@stylistic/no-extra-semi": "off",
103
+ "@stylistic/no-multi-spaces": "off",
104
+ "@stylistic/padding-line-between-statements": [
105
+ "warn",
106
+ { blankLine: "always", prev: "*", next: "*" },
107
+ { blankLine: "any", prev: "import", next: "import" },
108
+ {
109
+ blankLine: "always",
110
+ prev: ["const", "let", "var"],
111
+ next: ["const", "let", "var"]
112
+ },
113
+ {
114
+ blankLine: "never",
115
+ prev: ["singleline-const", "singleline-let", "singleline-var"],
116
+ next: ["singleline-const", "singleline-let", "singleline-var"]
117
+ },
118
+ { blankLine: "always", prev: "block-like", next: "const" },
119
+ { blankLine: "always", prev: "const", next: "block-like" }
120
+ ],
121
+ "@stylistic/function-paren-newline": ["warn", "consistent"],
122
+ "arrow-body-style": ["warn", "as-needed"],
123
+ "prefer-arrow-callback": ["warn", { allowNamedFunctions: true }],
124
+ "func-style": ["warn", "expression", { allowArrowFunctions: true }],
125
+ "simple-import-sort/imports": [
126
+ "warn",
127
+ {
128
+ groups
129
+ }
130
+ ],
131
+ "jsx-a11y/alt-text": "warn",
132
+ "no-empty": "warn",
133
+ "no-nested-ternary": "warn",
134
+ "no-undef": "warn",
135
+ "unused-imports/no-unused-vars": [
136
+ "warn",
137
+ {
138
+ vars: "all",
139
+ varsIgnorePattern: "^_",
140
+ args: "after-used",
141
+ argsIgnorePattern: "^_",
142
+ destructuredArrayIgnorePattern: "^_",
143
+ ignoreRestSiblings: true
144
+ }
145
+ ],
146
+ "no-void": "warn",
147
+ camelcase: "warn",
148
+ "array-callback-return": "warn",
149
+ "no-fallthrough": "warn",
150
+ eqeqeq: "warn",
151
+ "no-constant-binary-expression": "warn",
152
+ "@stylistic/lines-around-comment": "warn",
153
+ "import/no-duplicates": "warn",
154
+ "valid-typeof": "warn",
155
+ "no-constant-condition": "warn",
156
+ "no-use-before-define": "warn",
157
+ "@stylistic/implicit-arrow-linebreak": "warn",
158
+ "import/export": "warn",
159
+ "no-useless-escape": "warn",
160
+ "no-useless-return": "warn",
161
+ "prefer-promise-reject-errors": "warn",
162
+ "no-useless-constructor": "warn",
163
+ "no-new": "warn",
164
+ "prefer-regex-literals": "warn",
165
+ "@stylistic/multiline-comment-style": "off",
166
+ "space-before-function-paren": "off"
243
167
  };
244
168
 
245
- var astroConfig = __spreadArray(__spreadArray([], pluginAstro.configs.recommended, true), [
169
+ // src/configs/astro/rules.ts
170
+ var rules2 = {
171
+ "simple-import-sort/imports": [
172
+ "warn",
246
173
  {
247
- files: ['**/*.astro'],
248
- name: 'custom-astro',
249
- rules: rules$4
174
+ groups: [
175
+ // Packages `react` related packages come first.
176
+ ["^react"],
177
+ ["^(astro)(/.*|$)?"],
178
+ ...groups
179
+ ]
250
180
  }
251
- ], false);
181
+ ],
182
+ // Disable no-unresolved rule for .astro files
183
+ "react/jsx-filename-extension": [1, { extensions: [".astro"] }],
184
+ // Accept jsx in astro files
185
+ "react/destructuring-assignment": "off",
186
+ // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
187
+ "react/require-default-props": "off",
188
+ // Allow non-defined react props as undefined
189
+ "react/jsx-props-no-spreading": "off",
190
+ // _app.tsx uses spread operator and also, react-hook-form
191
+ "react/react-in-jsx-scope": "off",
192
+ "react/no-unknown-property": "off",
193
+ // Disable conflicted rules
194
+ "@stylistic/jsx-indent": "off",
195
+ "@stylistic/jsx-one-expression-per-line": "off",
196
+ "@stylistic/jsx-tag-spacing": "off",
197
+ "react/jsx-key": "off"
198
+ };
199
+
200
+ // src/configs/astro/index.config.ts
201
+ var astroConfig = [
202
+ ...pluginAstro.configs.recommended,
203
+ {
204
+ files: ["**/*.astro"],
205
+ name: "custom-astro",
206
+ rules: rules2
207
+ }
208
+ ];
252
209
 
253
- var languageOptions$1 = {
254
- ecmaVersion: 'latest',
255
- sourceType: 'module',
256
- globals: __assign(__assign({}, globals.browser), globals.node)
210
+ // src/configs/js/index.config.ts
211
+ import configStandard from "eslint-config-standard";
212
+ import pluginImport from "eslint-plugin-import";
213
+ import pluginJsxA11y from "eslint-plugin-jsx-a11y";
214
+ import pluginN from "eslint-plugin-n";
215
+ import pluginPromise from "eslint-plugin-promise";
216
+ import pluginSimpleImport from "eslint-plugin-simple-import-sort";
217
+ import pluginUnusedImport from "eslint-plugin-unused-imports";
218
+ import globals from "globals";
219
+ import eslint from "@eslint/js";
220
+ import pluginStylistic from "@stylistic/eslint-plugin";
221
+ var languageOptions = {
222
+ ecmaVersion: "latest",
223
+ sourceType: "module",
224
+ globals: {
225
+ ...globals.browser,
226
+ ...globals.node
227
+ }
257
228
  };
258
229
  var jsConfig = [
259
- __assign({ name: 'eslint-config' }, eslint.configs.recommended),
260
- {
261
- name: 'plugins',
262
- plugins: {
263
- n: pluginN,
264
- promise: pluginPromise,
265
- import: { rules: pluginImport.rules },
266
- 'simple-import-sort': pluginSimpleImport,
267
- 'jsx-a11y': pluginJsxA11y,
268
- 'unused-imports': pluginUnusedImport,
269
- sonarjs: pluginSonarJs
270
- },
271
- languageOptions: languageOptions$1,
272
- rules: __assign(__assign(__assign({}, configStandard.rules), pluginSonarJs.configs.recommended.rules), { 'import/first': 'off' })
273
- },
274
- __assign({ name: 'stylistic' }, pluginStylistic.configs['recommended-flat']),
275
- {
276
- name: 'custom-js',
277
- languageOptions: languageOptions$1,
278
- files: ['**/*.{js,jsx,mjs,cjs}'],
279
- ignores: ['node_modules/*'],
280
- rules: rules$5
230
+ {
231
+ name: "eslint-config",
232
+ ...eslint.configs.recommended
233
+ },
234
+ {
235
+ name: "plugins",
236
+ plugins: {
237
+ n: pluginN,
238
+ promise: pluginPromise,
239
+ import: { rules: pluginImport.rules },
240
+ "simple-import-sort": pluginSimpleImport,
241
+ "jsx-a11y": pluginJsxA11y,
242
+ "unused-imports": pluginUnusedImport
243
+ // sonarjs: pluginSonarJs
281
244
  },
282
- {
283
- name: 'ignore-node-modules-js',
284
- ignores: ['node_modules/*']
245
+ languageOptions,
246
+ rules: {
247
+ ...configStandard.rules,
248
+ // ...pluginSonarJs.configs.recommended.rules,
249
+ "import/first": "off"
285
250
  }
251
+ },
252
+ {
253
+ name: "stylistic",
254
+ ...pluginStylistic.configs["recommended-flat"]
255
+ },
256
+ {
257
+ name: "custom-js",
258
+ languageOptions,
259
+ files: ["**/*.{js,jsx,mjs,cjs}"],
260
+ ignores: ["node_modules/*"],
261
+ rules
262
+ },
263
+ {
264
+ name: "ignore-node-modules-js",
265
+ ignores: ["node_modules/*"]
266
+ }
286
267
  ];
287
268
 
288
- // Initialize FlatCompat with the base directory and recommended configurations
269
+ // src/utils/flat-compat.ts
270
+ import { getDirname } from "cross-dirname";
271
+ import { FlatCompat } from "@eslint/eslintrc";
289
272
  var flatCompat = new FlatCompat({
290
- baseDirectory: getDirname(),
291
- recommendedConfig: {}
273
+ baseDirectory: getDirname(),
274
+ recommendedConfig: {}
292
275
  });
293
276
 
294
- var rules$3 = {
295
- 'simple-import-sort/imports': [
296
- 'warn',
297
- {
298
- groups: __spreadArray([
299
- // Packages `react` related packages come first.
300
- ['^react'],
301
- ['^(next)(/.*|$)?']
302
- ], groups, true)
303
- }
304
- ]
277
+ // src/configs/next/rules.ts
278
+ var rules3 = {
279
+ "simple-import-sort/imports": [
280
+ "warn",
281
+ {
282
+ groups: [
283
+ // Packages `react` related packages come first.
284
+ ["^react"],
285
+ ["^(next)(/.*|$)?"],
286
+ ...groups
287
+ ]
288
+ }
289
+ ]
305
290
  };
306
291
 
307
- var nextConfig = __spreadArray(__spreadArray([], fixupConfigRules(flatCompat.extends('plugin:@next/next/core-web-vitals')), true), [
308
- {
309
- name: 'custom-next',
310
- rules: rules$3
311
- },
292
+ // src/configs/next/index.config.ts
293
+ import { fixupConfigRules } from "@eslint/compat";
294
+ var nextConfig = [
295
+ ...fixupConfigRules(flatCompat.extends("plugin:@next/next/core-web-vitals")),
296
+ {
297
+ name: "custom-next",
298
+ rules: rules3
299
+ },
300
+ {
301
+ name: "ignore-next-folder",
302
+ ignores: [".next/*"]
303
+ }
304
+ ];
305
+
306
+ // src/configs/react/index.config.ts
307
+ import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
308
+ import pluginReactHooks from "eslint-plugin-react-hooks";
309
+ import globals2 from "globals";
310
+
311
+ // src/configs/react/rules.ts
312
+ var rules4 = {
313
+ "react/react-in-jsx-scope": "off",
314
+ "react/jsx-max-depth": ["warn", { max: 7 }],
315
+ "react/prop-types": "off",
316
+ "react-hooks/exhaustive-deps": "off",
317
+ "react/button-has-type": "warn",
318
+ "react/display-name": "warn",
319
+ "react/no-children-prop": "warn",
320
+ "react/no-danger-with-children": "warn",
321
+ "react/no-unstable-nested-components": "warn",
322
+ "react/self-closing-comp": ["warn", { component: true, html: true }],
323
+ "react/jsx-curly-brace-presence": [
324
+ "warn",
325
+ { props: "never", children: "never" }
326
+ ],
327
+ "react/jsx-curly-newline": "warn",
328
+ "react/destructuring-assignment": "warn",
329
+ "react/jsx-pascal-case": "warn",
330
+ "react/boolean-prop-naming": "warn",
331
+ "react/hook-use-state": "warn",
332
+ "react/jsx-boolean-value": "warn",
333
+ "react/jsx-closing-tag-location": "warn",
334
+ "react/jsx-closing-bracket-location": "warn",
335
+ "react/jsx-wrap-multilines": "warn",
336
+ "react/jsx-no-target-blank": "warn",
337
+ "react/jsx-no-leaked-render": "warn",
338
+ "react/jsx-handler-names": "warn",
339
+ "react/jsx-fragments": "warn",
340
+ "react/no-deprecated": "warn",
341
+ "react/no-multi-comp": "warn",
342
+ "react/no-unescaped-entities": "warn",
343
+ "react/jsx-no-undef": "warn",
344
+ "react/no-unknown-property": "warn",
345
+ "simple-import-sort/imports": [
346
+ "warn",
312
347
  {
313
- name: 'ignore-next-folder',
314
- ignores: ['.next/*']
348
+ groups: [
349
+ // Packages `react` related packages come first.
350
+ ["^react"],
351
+ ...groups
352
+ ]
315
353
  }
316
- ], false);
317
-
318
- var rules$2 = {
319
- 'react/react-in-jsx-scope': 'off',
320
- 'react/jsx-max-depth': ['warn', { max: 7 }],
321
- 'react/prop-types': 'off',
322
- 'react-hooks/exhaustive-deps': 'off',
323
- 'react/button-has-type': 'warn',
324
- 'react/display-name': 'warn',
325
- 'react/no-children-prop': 'warn',
326
- 'react/no-danger-with-children': 'warn',
327
- 'react/no-unstable-nested-components': 'warn',
328
- 'react/self-closing-comp': ['warn', { component: true, html: true }],
329
- 'react/jsx-curly-brace-presence': [
330
- 'warn',
331
- { props: 'never', children: 'never' }
332
- ],
333
- 'react/jsx-curly-newline': 'warn',
334
- 'react/destructuring-assignment': 'warn',
335
- 'react/jsx-pascal-case': 'warn',
336
- 'react/boolean-prop-naming': 'warn',
337
- 'react/hook-use-state': 'warn',
338
- 'react/jsx-boolean-value': 'warn',
339
- 'react/jsx-closing-tag-location': 'warn',
340
- 'react/jsx-closing-bracket-location': 'warn',
341
- 'react/jsx-wrap-multilines': 'warn',
342
- 'react/jsx-no-target-blank': 'warn',
343
- 'react/jsx-no-leaked-render': 'warn',
344
- 'react/jsx-handler-names': 'warn',
345
- 'react/jsx-fragments': 'warn',
346
- 'react/no-deprecated': 'warn',
347
- 'react/no-multi-comp': 'warn',
348
- 'react/no-unescaped-entities': 'warn',
349
- 'react/jsx-no-undef': 'warn',
350
- 'react/no-unknown-property': 'warn',
351
- 'simple-import-sort/imports': [
352
- 'warn',
353
- {
354
- groups: __spreadArray([
355
- // Packages `react` related packages come first.
356
- ['^react']
357
- ], groups, true)
358
- }
359
- ]
354
+ ]
360
355
  };
361
356
 
362
- var languageOptions = __assign(__assign({ ecmaVersion: 'latest', sourceType: 'module' }, pluginReactConfig.languageOptions), { globals: __assign(__assign({}, globals.browser), globals.node) });
363
- var reactConfig = __spreadArray(__spreadArray([], fixupConfigRules(pluginReactConfig).map(function (react) { return (__assign(__assign({}, react), { name: 'react', languageOptions: languageOptions, settings: {
364
- react: {
365
- version: 'detect'
366
- }
367
- } })); }), true), [
368
- {
369
- name: 'custom-react',
370
- plugins: {
371
- 'react-hooks': pluginReactHooks
372
- },
373
- languageOptions: languageOptions,
374
- files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
375
- rules: __assign(__assign({}, pluginReactHooks.configs.recommended.rules), rules$2)
357
+ // src/configs/react/index.config.ts
358
+ import { fixupConfigRules as fixupConfigRules2 } from "@eslint/compat";
359
+ var languageOptions2 = {
360
+ ecmaVersion: "latest",
361
+ sourceType: "module",
362
+ ...pluginReactConfig.languageOptions,
363
+ globals: {
364
+ ...globals2.browser,
365
+ ...globals2.node
366
+ }
367
+ };
368
+ var reactConfig = [
369
+ ...fixupConfigRules2(pluginReactConfig).map((react) => ({
370
+ ...react,
371
+ name: "react",
372
+ languageOptions: languageOptions2,
373
+ settings: {
374
+ react: {
375
+ version: "detect"
376
+ }
376
377
  }
377
- ], false);
378
+ })),
379
+ {
380
+ name: "custom-react",
381
+ plugins: {
382
+ "react-hooks": pluginReactHooks
383
+ },
384
+ languageOptions: languageOptions2,
385
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
386
+ rules: {
387
+ ...pluginReactHooks.configs.recommended.rules,
388
+ ...rules4
389
+ }
390
+ }
391
+ ];
378
392
 
379
- var rules$1 = __assign(__assign({}, rules$5), { semi: 'off', 'no-unused-vars': 'off', '@typescript-eslint/indent': 'off', '@typescript-eslint/no-unused-vars': [
380
- 'warn',
381
- {
382
- vars: 'all',
383
- varsIgnorePattern: '^_',
384
- args: 'after-used',
385
- argsIgnorePattern: '^_',
386
- destructuredArrayIgnorePattern: '^_',
387
- ignoreRestSiblings: true
388
- }
389
- ], '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-empty-function': 'warn', '@typescript-eslint/ban-types': 'warn', '@typescript-eslint/no-var-requires': 'warn', '@typescript-eslint/ban-ts-comment': 'warn', '@typescript-eslint/no-non-null-assertion': 'warn', '@typescript-eslint/no-invalid-void-type': 'warn', '@typescript-eslint/no-dynamic-delete': 'warn', '@typescript-eslint/no-useless-constructor': 'warn', '@typescript-eslint/prefer-for-of': 'warn', '@typescript-eslint/no-duplicate-enum-values': 'warn' });
393
+ // src/configs/ts/index.config.ts
394
+ import tsEslint from "typescript-eslint";
390
395
 
391
- var tsConfig = __spreadArray(__spreadArray([], tsEslint.configs.stylistic, true), [
396
+ // src/configs/ts/rules.ts
397
+ var rules5 = {
398
+ // ! js rules are not enabled in ts files, eslint rules would be duplicated, this can be improved in the future
399
+ ...rules,
400
+ semi: "off",
401
+ "no-unused-vars": "off",
402
+ "@typescript-eslint/indent": "off",
403
+ "@typescript-eslint/no-unused-vars": [
404
+ "warn",
392
405
  {
393
- name: 'custom-ts',
394
- files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
395
- rules: rules$1,
396
- languageOptions: {
397
- parserOptions: {
398
- parser: tsParser
399
- },
400
- ecmaVersion: 'latest'
401
- }
402
- },
403
- {
404
- name: 'ignore-node-modules-ts',
405
- ignores: ['node_modules/*']
406
+ vars: "all",
407
+ varsIgnorePattern: "^_",
408
+ args: "after-used",
409
+ argsIgnorePattern: "^_",
410
+ destructuredArrayIgnorePattern: "^_",
411
+ ignoreRestSiblings: true
406
412
  }
407
- ], false);
408
-
409
- var rules = {
410
- 'simple-import-sort/imports': [
411
- 'warn',
412
- {
413
- groups: __spreadArray([
414
- // Packages `react` related packages come first.
415
- ['^react'],
416
- ['^(expo)(/.*|$)?']
417
- ], groups, true)
418
- }
419
- ]
413
+ ],
414
+ "@typescript-eslint/no-explicit-any": "warn",
415
+ "@typescript-eslint/no-empty-function": "warn",
416
+ "@typescript-eslint/no-empty-object-type": "warn",
417
+ "@typescript-eslint/no-unsafe-function-type": "warn",
418
+ "@typescript-eslint/no-wrapper-object-types": "warn",
419
+ "@typescript-eslint/no-var-requires": "warn",
420
+ "@typescript-eslint/ban-ts-comment": "warn",
421
+ "@typescript-eslint/no-non-null-assertion": "warn",
422
+ "@typescript-eslint/no-invalid-void-type": "warn",
423
+ "@typescript-eslint/no-dynamic-delete": "warn",
424
+ "@typescript-eslint/no-useless-constructor": "warn",
425
+ "@typescript-eslint/prefer-for-of": "warn",
426
+ "@typescript-eslint/no-duplicate-enum-values": "warn"
420
427
  };
421
428
 
422
- var expoConfig = __spreadArray(__spreadArray([], fixupConfigRules(flatCompat.extends('expo')), true), [
423
- {
424
- name: 'custom-expo',
425
- rules: rules
429
+ // src/configs/ts/index.config.ts
430
+ import tsParser from "@typescript-eslint/parser";
431
+ var tsConfig = [
432
+ ...tsEslint.configs.stylistic,
433
+ {
434
+ name: "custom-ts",
435
+ files: ["**/*.{ts,tsx,mts,cts}"],
436
+ rules: rules5,
437
+ languageOptions: {
438
+ parserOptions: {
439
+ parser: tsParser
440
+ },
441
+ ecmaVersion: "latest"
426
442
  }
427
- ], false);
443
+ }
444
+ // TODO: Temporal
445
+ // {
446
+ // name: 'ignore-node-modules-ts',
447
+ // ignores: ['node_modules/*']
448
+ // }
449
+ ];
428
450
 
429
- var cspell = [
451
+ // src/configs/expo/rules.ts
452
+ var rules6 = {
453
+ "simple-import-sort/imports": [
454
+ "warn",
430
455
  {
431
- name: 'cspell',
432
- plugins: { '@cspell': pluginCspell }
456
+ groups: [
457
+ // Packages `react` related packages come first.
458
+ ["^react"],
459
+ ["^(expo)(/.*|$)?"],
460
+ ...groups
461
+ ]
433
462
  }
463
+ ]
464
+ };
465
+
466
+ // src/configs/expo/index.config.ts
467
+ import { fixupConfigRules as fixupConfigRules3 } from "@eslint/compat";
468
+ var expoConfig = [
469
+ ...fixupConfigRules3(flatCompat.extends("expo")),
470
+ {
471
+ name: "custom-expo",
472
+ rules: rules6
473
+ }
434
474
  ];
435
475
 
436
- var i18next = __spreadArray([], fixupConfigRules(flatCompat.plugins('i18next')), true);
476
+ // src/optionals/cspell.ts
477
+ import pluginCspell from "@cspell/eslint-plugin";
478
+ var cspell = [
479
+ {
480
+ name: "cspell",
481
+ plugins: { "@cspell": pluginCspell }
482
+ }
483
+ ];
437
484
 
485
+ // src/optionals/i18next.ts
486
+ import { fixupConfigRules as fixupConfigRules4 } from "@eslint/compat";
487
+ var i18next = [
488
+ ...fixupConfigRules4(flatCompat.plugins("i18next"))
489
+ ];
490
+
491
+ // src/optionals/mdx.ts
492
+ import pluginMdx from "eslint-plugin-mdx";
438
493
  var mdx = [
439
- __assign({}, pluginMdx.flat),
440
- __assign(__assign({}, pluginMdx.flatCodeBlocks), { rules: __assign({}, pluginMdx.flatCodeBlocks.rules) })
494
+ {
495
+ ...pluginMdx.flat
496
+ },
497
+ {
498
+ ...pluginMdx.flatCodeBlocks,
499
+ rules: {
500
+ ...pluginMdx.flatCodeBlocks.rules
501
+ }
502
+ }
441
503
  ];
442
504
 
443
- var tailwind = __spreadArray([], pluginTailwind.configs['flat/recommended'], true);
505
+ // src/optionals/tailwind.ts
506
+ import pluginTailwind from "eslint-plugin-tailwindcss";
507
+ var tailwind = [...pluginTailwind.configs["flat/recommended"]];
444
508
 
445
- var vitest = __spreadArray(__spreadArray([], fixupConfigRules(flatCompat.extends('plugin:testing-library/react')), true), [
446
- pluginVitest.configs.recommended,
447
- {
448
- name: 'custom-vitest',
449
- rules: {
450
- 'vitest/expect-expect': [
451
- 'error',
452
- {
453
- assertFunctionNames: ['expect', 'assert', 'should']
454
- }
455
- ]
509
+ // src/optionals/vitest.ts
510
+ import pluginVitest from "eslint-plugin-vitest";
511
+ import { fixupConfigRules as fixupConfigRules5 } from "@eslint/compat";
512
+ var vitest = [
513
+ ...fixupConfigRules5(flatCompat.extends("plugin:testing-library/react")),
514
+ {
515
+ name: "vitest",
516
+ files: ["tests/**"],
517
+ // or any other pattern
518
+ plugins: {
519
+ vitest: pluginVitest
520
+ },
521
+ rules: {
522
+ ...pluginVitest.configs.recommended.rules,
523
+ // you can also use vitest.configs.all.rules to enable all rules
524
+ "vitest/max-nested-describe": ["error", { max: 3 }],
525
+ // you can also modify rules' behavior using option like this
526
+ "vitest/expect-expect": [
527
+ "error",
528
+ {
529
+ assertFunctionNames: ["expect", "assert", "should"]
456
530
  }
531
+ ]
457
532
  }
458
- ], false);
533
+ }
534
+ ];
459
535
 
460
- var ConfigOptions;
461
- (function (ConfigOptions) {
462
- ConfigOptions["Ts"] = "ts";
463
- ConfigOptions["React"] = "react";
464
- ConfigOptions["Next"] = "next";
465
- ConfigOptions["Expo"] = "expo";
466
- ConfigOptions["Astro"] = "astro";
467
- })(ConfigOptions || (ConfigOptions = {}));
468
- var OptionalOptions;
469
- (function (OptionalOptions) {
470
- OptionalOptions["Cspell"] = "cspell";
471
- OptionalOptions["Tailwind"] = "tailwind";
472
- OptionalOptions["Vitest"] = "vitest";
473
- OptionalOptions["I18next"] = "i18next";
474
- OptionalOptions["Mdx"] = "mdx";
475
- })(OptionalOptions || (OptionalOptions = {}));
536
+ // src/index.ts
537
+ var ConfigOption2 = /* @__PURE__ */ ((ConfigOption3) => {
538
+ ConfigOption3["Ts"] = "ts";
539
+ ConfigOption3["React"] = "react";
540
+ ConfigOption3["Next"] = "next";
541
+ ConfigOption3["Expo"] = "expo";
542
+ ConfigOption3["Astro"] = "astro";
543
+ return ConfigOption3;
544
+ })(ConfigOption2 || {});
545
+ var OptionalOption = /* @__PURE__ */ ((OptionalOption2) => {
546
+ OptionalOption2["Cspell"] = "cspell";
547
+ OptionalOption2["Tailwind"] = "tailwind";
548
+ OptionalOption2["Vitest"] = "vitest";
549
+ OptionalOption2["I18next"] = "i18next";
550
+ OptionalOption2["Mdx"] = "mdx";
551
+ return OptionalOption2;
552
+ })(OptionalOption || {});
476
553
  var ReactConfigs = [
477
- ConfigOptions.React,
478
- ConfigOptions.Astro,
479
- ConfigOptions.Next,
480
- ConfigOptions.Expo
554
+ "react" /* React */,
555
+ "astro" /* Astro */,
556
+ "next" /* Next */,
557
+ "expo" /* Expo */
481
558
  ];
482
- // !important: The array order is important, the lower the more important
483
- var eslintConfig = function (_a) {
484
- var _b = _a === void 0 ? {} : _a, config = _b.config, optionals = _b.optionals;
485
- var hasReact = ReactConfigs.some(function (reactConfig) { return config === null || config === void 0 ? void 0 : config.includes(reactConfig); });
486
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], jsConfig, true), (hasReact ? reactConfig : []), true), ((config === null || config === void 0 ? void 0 : config.includes(ConfigOptions.Ts)) ? tsConfig : []), true), ((config === null || config === void 0 ? void 0 : config.includes(ConfigOptions.Next)) ? nextConfig : []), true), ((config === null || config === void 0 ? void 0 : config.includes(ConfigOptions.Astro)) ? astroConfig : []), true), ((config === null || config === void 0 ? void 0 : config.includes(ConfigOptions.Expo)) ? expoConfig : []), true), ((optionals === null || optionals === void 0 ? void 0 : optionals.includes(OptionalOptions.Cspell)) ? cspell : []), true), ((optionals === null || optionals === void 0 ? void 0 : optionals.includes(OptionalOptions.Tailwind)) ? tailwind : []), true), ((optionals === null || optionals === void 0 ? void 0 : optionals.includes(OptionalOptions.Vitest)) ? vitest : []), true), ((optionals === null || optionals === void 0 ? void 0 : optionals.includes(OptionalOptions.I18next)) ? i18next : []), true), ((optionals === null || optionals === void 0 ? void 0 : optionals.includes(OptionalOptions.Mdx)) ? mdx : []), true);
559
+ var eslintConfig = ({ config = [], optionals = [] } = {}) => {
560
+ const hasReact = hasReactConfig(config);
561
+ return [
562
+ ...jsConfig,
563
+ ...hasReact ? reactConfig : [],
564
+ ...applyConfigIfOptionPresent(config, "ts" /* Ts */, tsConfig),
565
+ ...applyConfigIfOptionPresent(config, "next" /* Next */, nextConfig),
566
+ ...applyConfigIfOptionPresent(config, "astro" /* Astro */, astroConfig),
567
+ ...applyConfigIfOptionPresent(config, "expo" /* Expo */, expoConfig),
568
+ ...optionals.includes("cspell" /* Cspell */) ? cspell : [],
569
+ ...optionals.includes("tailwind" /* Tailwind */) ? tailwind : [],
570
+ ...optionals.includes("vitest" /* Vitest */) ? vitest : [],
571
+ ...optionals.includes("i18next" /* I18next */) ? i18next : [],
572
+ ...optionals.includes("mdx" /* Mdx */) ? mdx : []
573
+ ];
574
+ };
575
+ export {
576
+ ConfigOption2 as ConfigOption,
577
+ OptionalOption,
578
+ ReactConfigs,
579
+ eslintConfig
487
580
  };
488
-
489
- export { ConfigOptions, OptionalOptions, eslintConfig };