eslint-config-any 1.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.
Files changed (44) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +89 -0
  3. package/dist/index.js +1 -0
  4. package/package.json +78 -0
  5. package/src/configs/base/index.js +38 -0
  6. package/src/configs/base/plugins/@eslint-community___eslint-comments/index.js +18 -0
  7. package/src/configs/base/plugins/@eslint-community___eslint-comments/rules/index.js +1 -0
  8. package/src/configs/base/plugins/array-func/index.js +19 -0
  9. package/src/configs/base/plugins/array-func/rules/index.js +4 -0
  10. package/src/configs/base/plugins/import/index.js +17 -0
  11. package/src/configs/base/plugins/import/rules/index.js +25 -0
  12. package/src/configs/base/plugins/import-helpers/index.js +17 -0
  13. package/src/configs/base/plugins/import-helpers/rules/index.js +14 -0
  14. package/src/configs/base/plugins/json/index.js +26 -0
  15. package/src/configs/base/plugins/json/rules/index.js +3 -0
  16. package/src/configs/base/plugins/markdown/index.js +5 -0
  17. package/src/configs/base/plugins/markdown/rules/index.js +3 -0
  18. package/src/configs/base/plugins/perfectionist/index.js +17 -0
  19. package/src/configs/base/plugins/perfectionist/rules/index.js +40 -0
  20. package/src/configs/base/plugins/regexp/index.js +19 -0
  21. package/src/configs/base/plugins/regexp/rules/index.js +3 -0
  22. package/src/configs/base/rules/index.js +43 -0
  23. package/src/configs/env/browser/index.js +10 -0
  24. package/src/configs/env/commonjs/index.js +14 -0
  25. package/src/configs/env/index.js +15 -0
  26. package/src/configs/env/jest/index.js +15 -0
  27. package/src/configs/env/node/index.js +13 -0
  28. package/src/configs/env/sharedNodeAndBrowser/index.js +10 -0
  29. package/src/configs/env/vitest/index.js +15 -0
  30. package/src/configs/index.js +42 -0
  31. package/src/configs/prettier/index.js +17 -0
  32. package/src/configs/react/index.js +40 -0
  33. package/src/configs/react/rules/index.js +47 -0
  34. package/src/configs/typescript/index.js +24 -0
  35. package/src/configs/typescript/rules/index.js +23 -0
  36. package/src/configs/vue/index.js +7 -0
  37. package/src/configs/vue/shared/index.js +24 -0
  38. package/src/configs/vue/shared/rules/index.js +77 -0
  39. package/src/configs/vue/v2/index.js +21 -0
  40. package/src/configs/vue/v2/rules/index.js +1 -0
  41. package/src/configs/vue/v3/index.js +21 -0
  42. package/src/configs/vue/v3/rules/index.js +1 -0
  43. package/src/utils/files.js +8 -0
  44. package/src/utils/index.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2025 Julio L. Muller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # ESlint Configuration for Any JS Project
