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