@santi020k/eslint-config-santi020k 1.2.1 → 2.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 ADDED
@@ -0,0 +1,453 @@
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';
21
+
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;
63
+ };
64
+
65
+ // Initialize FlatCompat with the base directory and recommended configurations
66
+ var flatCompat = new FlatCompat({
67
+ baseDirectory: getDirname(),
68
+ recommendedConfig: {}
69
+ });
70
+
71
+ 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)$']
102
+ ];
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)
232
+ }
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), [
254
+ {
255
+ name: 'custom-astro',
256
+ rules: rules$4
257
+ }
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),
267
+ {
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' })
280
+ },
281
+ __assign({ name: 'stylistic' }, pluginStylistic.configs['recommended-flat']),
282
+ {
283
+ name: 'custom-js',
284
+ languageOptions: languageOptions$1,
285
+ files: ['**/*.{js,jsx,mjs,cjs}'],
286
+ rules: rules$5
287
+ }
288
+ ];
289
+
290
+ var rules$3 = {
291
+ 'simple-import-sort/imports': [
292
+ 'warn',
293
+ {
294
+ groups: __spreadArray([
295
+ // Packages `react` related packages come first.
296
+ ['^react'],
297
+ ['^(next)(/.*|$)?']
298
+ ], groups, true)
299
+ }
300
+ ]
301
+ };
302
+
303
+ var nextConfig = __spreadArray(__spreadArray([], fixupConfigRules(flatCompat.extends('plugin:@next/next/core-web-vitals')), true), [
304
+ {
305
+ name: 'custom-next',
306
+ rules: rules$3
307
+ }
308
+ ], false);
309
+
310
+ var rules$2 = {
311
+ 'react/react-in-jsx-scope': 'off',
312
+ 'react/jsx-max-depth': ['warn', { max: 7 }],
313
+ 'react/prop-types': 'off',
314
+ 'react-hooks/exhaustive-deps': 'off',
315
+ 'react/button-has-type': 'warn',
316
+ 'react/display-name': 'warn',
317
+ 'react/no-children-prop': 'warn',
318
+ 'react/no-danger-with-children': 'warn',
319
+ 'react/no-unstable-nested-components': 'warn',
320
+ 'react/self-closing-comp': ['warn', { component: true, html: true }],
321
+ 'react/jsx-curly-brace-presence': [
322
+ 'warn',
323
+ { props: 'never', children: 'never' }
324
+ ],
325
+ 'react/jsx-curly-newline': 'warn',
326
+ 'react/destructuring-assignment': 'warn',
327
+ 'react/jsx-pascal-case': 'warn',
328
+ 'react/boolean-prop-naming': 'warn',
329
+ 'react/hook-use-state': 'warn',
330
+ 'react/jsx-boolean-value': 'warn',
331
+ 'react/jsx-closing-tag-location': 'warn',
332
+ 'react/jsx-closing-bracket-location': 'warn',
333
+ 'react/jsx-wrap-multilines': 'warn',
334
+ 'react/jsx-no-target-blank': 'warn',
335
+ 'react/jsx-no-leaked-render': 'warn',
336
+ 'react/jsx-handler-names': 'warn',
337
+ 'react/jsx-fragments': 'warn',
338
+ 'react/no-deprecated': 'warn',
339
+ 'react/no-multi-comp': 'warn',
340
+ 'react/no-unescaped-entities': 'warn',
341
+ 'react/jsx-no-undef': 'warn',
342
+ 'react/no-unknown-property': 'warn',
343
+ 'simple-import-sort/imports': [
344
+ 'warn',
345
+ {
346
+ groups: __spreadArray([
347
+ // Packages `react` related packages come first.
348
+ ['^react']
349
+ ], groups, true)
350
+ }
351
+ ]
352
+ };
353
+
354
+ var languageOptions = __assign(__assign({ ecmaVersion: 'latest', sourceType: 'module' }, pluginReactConfig.languageOptions), { globals: __assign(__assign({}, globals.browser), globals.node) });
355
+ var reactConfig = __spreadArray(__spreadArray([], fixupConfigRules(pluginReactConfig).map(function (react) { return (__assign(__assign({}, react), { name: 'react', languageOptions: languageOptions, settings: {
356
+ react: {
357
+ version: 'detect'
358
+ }
359
+ } })); }), true), [
360
+ {
361
+ name: 'custom-react',
362
+ plugins: {
363
+ 'react-hooks': pluginReactHooks
364
+ },
365
+ languageOptions: languageOptions,
366
+ files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
367
+ rules: __assign(__assign({}, pluginReactHooks.configs.recommended.rules), rules$2)
368
+ }
369
+ ], false);
370
+
371
+ var rules$1 = __assign(__assign({}, rules$5), { semi: 'off', 'no-unused-vars': 'off', '@typescript-eslint/indent': 'off', '@typescript-eslint/no-unused-vars': [
372
+ 'warn',
373
+ {
374
+ vars: 'all',
375
+ varsIgnorePattern: '^_',
376
+ args: 'after-used',
377
+ argsIgnorePattern: '^_',
378
+ destructuredArrayIgnorePattern: '^_',
379
+ ignoreRestSiblings: true
380
+ }
381
+ ], '@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' });
382
+
383
+ var tsConfig = __spreadArray(__spreadArray([], tsEslint.configs.stylistic, true), [
384
+ {
385
+ name: 'custom-ts',
386
+ files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
387
+ rules: rules$1
388
+ }
389
+ ], false);
390
+
391
+ var rules = {
392
+ 'simple-import-sort/imports': [
393
+ 'warn',
394
+ {
395
+ groups: __spreadArray([
396
+ // Packages `react` related packages come first.
397
+ ['^react'],
398
+ ['^(expo)(/.*|$)?']
399
+ ], groups, true)
400
+ }
401
+ ]
402
+ };
403
+
404
+ var expoConfig = __spreadArray(__spreadArray([], fixupConfigRules(flatCompat.extends('expo')), true), [
405
+ {
406
+ name: 'custom-expo',
407
+ rules: rules
408
+ }
409
+ ], false);
410
+
411
+ var cspell = [
412
+ {
413
+ name: 'cspell',
414
+ plugins: { '@cspell': pluginCspell }
415
+ }
416
+ ];
417
+
418
+ var i18next = __spreadArray([], fixupConfigRules(flatCompat.plugins('i18next')), true);
419
+
420
+ var tailwind = __spreadArray([], pluginTailwind.configs['flat/recommended'], true);
421
+
422
+ var vitest = __spreadArray(__spreadArray([], fixupConfigRules(flatCompat.extends('plugin:testing-library/react')), true), [
423
+ pluginVitest.configs.recommended
424
+ ], false);
425
+
426
+ var ConfigOptions;
427
+ (function (ConfigOptions) {
428
+ ConfigOptions["Ts"] = "ts";
429
+ ConfigOptions["React"] = "react";
430
+ ConfigOptions["Next"] = "next";
431
+ ConfigOptions["Expo"] = "expo";
432
+ ConfigOptions["Astro"] = "astro";
433
+ })(ConfigOptions || (ConfigOptions = {}));
434
+ var OptionalOptions;
435
+ (function (OptionalOptions) {
436
+ OptionalOptions["Cspell"] = "cspell";
437
+ OptionalOptions["Tailwind"] = "tailwind";
438
+ OptionalOptions["Vitest"] = "vitest";
439
+ OptionalOptions["I18next"] = "i18next";
440
+ })(OptionalOptions || (OptionalOptions = {}));
441
+ var ReactConfigs = [
442
+ ConfigOptions.React,
443
+ ConfigOptions.Next,
444
+ ConfigOptions.Expo
445
+ ];
446
+ // !important: The array order is important, the lower the more important
447
+ var eslintConfig = function (_a) {
448
+ var _b = _a === void 0 ? {} : _a, config = _b.config, optionals = _b.optionals;
449
+ var hasReact = ReactConfigs.some(function (reactConfig) { return config === null || config === void 0 ? void 0 : config.includes(reactConfig); });
450
+ 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);
451
+ };
452
+
453
+ export { ConfigOptions, OptionalOptions, eslintConfig };