2
+
3
+ <p>
4
+ <img src="https://img.shields.io/npm/v/eslint-config-any" alt="NPM Latest Version" />
5
+
6
+ <img src="https://img.shields.io/npm/dependency-version/eslint-config-any/peer/eslint" alt="Minimum ESlint version" />
7
+
8
+ <img src="https://img.shields.io/npm/dependency-version/eslint-config-any/peer/prettier" alt="Minimum Prettier version" />
9
+
10
+ <img src="https://img.shields.io/npm/dependency-version/eslint-config-any/peer/typescript" alt="Minimum TypeScript version" />
11
+
12
+ <img src="https://img.shields.io/npm/dm/eslint-config-any.svg?style=flat-square" alt="Downloads Count" />
13
+
14
+ <img src="https://img.shields.io/github/last-commit/juliolmuller/eslint-config-any?" alt="Last Update Date" />
15
+
16
+ <img src="https://img.shields.io/github/license/juliolmuller/eslint-config-any" alt="Project License" />
17
+ </p>
18
+
19
+ This package provides strict linting and formatting rules for (almost) all sorts of JavaScript stack projects, like React, Vue, Vanilla, Node and their variants in TypeScript.
20
+
21
+ ## Setup
22
+
23
+ **Plug-and-paly**: this is designed to be as simple as possible to setup, so you can invest your time in your project.
24
+
25
+ 1. Add the necessary packages to your development dependencies:
26
+
27
+ ```bash
28
+ # using NPM
29
+ $ npm install -D eslint-config-any eslint prettier typescript
30
+
31
+ # using Bun
32
+ $ bun add -d eslint-config-any eslint prettier typescript
33
+ ```
34
+
35
+ 2. Create a `eslint.config.mjs` file at project root.
36
+ 3. Write some boilerplate like below, selecting the presets you need:
37
+
38
+ ```js
39
+ // eslint.config.mjs
40
+ import anyConfig from 'eslint-config-any';
41
+
42
+ export default [
43
+ ...anyConfig.react,
44
+ ...anyConfig.vitest,
45
+ ];
46
+ ```
47
+
48
+ ## Which Presets I Can Pick?
49
+
50
+ This package is designed to make you write the less code as possible, so you don't need to deal with scaffold-hell and learning how to setup a ESlint or Prettier configuration.
51
+
52
+ With the latest version of ESlint (9+) and its [Flat Configuration](https://eslint.org/blog/2022/08/new-config-system-part-1/), things got a little more complicated to setup, specially if you seek stricter rules for linting and formatting (like I do). However, things got way more flexible, allowing plugins and configs to apply only to certain files that actually use them for linting. For example, you'll only need `eslint-plugin-vue` for `*.vue` files, ot TypeScript-specific rules in files that actually use TS, and so on.
53
+
54
+ So you'll' just need to select one generalized preset and make small compositions in a few cases.
55
+
56
+ The current presets available are:
57
+
58
+ - `react`: for React projects, adding support not only for basic JS files but also TS, JSX and TSX extensions, as well as providing browser's global variables.
59
+ - `vue`: for Vue 3 projects, adding support not only for basic JS files but also TS and VUE extensions, as well as providing browser's global variables.
60
+ - `vue2`: similar to `vue` option, except it contains some specific rules for Vue v2 only. **Don't select both presets, as they may conflict with each other**.
61
+ - `browser`: if your project does not use nay of the previous frameworks and is meant to run in the client-side, that's the one to go with. It lints files with JS and TS extensions and provides browser's global variables.
62
+ - `node`: if you're writing code for the server-side, use this preset to lint JS and TS files, as well as providing Node's global variables.
63
+ - `sharedNodeAndBrowser`: if you're project targets browser and node environments, this not only lints JS and TS files, but also ensure you only use global variables that are available in both environments.
64
+ - `commonjs`: all the presets above consider projects using ES Modules. But if you're using CommonJS, combine this option to make this standard compatible.
65
+ - `jest`: if you're using Jest as test runner, add this preset in combination of another to allow Jest variables.
66
+ - `vitest`: if you're using Vitest as test runner, add this preset in combination of another to allow Vitest variables.
67
+
68
+ ## Customization
69
+
70
+ Not everyone follow the same rules. Uf you're project is one of these, you can enable disable rules by adding a new object to the configs array:
71
+
72
+ ```js
73
+ // eslint.config.mjs
74
+ import anyConfig from 'eslint-config-any';
75
+
76
+ export default [
77
+ ...anyConfig.node,
78
+ ...anyConfig.commonjs,
79
+ ...anyConfig.jest,
80
+ {
81
+ '@typescript-eslint/explicit-function-return-type': 'off',
82
+ 'no-console': 'off',
83
+ },
84
+ ];
85
+ ```
86
+
87
+ ## Contribute
88
+
89
+ Feel free to submit a Pull Request to this project and suggest stricter rules, plugins, fixes and documentation enhancements.
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from '../src/configs/index.js';
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "eslint-config-any",
3
+ "version": "1.0.0",
4
+ "description": "ESLint configuration for JavaScript, TypeScript, React & Vue projects, by Julio L. Muller",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Julio L. Muller",
8
+ "url": "https://github.com/juliolmuller"
9
+ },
10
+ "keywords": [
11
+ "eslint",
12
+ "config",
13
+ "javascript",
14
+ "typescript",
15
+ "node",
16
+ "react",
17
+ "vue",
18
+ "jest",
19
+ "vitest",
20
+ "commonjs"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/juliolmuller/eslint-config-any"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/juliolmuller/eslint-config-any/issues"
28
+ },
29
+ "homepage": "https://github.com/juliolmuller/eslint-config-any#readme",
30
+ "engines": {
31
+ "node": ">=22"
32
+ },
33
+ "type": "module",
34
+ "main": "dist/index.js",
35
+ "scripts": {
36
+ "prepare": "husky",
37
+ "commit": "git-cz",
38
+ "lint": "eslint --fix src/ eslint.config.js",
39
+ "prepublishOnly": "bun run lint"
40
+ },
41
+ "peerDependencies": {
42
+ "eslint": ">=9.22",
43
+ "prettier": ">=3.5",
44
+ "typescript": ">=5.8"
45
+ },
46
+ "dependencies": {
47
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
48
+ "@eslint/js": "^9.23.0",
49
+ "@eslint/json": "^0.11.0",
50
+ "@eslint/markdown": "^6.3.0",
51
+ "eslint-config-prettier": "^10.1.1",
52
+ "eslint-plugin-array-func": "^5.0.2",
53
+ "eslint-plugin-import": "^2.31.0",
54
+ "eslint-plugin-import-helpers": "^2.0.1",
55
+ "eslint-plugin-jsx-a11y": "^6.10.2",
56
+ "eslint-plugin-perfectionist": "^4.10.1",
57
+ "eslint-plugin-prettier": "^5.2.3",
58
+ "eslint-plugin-react": "^7.37.4",
59
+ "eslint-plugin-react-hooks": "^5.2.0",
60
+ "eslint-plugin-regexp": "^2.7.0",
61
+ "eslint-plugin-vue": "^10.0.0",
62
+ "globals": "^16.0.0",
63
+ "typescript-eslint": "^8.27.0",
64
+ "vue-eslint-parser": "^10.1.1"
65
+ },
66
+ "devDependencies": {
67
+ "@commitlint/cli": "^19.8.0",
68
+ "@commitlint/config-conventional": "^19.8.0",
69
+ "@types/bun": "^1.2.5",
70
+ "commitizen": "^4.3.1",
71
+ "cz-conventional-changelog": "^3.3.0",
72
+ "eslint": "^9.23.0",
73
+ "husky": "^9.1.7",
74
+ "lint-staged": "^15.5.0",
75
+ "prettier": "^3.5.3",
76
+ "typescript": "^5.8.2"
77
+ }
78
+ }
@@ -0,0 +1,38 @@
1
+ import jsEslint from '@eslint/js';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { JS, TS, VUE } from '../../utils/index.js';
5
+ import eslintCommentsConfigs from './plugins/@eslint-community___eslint-comments/index.js';
6
+ import arrayFuncConfigs from './plugins/array-func/index.js';
7
+ import importHelpersConfigs from './plugins/import-helpers/index.js';
8
+ import importConfigs from './plugins/import/index.js';
9
+ import jsonConfigs from './plugins/json/index.js';
10
+ import markdownConfigs from './plugins/markdown/index.js';
11
+ import perfectionistConfigs from './plugins/perfectionist/index.js';
12
+ import regexpConfigs from './plugins/regexp/index.js';
13
+ import rules from './rules/index.js';
14
+
15
+ const matchingFilesPattern = [JS, TS, VUE];
16
+ const baseJavaScriptConfig = jsEslint.configs.recommended;
17
+
18
+ export default defineConfig([
19
+ {
20
+ ignores: ['**/coverage/**', '**/build/**', '**/dist/**', '**/*.min.js', '**/node_modules/**'],
21
+ },
22
+ {
23
+ ...baseJavaScriptConfig,
24
+ files: matchingFilesPattern,
25
+ },
26
+ ...jsonConfigs,
27
+ ...markdownConfigs,
28
+ ...eslintCommentsConfigs,
29
+ ...arrayFuncConfigs,
30
+ ...importConfigs,
31
+ ...importHelpersConfigs,
32
+ ...perfectionistConfigs,
33
+ ...regexpConfigs,
34
+ {
35
+ files: matchingFilesPattern,
36
+ rules,
37
+ },
38
+ ]);
@@ -0,0 +1,18 @@
1
+ import eslintCommentsConfigs from '@eslint-community/eslint-plugin-eslint-comments/configs';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import rules from './rules/index.js';
5
+
6
+ const matchingFilesPattern = ['**/*.{js,jsx,mjsx,cjs,mjs,ts,tsx,mtsx,vue}'];
7
+ const baseJavaScriptConfig = eslintCommentsConfigs.recommended;
8
+
9
+ export default defineConfig([
10
+ {
11
+ ...baseJavaScriptConfig,
12
+ files: matchingFilesPattern,
13
+ rules: {
14
+ ...baseJavaScriptConfig.rules,
15
+ ...rules,
16
+ },
17
+ },
18
+ ]);
@@ -0,0 +1,19 @@
1
+ import arrayFuncPlugin from 'eslint-plugin-array-func';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { JS, TS, VUE } from '../../../../utils/index.js';
5
+ import rules from './rules/index.js';
6
+
7
+ const matchingFilesPattern = [JS, TS, VUE];
8
+ const baseArrayFuncConfig = arrayFuncPlugin.configs.recommended;
9
+
10
+ export default defineConfig([
11
+ {
12
+ ...baseArrayFuncConfig,
13
+ files: matchingFilesPattern,
14
+ rules: {
15
+ ...baseArrayFuncConfig.rules,
16
+ ...rules,
17
+ },
18
+ },
19
+ ]);
@@ -0,0 +1,4 @@
1
+ export default {
2
+ // https://github.com/freaktechnik/eslint-plugin-array-func#prefer-array-from
3
+ 'array-func/prefer-array-from': 'off',
4
+ };
@@ -0,0 +1,17 @@
1
+ import importPlugin from 'eslint-plugin-import';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { JS, TS, VUE } from '../../../../utils/index.js';
5
+ import rules from './rules/index.js';
6
+
7
+ const matchingFilesPattern = [JS, TS, VUE];
8
+
9
+ export default defineConfig([
10
+ {
11
+ files: matchingFilesPattern,
12
+ plugins: {
13
+ import: importPlugin,
14
+ },
15
+ rules,
16
+ },
17
+ ]);
@@ -0,0 +1,25 @@
1
+ export default {
2
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unresolved.md
3
+ 'import/no-unresolved': 'off',
4
+
5
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/named.md
6
+ 'import/named': 'error',
7
+
8
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md
9
+ 'import/namespace': 'error',
10
+
11
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/default.md
12
+ 'import/default': 'error',
13
+
14
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/export.md
15
+ 'import/export': 'error',
16
+
17
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default.md
18
+ 'import/no-named-as-default': 'warn',
19
+
20
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md
21
+ 'import/no-named-as-default-member': 'warn',
22
+
23
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md
24
+ 'import/no-duplicates': 'warn',
25
+ };
@@ -0,0 +1,17 @@
1
+ import importHelpersPlugin from 'eslint-plugin-import-helpers';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { JS, TS, VUE } from '../../../../utils/index.js';
5
+ import rules from './rules/index.js';
6
+
7
+ const matchingFilesPattern = [JS, TS, VUE];
8
+
9
+ export default defineConfig([
10
+ {
11
+ files: matchingFilesPattern,
12
+ plugins: {
13
+ 'import-helpers': importHelpersPlugin,
14
+ },
15
+ rules,
16
+ },
17
+ ]);
@@ -0,0 +1,14 @@
1
+ export default {
2
+ // https://github.com/willhoney7/eslint-plugin-import-helpers/blob/main/docs/rules/order-imports.md
3
+ 'import-helpers/order-imports': [
4
+ 'warn',
5
+ {
6
+ alphabetize: {
7
+ order: 'asc',
8
+ ignoreCase: true,
9
+ },
10
+ groups: ['module', ['/^~//', '/^@//'], ['parent', 'sibling', 'index']],
11
+ newlinesBetween: 'always',
12
+ },
13
+ ],
14
+ };
@@ -0,0 +1,26 @@
1
+ // eslint.config.js
2
+ import jsonEslint from '@eslint/json';
3
+ import { defineConfig } from 'eslint/config';
4
+
5
+ import { JSON, JSON5, JSONC } from '../../../../utils/index.js';
6
+
7
+ const baseJsonConfig = jsonEslint.configs.recommended;
8
+
9
+ export default defineConfig([
10
+ {
11
+ ...baseJsonConfig,
12
+ files: [JSON],
13
+ ignores: ['package-lock.json'],
14
+ language: 'json/json',
15
+ },
16
+ {
17
+ ...baseJsonConfig,
18
+ files: [JSONC],
19
+ language: 'json/jsonc',
20
+ },
21
+ {
22
+ ...baseJsonConfig,
23
+ files: [JSON5],
24
+ language: 'json/json5',
25
+ },
26
+ ]);
@@ -0,0 +1,3 @@
1
+ export default {
2
+ // https://github.com/eslint/json
3
+ };
@@ -0,0 +1,5 @@
1
+ // eslint.config.js
2
+ import markdownEslint from '@eslint/markdown';
3
+ import { defineConfig } from 'eslint/config';
4
+
5
+ export default defineConfig([...markdownEslint.configs.recommended]);
@@ -0,0 +1,3 @@
1
+ export default {
2
+ // https://github.com/eslint/markdown
3
+ };
@@ -0,0 +1,17 @@
1
+ import perfectionistPlugin from 'eslint-plugin-perfectionist';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { JS, TS, VUE } from '../../../../utils/index.js';
5
+ import rules from './rules/index.js';
6
+
7
+ const matchingFilesPattern = [JS, TS, VUE];
8
+
9
+ export default defineConfig([
10
+ {
11
+ files: matchingFilesPattern,
12
+ plugins: {
13
+ perfectionist: perfectionistPlugin,
14
+ },
15
+ rules,
16
+ },
17
+ ]);
@@ -0,0 +1,40 @@
1
+ export default {
2
+ // https://perfectionist.dev/rules/sort-decorators
3
+ 'perfectionist/sort-decorators': 'warn',
4
+
5
+ // https://perfectionist.dev/rules/sort-enums
6
+ 'perfectionist/sort-enums': 'warn',
7
+
8
+ // https://perfectionist.dev/rules/sort-exports
9
+ 'perfectionist/sort-exports': 'warn',
10
+
11
+ // https://perfectionist.dev/rules/sort-heritage-clauses
12
+ 'perfectionist/sort-heritage-clauses': 'warn',
13
+
14
+ // https://perfectionist.dev/rules/sort-interfaces
15
+ 'perfectionist/sort-interfaces': 'warn',
16
+
17
+ // https://perfectionist.dev/rules/sort-intersection-types
18
+ 'perfectionist/sort-intersection-types': 'warn',
19
+
20
+ // https://perfectionist.dev/rules/sort-maps
21
+ 'perfectionist/sort-maps': ['warn', { type: 'line-length' }],
22
+
23
+ // https://perfectionist.dev/rules/sort-named-exports
24
+ 'perfectionist/sort-named-exports': 'warn',
25
+
26
+ // https://perfectionist.dev/rules/sort-named-imports
27
+ 'perfectionist/sort-named-imports': 'warn',
28
+
29
+ // https://perfectionist.dev/rules/sort-object-types
30
+ 'perfectionist/sort-object-types': 'warn',
31
+
32
+ // https://perfectionist.dev/rules/sort-sets
33
+ 'perfectionist/sort-sets': 'warn',
34
+
35
+ // https://perfectionist.dev/rules/sort-switch-case
36
+ 'perfectionist/sort-switch-case': 'warn',
37
+
38
+ // https://perfectionist.dev/rules/sort-union-types
39
+ 'perfectionist/sort-union-types': 'warn',
40
+ };
@@ -0,0 +1,19 @@
1
+ import regexpPlugin from 'eslint-plugin-regexp';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { JS, TS, VUE } from '../../../../utils/index.js';
5
+ import rules from './rules/index.js';
6
+
7
+ const matchingFilesPattern = [JS, TS, VUE];
8
+ const baseRegExpConfig = regexpPlugin.configs['flat/recommended'];
9
+
10
+ export default defineConfig([
11
+ {
12
+ ...baseRegExpConfig,
13
+ files: matchingFilesPattern,
14
+ rules: {
15
+ ...baseRegExpConfig.rules,
16
+ ...rules,
17
+ },
18
+ },
19
+ ]);
@@ -0,0 +1,3 @@
1
+ export default {
2
+ // https://ota-meshi.github.io/eslint-plugin-regexp/rules
3
+ };
@@ -0,0 +1,43 @@
1
+ export default {
2
+ // https://eslint.org/docs/rules/eqeqeq
3
+ eqeqeq: 'error',
4
+
5
+ // https://eslint.org/docs/rules/func-style
6
+ 'func-style': [
7
+ 'error',
8
+ 'declaration',
9
+ {
10
+ allowArrowFunctions: true,
11
+ },
12
+ ],
13
+
14
+ // https://eslint.org/docs/rules/no-console
15
+ 'no-console': [
16
+ 'error',
17
+ {
18
+ allow: [console.error.name, console.info.name, console.warn.name],
19
+ },
20
+ ],
21
+
22
+ // https://eslint.org/docs/rules/no-empty-function
23
+ 'no-empty-function': 'off',
24
+
25
+ // https://eslint.org/docs/rules/no-unused-vars
26
+ 'no-unused-vars': [
27
+ 'error',
28
+ {
29
+ args: 'all',
30
+ argsIgnorePattern: '^_',
31
+ ignoreRestSiblings: true,
32
+ },
33
+ ],
34
+
35
+ // https://eslint.org/docs/rules/prefer-arrow-callback
36
+ 'prefer-arrow-callback': 'error',
37
+
38
+ // https://eslint.org/docs/rules/prefer-const
39
+ 'prefer-const': 'error',
40
+
41
+ // https://eslint.org/docs/rules/prefer-template
42
+ 'prefer-template': 'error',
43
+ };
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import globals from 'globals';
3
+
4
+ export default defineConfig([
5
+ {
6
+ languageOptions: {
7
+ globals: globals.browser,
8
+ },
9
+ },
10
+ ]);
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from 'eslint/config';
2
+
3
+ import { CJS } from '../../../utils/index.js';
4
+
5
+ const matchingFilesPattern = [CJS];
6
+
7
+ export default defineConfig([
8
+ {
9
+ files: matchingFilesPattern,
10
+ languageOptions: {
11
+ sourceType: 'commonjs',
12
+ },
13
+ },
14
+ ]);
@@ -0,0 +1,15 @@
1
+ import browser from './browser/index.js';
2
+ import commonjs from './commonjs/index.js';
3
+ import jest from './jest/index.js';
4
+ import node from './node/index.js';
5
+ import sharedNodeAndBrowser from './sharedNodeAndBrowser/index.js';
6
+ import vitest from './vitest/index.js';
7
+
8
+ export default {
9
+ sharedNodeAndBrowser,
10
+ commonjs,
11
+ browser,
12
+ vitest,
13
+ jest,
14
+ node,
15
+ };
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import globals from 'globals';
3
+
4
+ import { TEST } from '../../../utils/index.js';
5
+
6
+ const matchingFilesPattern = [TEST];
7
+
8
+ export default defineConfig([
9
+ {
10
+ files: matchingFilesPattern,
11
+ languageOptions: {
12
+ globals: globals.vitest,
13
+ },
14
+ },
15
+ ]);
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import globals from 'globals';
3
+
4
+ export default defineConfig([
5
+ {
6
+ languageOptions: {
7
+ globals: {
8
+ ...globals.node,
9
+ Bun: true,
10
+ },
11
+ },
12
+ },
13
+ ]);
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import globals from 'globals';
3
+
4
+ export default defineConfig([
5
+ {
6
+ languageOptions: {
7
+ globals: globals['shared-node-browser'],
8
+ },
9
+ },
10
+ ]);
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import globals from 'globals';
3
+
4
+ import { TEST } from '../../../utils/index.js';
5
+
6
+ const matchingFilesPattern = [TEST];
7
+
8
+ export default defineConfig([
9
+ {
10
+ files: matchingFilesPattern,
11
+ languageOptions: {
12
+ globals: globals.jest,
13
+ },
14
+ },
15
+ ]);
@@ -0,0 +1,42 @@
1
+ import jsConfigs from './base/index.js';
2
+ import envConfigs from './env/index.js';
3
+ import prettierConfigs from './prettier/index.js';
4
+ import reactConfigs from './react/index.js';
5
+ import tsConfigs from './typescript/index.js';
6
+ import vueConfigs from './vue/index.js';
7
+
8
+ /**
9
+ * @typedef {import('eslint').Linter.Config[]} EslintFlatConfig
10
+ *
11
+ * @typedef {Object} EslintFlatConfigSetup
12
+ * @property {EslintFlatConfig} commonjs
13
+ * @property {EslintFlatConfig} jest
14
+ * @property {EslintFlatConfig} vitest
15
+ * @property {EslintFlatConfig} node
16
+ * @property {EslintFlatConfig} browser
17
+ * @property {EslintFlatConfig} sharedNodeAndBrowser
18
+ * @property {EslintFlatConfig} react
19
+ * @property {EslintFlatConfig} vue
20
+ * @property {EslintFlatConfig} vue2
21
+ */
22
+
23
+ /**
24
+ * @param {EslintFlatConfig} otherConfigs
25
+ * @return {EslintFlatConfig}
26
+ */
27
+ function mergeConfigs(otherConfigs) {
28
+ return [...jsConfigs, ...tsConfigs, ...otherConfigs, ...prettierConfigs];
29
+ }
30
+
31
+ /** @type {EslintFlatConfigSetup} */
32
+ export default {
33
+ commonjs: envConfigs.commonjs,
34
+ jest: envConfigs.jest,
35
+ vitest: envConfigs.vitest,
36
+ node: mergeConfigs(envConfigs.node),
37
+ browser: mergeConfigs(envConfigs.browser),
38
+ sharedNodeAndBrowser: mergeConfigs(envConfigs.sharedNodeAndBrowser),
39
+ react: mergeConfigs(reactConfigs),
40
+ vue: mergeConfigs(vueConfigs.vue3),
41
+ vue2: mergeConfigs(vueConfigs.vue2),
42
+ };
@@ -0,0 +1,17 @@
1
+ import prettierConfigAndPlugin from 'eslint-plugin-prettier/recommended';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ export default defineConfig([
5
+ prettierConfigAndPlugin,
6
+ {
7
+ rules: {
8
+ 'prettier/prettier': [
9
+ 'warn',
10
+ {
11
+ printWidth: 100,
12
+ singleQuote: true,
13
+ },
14
+ ],
15
+ },
16
+ },
17
+ ]);
@@ -0,0 +1,40 @@
1
+ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
2
+ import reactPlugin from 'eslint-plugin-react';
3
+ import reactHooksPlugin from 'eslint-plugin-react-hooks';
4
+ import { defineConfig } from 'eslint/config';
5
+ import globals from 'globals';
6
+
7
+ import { JS, TS } from '../../utils/index.js';
8
+ import rules from './rules/index.js';
9
+
10
+ const matchingFilesPattern = [JS, TS];
11
+ const baseReactConfig = reactPlugin.configs.flat.recommended;
12
+ const baseReactHooksConfig = reactHooksPlugin.configs['recommended-latest'];
13
+ const baseJsxA11yConfig = jsxA11yPlugin.flatConfigs.recommended;
14
+
15
+ export default defineConfig([
16
+ {
17
+ ...baseReactConfig,
18
+ files: matchingFilesPattern,
19
+ settings: {
20
+ react: {
21
+ version: 'detect',
22
+ },
23
+ },
24
+ },
25
+ {
26
+ ...baseReactHooksConfig,
27
+ files: matchingFilesPattern,
28
+ },
29
+ {
30
+ ...baseJsxA11yConfig,
31
+ files: matchingFilesPattern,
32
+ },
33
+ {
34
+ files: matchingFilesPattern,
35
+ languageOptions: {
36
+ globals: globals.browser,
37
+ },
38
+ rules,
39
+ },
40
+ ]);
@@ -0,0 +1,47 @@
1
+ export default {
2
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
3
+ 'react/jsx-boolean-value': ['warn', 'never'],
4
+
5
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
6
+ 'react/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
7
+
8
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
9
+ 'react/jsx-curly-brace-presence': [
10
+ 'warn',
11
+ {
12
+ children: 'never',
13
+ props: 'never',
14
+ propElementValues: 'always',
15
+ },
16
+ ],
17
+
18
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
19
+ 'react/jsx-curly-spacing': [
20
+ 'warn',
21
+ {
22
+ when: 'never',
23
+ },
24
+ ],
25
+
26
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
27
+ 'react/jsx-equals-spacing': ['warn', 'never'],
28
+
29
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
30
+ 'react/jsx-filename-extension': [
31
+ 'error',
32
+ {
33
+ allow: 'as-needed',
34
+ extensions: ['.jsx', '.mjsx', '.tsx', '.mtsx'],
35
+ ignoreFilesWithoutCode: true,
36
+ },
37
+ ],
38
+
39
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
40
+ 'react/jsx-uses-react': 'off',
41
+
42
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
43
+ 'react/prop-types': 'off',
44
+
45
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
46
+ 'react/react-in-jsx-scope': 'off',
47
+ };
@@ -0,0 +1,24 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import tsEslint from 'typescript-eslint';
3
+
4
+ import { TS, VUE } from '../../utils/index.js';
5
+ import rules from './rules/index.js';
6
+
7
+ const matchingFilesPattern = [TS, VUE];
8
+ const baseTypeScriptConfig = tsEslint.configs.recommended;
9
+ const baseStylisticConfigRules = tsEslint.configs.stylistic.at(-1)?.rules ?? {};
10
+ const stylisticRules = Object.keys(baseStylisticConfigRules).reduce((acc, rule) => {
11
+ acc[rule] = 'warn';
12
+ return acc;
13
+ }, {});
14
+
15
+ export default defineConfig([
16
+ ...baseTypeScriptConfig,
17
+ {
18
+ files: matchingFilesPattern,
19
+ rules: {
20
+ ...stylisticRules,
21
+ ...rules,
22
+ },
23
+ },
24
+ ]);
@@ -0,0 +1,23 @@
1
+ import standardRules from '../../base/rules/index.js';
2
+
3
+ export default {
4
+ // https://typescript-eslint.io/rules/consistent-type-imports
5
+ '@typescript-eslint/consistent-type-imports': [
6
+ 'warn',
7
+ {
8
+ disallowTypeAnnotations: true,
9
+ fixStyle: 'inline-type-imports',
10
+ prefer: 'type-imports',
11
+ },
12
+ ],
13
+
14
+ // https://typescript-eslint.io/rules/explicit-function-return-type
15
+ '@typescript-eslint/explicit-function-return-type': 'warn',
16
+
17
+ // https://typescript-eslint.io/rules/no-empty-function
18
+ '@typescript-eslint/no-empty-function': 'off',
19
+ 'no-empty-function': 'off',
20
+
21
+ // https://typescript-eslint.io/rules/no-unused-vars
22
+ '@typescript-eslint/no-unused-vars': standardRules['no-unused-vars'],
23
+ };
@@ -0,0 +1,7 @@
1
+ import vue2 from './v2/index.js';
2
+ import vue3 from './v3/index.js';
3
+
4
+ export default {
5
+ vue2,
6
+ vue3,
7
+ };
@@ -0,0 +1,24 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import globals from 'globals';
3
+ import tsEslint from 'typescript-eslint';
4
+
5
+ import { VUE } from '../../../utils/index.js';
6
+ import rules from './rules/index.js';
7
+
8
+ const matchingFilesPattern = [VUE];
9
+
10
+ export default defineConfig([
11
+ {
12
+ files: matchingFilesPattern,
13
+ languageOptions: {
14
+ globals: globals.browser,
15
+ parserOptions: {
16
+ parser: tsEslint.parser,
17
+ ecmaFeatures: {
18
+ jsx: true,
19
+ },
20
+ },
21
+ },
22
+ rules,
23
+ },
24
+ ]);
@@ -0,0 +1,77 @@
1
+ export default {
2
+ // https://eslint.vuejs.org/rules/block-order.html
3
+ 'vue/block-order': [
4
+ 'error',
5
+ {
6
+ order: ['script', 'template', 'style'],
7
+ },
8
+ ],
9
+
10
+ // https://eslint.vuejs.org/rules/vue/html-self-closing.html
11
+ 'vue/html-self-closing': [
12
+ 'error',
13
+ {
14
+ html: {
15
+ void: 'always',
16
+ normal: 'always',
17
+ component: 'always',
18
+ },
19
+ svg: 'always',
20
+ math: 'always',
21
+ },
22
+ ],
23
+
24
+ // https://eslint.vuejs.org/rules/multi-word-component-names.html
25
+ 'vue/multi-word-component-names': 'off',
26
+
27
+ // https://eslint.vuejs.org/rules/order-in-components.html
28
+ 'vue/order-in-components': [
29
+ 'error',
30
+ {
31
+ order: [
32
+ 'el',
33
+ 'name',
34
+ 'key', // Nuxt's
35
+ 'head', // Nuxt's
36
+ 'extends',
37
+ 'inheritAttrs',
38
+ 'parent',
39
+ 'functional',
40
+ ['delimiters', 'comments'],
41
+ 'components',
42
+ 'directives',
43
+ 'filters',
44
+ 'mixins',
45
+ 'provide',
46
+ 'inject',
47
+ 'ROUTER_GUARDS', // Vue Router's
48
+ 'layout', // Nuxt's
49
+ 'middleware', // Nuxt's
50
+ 'validate', // Nuxt's
51
+ 'scrollToTop', // Nuxt's
52
+ 'transition', // Nuxt's
53
+ 'loading', // Nuxt's
54
+ 'model',
55
+ 'expose',
56
+ 'slots',
57
+ 'emits',
58
+ 'props',
59
+ 'propsData',
60
+ 'data',
61
+ 'asyncData', // Nuxt's
62
+ 'computed',
63
+ 'setup',
64
+ 'watch',
65
+ 'watchQuery', // Nuxt's
66
+ 'methods',
67
+ 'fetch', // Nuxt's
68
+ 'LIFECYCLE_HOOKS',
69
+ ['template', 'render'],
70
+ 'renderError',
71
+ ],
72
+ },
73
+ ],
74
+
75
+ // https://eslint.vuejs.org/rules/require-name-property.html
76
+ 'vue/require-name-property': 'error',
77
+ };
@@ -0,0 +1,21 @@
1
+ import vuePlugin from 'eslint-plugin-vue';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { VUE } from '../../../utils/index.js';
5
+ import config from '../shared/index.js';
6
+ import rules from './rules/index.js';
7
+
8
+ const matchingFilesPattern = [VUE];
9
+ const recommendedConfig = vuePlugin.configs['flat/vue2-recommended'].map((config) => ({
10
+ ...config,
11
+ files: matchingFilesPattern,
12
+ }));
13
+
14
+ export default defineConfig([
15
+ ...recommendedConfig,
16
+ ...config,
17
+ {
18
+ files: matchingFilesPattern,
19
+ rules,
20
+ },
21
+ ]);
@@ -0,0 +1 @@
1
+ export default {};
@@ -0,0 +1,21 @@
1
+ import vuePlugin from 'eslint-plugin-vue';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ import { VUE } from '../../../utils/index.js';
5
+ import config from '../shared/index.js';
6
+ import rules from './rules/index.js';
7
+
8
+ const matchingFilesPattern = [VUE];
9
+ const recommendedConfig = vuePlugin.configs['flat/recommended'].map((config) => ({
10
+ ...config,
11
+ files: matchingFilesPattern,
12
+ }));
13
+
14
+ export default defineConfig([
15
+ ...recommendedConfig,
16
+ ...config,
17
+ {
18
+ files: matchingFilesPattern,
19
+ rules,
20
+ },
21
+ ]);
@@ -0,0 +1 @@
1
+ export default {};
@@ -0,0 +1,8 @@
1
+ export const VUE = '**/*.vue';
2
+ export const JSON = '**/*.json';
3
+ export const JSONC = '**/*.jsonc';
4
+ export const JSON5 = '**/*.json5';
5
+ export const CJS = '**/*.{js,cjs}';
6
+ export const JS = '**/*.{js,cjs,mjs,jsx,mjsx}';
7
+ export const TS = '**/*.{ts,mts,tsx,mtsx}';
8
+ export const TEST = '**/*.{test,spec}.*';
@@ -0,0 +1 @@
1
+ export * from './files.js';