@anolilab/eslint-config 15.0.2 → 16.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 (224) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +386 -466
  3. package/dist/index.cjs +20 -0
  4. package/dist/index.d.cts +16370 -0
  5. package/dist/index.d.mts +16370 -0
  6. package/dist/index.d.ts +16367 -2
  7. package/dist/index.mjs +20 -0
  8. package/package.json +89 -265
  9. package/bin/generate-eslint-cofig.js +0 -3
  10. package/dist/chunk-A6LXZAWN.js +0 -9
  11. package/dist/chunk-A6LXZAWN.js.map +0 -1
  12. package/dist/chunk-MFE6DF6Y.js +0 -8
  13. package/dist/chunk-MFE6DF6Y.js.map +0 -1
  14. package/dist/chunk-MKL3NIXX.js +0 -9
  15. package/dist/chunk-MKL3NIXX.js.map +0 -1
  16. package/dist/chunk-R26SPKXH.js +0 -9
  17. package/dist/chunk-R26SPKXH.js.map +0 -1
  18. package/dist/chunk-RG6NJDJA.js +0 -9
  19. package/dist/chunk-RG6NJDJA.js.map +0 -1
  20. package/dist/chunk-SEYYGHPU.js +0 -8
  21. package/dist/chunk-SEYYGHPU.js.map +0 -1
  22. package/dist/chunk-SLM5UENV.js +0 -14
  23. package/dist/chunk-SLM5UENV.js.map +0 -1
  24. package/dist/chunk-UGG52B5H.js +0 -11
  25. package/dist/chunk-UGG52B5H.js.map +0 -1
  26. package/dist/chunk-WG6GTAIA.js +0 -8
  27. package/dist/chunk-WG6GTAIA.js.map +0 -1
  28. package/dist/chunk-WW4PDMXQ.js +0 -9
  29. package/dist/chunk-WW4PDMXQ.js.map +0 -1
  30. package/dist/config/best-practices.d.ts +0 -5
  31. package/dist/config/best-practices.js +0 -11
  32. package/dist/config/best-practices.js.map +0 -1
  33. package/dist/config/errors.d.ts +0 -5
  34. package/dist/config/errors.js +0 -11
  35. package/dist/config/errors.js.map +0 -1
  36. package/dist/config/es6.d.ts +0 -5
  37. package/dist/config/es6.js +0 -11
  38. package/dist/config/es6.js.map +0 -1
  39. package/dist/config/plugins/antfu.d.ts +0 -5
  40. package/dist/config/plugins/antfu.js +0 -11
  41. package/dist/config/plugins/antfu.js.map +0 -1
  42. package/dist/config/plugins/array-func.d.ts +0 -5
  43. package/dist/config/plugins/array-func.js +0 -10
  44. package/dist/config/plugins/array-func.js.map +0 -1
  45. package/dist/config/plugins/ava.d.ts +0 -5
  46. package/dist/config/plugins/ava.js +0 -9
  47. package/dist/config/plugins/ava.js.map +0 -1
  48. package/dist/config/plugins/babel.d.ts +0 -5
  49. package/dist/config/plugins/babel.js +0 -16
  50. package/dist/config/plugins/babel.js.map +0 -1
  51. package/dist/config/plugins/compat.d.ts +0 -5
  52. package/dist/config/plugins/compat.js +0 -9
  53. package/dist/config/plugins/compat.js.map +0 -1
  54. package/dist/config/plugins/cypress.d.ts +0 -5
  55. package/dist/config/plugins/cypress.js +0 -9
  56. package/dist/config/plugins/cypress.js.map +0 -1
  57. package/dist/config/plugins/deprecation.d.ts +0 -5
  58. package/dist/config/plugins/deprecation.js +0 -10
  59. package/dist/config/plugins/deprecation.js.map +0 -1
  60. package/dist/config/plugins/editorconfig.d.ts +0 -5
  61. package/dist/config/plugins/editorconfig.js +0 -10
  62. package/dist/config/plugins/editorconfig.js.map +0 -1
  63. package/dist/config/plugins/es.d.ts +0 -5
  64. package/dist/config/plugins/es.js +0 -10
  65. package/dist/config/plugins/es.js.map +0 -1
  66. package/dist/config/plugins/eslint-comments.d.ts +0 -5
  67. package/dist/config/plugins/eslint-comments.js +0 -10
  68. package/dist/config/plugins/eslint-comments.js.map +0 -1
  69. package/dist/config/plugins/etc.d.ts +0 -5
  70. package/dist/config/plugins/etc.js +0 -18
  71. package/dist/config/plugins/etc.js.map +0 -1
  72. package/dist/config/plugins/html.d.ts +0 -5
  73. package/dist/config/plugins/html.js +0 -12
  74. package/dist/config/plugins/html.js.map +0 -1
  75. package/dist/config/plugins/import.d.ts +0 -5
  76. package/dist/config/plugins/import.js +0 -12
  77. package/dist/config/plugins/import.js.map +0 -1
  78. package/dist/config/plugins/jest-async.d.ts +0 -5
  79. package/dist/config/plugins/jest-async.js +0 -9
  80. package/dist/config/plugins/jest-async.js.map +0 -1
  81. package/dist/config/plugins/jest-dom.d.ts +0 -5
  82. package/dist/config/plugins/jest-dom.js +0 -9
  83. package/dist/config/plugins/jest-dom.js.map +0 -1
  84. package/dist/config/plugins/jest-formatting.d.ts +0 -5
  85. package/dist/config/plugins/jest-formatting.js +0 -9
  86. package/dist/config/plugins/jest-formatting.js.map +0 -1
  87. package/dist/config/plugins/jest.d.ts +0 -5
  88. package/dist/config/plugins/jest.js +0 -14
  89. package/dist/config/plugins/jest.js.map +0 -1
  90. package/dist/config/plugins/jsdoc.d.ts +0 -5
  91. package/dist/config/plugins/jsdoc.js +0 -12
  92. package/dist/config/plugins/jsdoc.js.map +0 -1
  93. package/dist/config/plugins/jsonc.d.ts +0 -5
  94. package/dist/config/plugins/jsonc.js +0 -17
  95. package/dist/config/plugins/jsonc.js.map +0 -1
  96. package/dist/config/plugins/jsx-a11y.d.ts +0 -5
  97. package/dist/config/plugins/jsx-a11y.js +0 -10
  98. package/dist/config/plugins/jsx-a11y.js.map +0 -1
  99. package/dist/config/plugins/markdown.d.ts +0 -5
  100. package/dist/config/plugins/markdown.js +0 -10
  101. package/dist/config/plugins/markdown.js.map +0 -1
  102. package/dist/config/plugins/mdx.d.ts +0 -5
  103. package/dist/config/plugins/mdx.js +0 -10
  104. package/dist/config/plugins/mdx.js.map +0 -1
  105. package/dist/config/plugins/no-extend-native.d.ts +0 -5
  106. package/dist/config/plugins/no-extend-native.js +0 -9
  107. package/dist/config/plugins/no-extend-native.js.map +0 -1
  108. package/dist/config/plugins/no-loops.d.ts +0 -5
  109. package/dist/config/plugins/no-loops.js +0 -9
  110. package/dist/config/plugins/no-loops.js.map +0 -1
  111. package/dist/config/plugins/no-only-tests.d.ts +0 -5
  112. package/dist/config/plugins/no-only-tests.js +0 -10
  113. package/dist/config/plugins/no-only-tests.js.map +0 -1
  114. package/dist/config/plugins/no-secrets.d.ts +0 -5
  115. package/dist/config/plugins/no-secrets.js +0 -9
  116. package/dist/config/plugins/no-secrets.js.map +0 -1
  117. package/dist/config/plugins/no-unsanitized.d.ts +0 -5
  118. package/dist/config/plugins/no-unsanitized.js +0 -9
  119. package/dist/config/plugins/no-unsanitized.js.map +0 -1
  120. package/dist/config/plugins/node.d.ts +0 -5
  121. package/dist/config/plugins/node.js +0 -10
  122. package/dist/config/plugins/node.js.map +0 -1
  123. package/dist/config/plugins/perfectionist.d.ts +0 -5
  124. package/dist/config/plugins/perfectionist.js +0 -14
  125. package/dist/config/plugins/perfectionist.js.map +0 -1
  126. package/dist/config/plugins/playwright.d.ts +0 -5
  127. package/dist/config/plugins/playwright.js +0 -10
  128. package/dist/config/plugins/playwright.js.map +0 -1
  129. package/dist/config/plugins/promise.d.ts +0 -5
  130. package/dist/config/plugins/promise.js +0 -9
  131. package/dist/config/plugins/promise.js.map +0 -1
  132. package/dist/config/plugins/react-hooks.d.ts +0 -5
  133. package/dist/config/plugins/react-hooks.js +0 -10
  134. package/dist/config/plugins/react-hooks.js.map +0 -1
  135. package/dist/config/plugins/react-redux.d.ts +0 -5
  136. package/dist/config/plugins/react-redux.js +0 -10
  137. package/dist/config/plugins/react-redux.js.map +0 -1
  138. package/dist/config/plugins/react-usememo.d.ts +0 -5
  139. package/dist/config/plugins/react-usememo.js +0 -10
  140. package/dist/config/plugins/react-usememo.js.map +0 -1
  141. package/dist/config/plugins/react.d.ts +0 -5
  142. package/dist/config/plugins/react.js +0 -29
  143. package/dist/config/plugins/react.js.map +0 -1
  144. package/dist/config/plugins/regexp.d.ts +0 -5
  145. package/dist/config/plugins/regexp.js +0 -10
  146. package/dist/config/plugins/regexp.js.map +0 -1
  147. package/dist/config/plugins/security.d.ts +0 -5
  148. package/dist/config/plugins/security.js +0 -9
  149. package/dist/config/plugins/security.js.map +0 -1
  150. package/dist/config/plugins/simple-import-sort.d.ts +0 -5
  151. package/dist/config/plugins/simple-import-sort.js +0 -10
  152. package/dist/config/plugins/simple-import-sort.js.map +0 -1
  153. package/dist/config/plugins/sonarjs.d.ts +0 -5
  154. package/dist/config/plugins/sonarjs.js +0 -10
  155. package/dist/config/plugins/sonarjs.js.map +0 -1
  156. package/dist/config/plugins/ssr-friendly.d.ts +0 -5
  157. package/dist/config/plugins/ssr-friendly.js +0 -10
  158. package/dist/config/plugins/ssr-friendly.js.map +0 -1
  159. package/dist/config/plugins/storybook.d.ts +0 -5
  160. package/dist/config/plugins/storybook.js +0 -9
  161. package/dist/config/plugins/storybook.js.map +0 -1
  162. package/dist/config/plugins/tailwindcss.d.ts +0 -5
  163. package/dist/config/plugins/tailwindcss.js +0 -10
  164. package/dist/config/plugins/tailwindcss.js.map +0 -1
  165. package/dist/config/plugins/tanstack-query.d.ts +0 -5
  166. package/dist/config/plugins/tanstack-query.js +0 -10
  167. package/dist/config/plugins/tanstack-query.js.map +0 -1
  168. package/dist/config/plugins/testing-library-dom.d.ts +0 -5
  169. package/dist/config/plugins/testing-library-dom.js +0 -12
  170. package/dist/config/plugins/testing-library-dom.js.map +0 -1
  171. package/dist/config/plugins/testing-library-react.d.ts +0 -5
  172. package/dist/config/plugins/testing-library-react.js +0 -12
  173. package/dist/config/plugins/testing-library-react.js.map +0 -1
  174. package/dist/config/plugins/toml.d.ts +0 -5
  175. package/dist/config/plugins/toml.js +0 -9
  176. package/dist/config/plugins/toml.js.map +0 -1
  177. package/dist/config/plugins/tsdoc.d.ts +0 -5
  178. package/dist/config/plugins/tsdoc.js +0 -10
  179. package/dist/config/plugins/tsdoc.js.map +0 -1
  180. package/dist/config/plugins/typescript.d.ts +0 -5
  181. package/dist/config/plugins/typescript.js +0 -19
  182. package/dist/config/plugins/typescript.js.map +0 -1
  183. package/dist/config/plugins/unicorn.d.ts +0 -5
  184. package/dist/config/plugins/unicorn.js +0 -12
  185. package/dist/config/plugins/unicorn.js.map +0 -1
  186. package/dist/config/plugins/validate-jsx-nesting.d.ts +0 -5
  187. package/dist/config/plugins/validate-jsx-nesting.js +0 -10
  188. package/dist/config/plugins/validate-jsx-nesting.js.map +0 -1
  189. package/dist/config/plugins/vitest.d.ts +0 -5
  190. package/dist/config/plugins/vitest.js +0 -10
  191. package/dist/config/plugins/vitest.js.map +0 -1
  192. package/dist/config/plugins/yml.d.ts +0 -5
  193. package/dist/config/plugins/yml.js +0 -12
  194. package/dist/config/plugins/yml.js.map +0 -1
  195. package/dist/config/plugins/you-dont-need-lodash-underscore.d.ts +0 -5
  196. package/dist/config/plugins/you-dont-need-lodash-underscore.js +0 -10
  197. package/dist/config/plugins/you-dont-need-lodash-underscore.js.map +0 -1
  198. package/dist/config/plugins/you-dont-need-momentjs.d.ts +0 -5
  199. package/dist/config/plugins/you-dont-need-momentjs.js +0 -10
  200. package/dist/config/plugins/you-dont-need-momentjs.js.map +0 -1
  201. package/dist/config/plugins/zod.d.ts +0 -5
  202. package/dist/config/plugins/zod.js +0 -10
  203. package/dist/config/plugins/zod.js.map +0 -1
  204. package/dist/config/style.d.ts +0 -5
  205. package/dist/config/style.js +0 -13
  206. package/dist/config/style.js.map +0 -1
  207. package/dist/config/variables.d.ts +0 -5
  208. package/dist/config/variables.js +0 -11
  209. package/dist/config/variables.js.map +0 -1
  210. package/dist/define-config.d.ts +0 -1
  211. package/dist/define-config.js +0 -17
  212. package/dist/define-config.js.map +0 -1
  213. package/dist/globals.d.ts +0 -8
  214. package/dist/globals.js +0 -17
  215. package/dist/globals.js.map +0 -1
  216. package/dist/index.js +0 -26
  217. package/dist/index.js.map +0 -1
  218. package/dist/postinstall.d.ts +0 -1
  219. package/dist/postinstall.js +0 -79
  220. package/dist/postinstall.js.map +0 -1
  221. package/dist/typescript-type-checking.d.ts +0 -5
  222. package/dist/typescript-type-checking.js +0 -13
  223. package/dist/typescript-type-checking.js.map +0 -1
  224. package/skip.js +0 -7
package/README.md CHANGED
@@ -20,608 +20,527 @@
20
20
 
21
21
  ## Purpose
22
22
 
23
- Our package serves as a valuable resource for JavaScript/Typescript-based projects, offering composable [ESLint](https://eslint.org/) configurations. It encompasses a range of features, including performance optimization and the flexibility to extend pre-defined base configurations.
23
+ Our package serves as a valuable resource for JavaScript/Typescript-based projects, offering composable [ESLint](https://eslint.org/) configurations. It encompasses a range of features, including performance optimization and the flexibility to extend pre-defined base configurations. We aim to provide a strong, opinionated foundation for code quality and consistency, while still allowing for customization to suit specific project needs.
24
24
 
25
- - Tailored Configuration for Workspaces: With this package, each workspace within your monorepo gains the ability to have its own customized ESLint configuration. This ensures that individual projects can maintain their specific requirements while still adhering to the overall guidelines.
25
+ - Tailored Configuration for Workspaces: With this package, each workspace within your monorepo gains the ability to have its own customized ESLint configuration. This ensures that individual projects can maintain their specific requirements while still adhering to the overall guidelines.
26
+ - Configurability at Your Fingertips: Crafting your workspace's ESLint configuration is a breeze, thanks to the seamless composition of pre-defined base configurations. This empowers you to tailor the settings to suit your project's unique needs, without starting from scratch.
26
27
 
27
- - Configurability at Your Fingertips: Crafting your workspace's ESLint configuration is a breeze, thanks to the seamless composition of pre-defined base configurations. This empowers you to tailor the settings to suit your project's unique needs, without starting from scratch.
28
+ - Enhanced Efficiency: We've optimized the package's performance by intelligently enabling plugins based on file naming conventions and project dependencies. This streamlined approach ensures that your ESLint checks run efficiently, targeting the relevant files and maximizing productivity.
28
29
 
29
- - Streamlined Convenience: Say goodbye to the hassle of installing plugins for each workspace. Our package integrates [@rushstack/eslint-patch](https://www.npmjs.com/package/@rushstack/eslint-patch), eliminating the need for repetitive plugin installations. Enjoy peace of mind as you focus on your work, knowing that the necessary plugins are automatically included.
30
-
31
- - Enhanced Efficiency: We've optimized the package's performance by intelligently enabling plugins based on file naming conventions. This streamlined approach ensures that your ESLint checks run efficiently, targeting the relevant files and maximizing productivity.
30
+ > [!NOTE]
31
+ > Since v16.0.0, this config is rewritten to the new [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new).
32
+ >
33
+ > ESLint v9.5.0+ is now required.
32
34
 
33
- In summary, our package provides comprehensive and adaptable ESLint configurations for JavaScript and Typescript projects. It empowers you to achieve code quality while minimizing overhead and maximizing productivity throughout your workspaces.
35
+ > [!WARNING]
36
+ >
37
+ > Please keep in mind that this is still **_a personal config_** with a lot of opinions. Changes might not always work for everyone and every use case.
38
+ >
39
+ > If you are using this config directly, I suggest you **review the changes every time you update**. Or if you want more control over the rules, always feel free to fork it. Thanks!
34
40
 
35
41
  ## Highlights
36
42
 
37
- - Zero-config, but configurable when needed.
38
- - Enforces readable code, because you read more code than you write.
39
- - No need to specify file paths to lint as it lints all JS/TS files except for commonly ignored paths.
40
- - Config overrides per files/globs.
41
- - TypeScript supported by default, if `typescript` was installed.
42
- - Includes many useful ESLint plugins, like [unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn), [import](https://github.com/benmosher/eslint-plugin-import) and [more](#plugins).
43
- - Automatically enables rules based on the [engines](https://docs.npmjs.com/files/package.json#engines) field in your package.json.
44
- - Specify indent and semicolon preferences easily without messing with the rule config.
45
- - Disables rules that conflict with [Prettier](#let-prettier-handle-style-related-rules).
46
- - Typesafe, because it's written in TypeScript and uses [eslint-define-config](https://github.com/Shinigami92/eslint-define-config) to define the config.
43
+ - Zero-config for many common setups, but highly configurable when needed.
44
+ - Enforces readable and consistent code, because you read more code than you write.
45
+ - Lints a wide range of files, including JavaScript, TypeScript, JSON, YAML, Markdown, and more.
46
+ - No need to specify file paths to lint as it intelligently lints relevant files, respecting `.gitignore` and common ignore patterns.
47
+ - Config overrides per files/globs.
48
+ - First-class TypeScript support, automatically enabled if `typescript` is detected in your project.
49
+ - Includes a comprehensive set of ESLint plugins, like [unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn), [import](https://github.com/benmosher/eslint-plugin-import), [sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs), and [security](#security) plugins. (See more under [Plugins](#plugins)).
50
+ - Automatically enables relevant rules based on the [engines](https://docs.npmjs.com/files/package.json#engines) field in your `package.json`.
51
+ - Easily configure stylistic preferences like indent and semicolon without deep diving into rule configurations.
52
+ - Works alongside Prettier: Our configuration disables ESLint rules that would conflict with Prettier, allowing ESLint to focus on code quality and Prettier on formatting if you choose to use both. However, many stylistic rules are included and can be enforced by ESLint directly.
47
53
 
48
54
  ## Install
49
55
 
50
56
  To install this config, run the following command.
51
57
 
52
- > Note: `eslint-plugin-import@npm:eslint-plugin-i` is needed to use the correct package.
53
-
54
58
  ```bash
55
- npm install --save-dev eslint @anolilab/eslint-config eslint-plugin-import@npm:eslint-plugin-i@latest @babel/core @eslint-types/import @eslint-types/deprecation @eslint-types/jsdoc @eslint-types/typescript-eslint @eslint-types/unicorn
59
+ npm install --save-dev eslint @anolilab/eslint-config
56
60
  ```
57
61
 
58
62
  ```sh
59
- pnpm add -D eslint @anolilab/eslint-config eslint-plugin-import@npm:eslint-plugin-i@latest @babel/core @eslint-types/import @eslint-types/deprecation @eslint-types/jsdoc @eslint-types/typescript-eslint @eslint-types/unicorn
63
+ pnpm add -D eslint @anolilab/eslint-config
60
64
  ```
61
65
 
62
66
  ```sh
63
- yarn add -D eslint @anolilab/eslint-config eslint-plugin-import@npm:eslint-plugin-i@latest @babel/core @eslint-types/import @eslint-types/deprecation @eslint-types/jsdoc @eslint-types/typescript-eslint @eslint-types/unicorn
67
+ yarn add -D eslint @anolilab/eslint-config
64
68
  ```
65
69
 
66
70
  ## Usage
67
71
 
68
- If you don’t have a `.eslintrc.js`, we will create the file for you after installing `@anolilab/eslint-config`.
72
+ Our default export is designed to be used within ESLint's flat configuration system (e.g., `eslint.config.js`). It contains a comprehensive set of ESLint rules, suitable for modern ECMAScript (ES2021+ by default) and TypeScript projects.
69
73
 
70
- If you already have a `.eslintrc.js`, then you can extend the `.eslintrc.js`, with `@anolilab/eslint-config`.
74
+ To use it, import the `createConfig` function from `@anolilab/eslint-config` into your `eslint.config.js` (or `eslint.config.mjs`). This function allows you to generate the configuration, optionally with your own settings.
71
75
 
72
- > Note: If the script detects an existing `.eslintrc.js` file, it will not overwrite it.
73
-
74
- > Note: It can happen that the postinstall script don't run, then you have to add the `.eslintrc.js` manually, or you will use bin command `./node_modules/bin/anolilab-eslint-config` to generate it.
75
-
76
- > Note: Our default export contains all of our ESLint rules, including ECMAScript 6+. `@anolilab/eslint-config` use the `ecmaVersion`:`2021` as default.
77
- >
78
- > To change this configuration, change `env: { es2021: false, then active you needed env }` same for, `parserOptions: { "ecmaVersion": 2021 change the version }`
76
+ Create `eslint.config.mjs` in your project root:
79
77
 
80
78
  ```js
81
- /** @ts-check */
82
- const { defineConfig } = require('@anolilab/eslint-config/define-config');
83
-
84
- /// <reference types="@eslint-types/unicorn" />
85
- /// <reference types="@eslint-types/typescript-eslint" />
86
- /// <reference types="@eslint-types/jsdoc" />
87
- /// <reference types="@eslint-types/import" />
88
- /// <reference types="@eslint-types/deprecation" />
89
-
90
- module.exports = defineConfig({
91
- env: {
92
- // Your environments (which contains several predefined global variables)
93
- //
94
- // browser: true,
95
- // node: true,
96
- // mocha: true,
97
- // jest: true,
98
- // jquery: true
99
- },
100
- extends: ["@anolilab/eslint-config"],
101
- globals: {
102
- // Your global variables (setting to false means it's not allowed to be reassigned)
103
- //
104
- // myGlobal: false
105
- },
106
- root: true,
107
- rules: {
108
- // Customize your rules
109
- },
110
- });
111
- ```
112
-
113
- For more advanced use cases see the example configurations for Node, TypeScript, React or Prettier.
114
-
115
- > Note: `@anolilab/eslint-config` will handle the configuration for almost all eslint-plugins / eslint-configs automatically.
116
- > With this you only need to install the needed plugins/configs for TypeScript or React and you done.
79
+ // eslint.config.mjs
117
80
 
118
- ### TypeScript
81
+ import { createConfig } from "@anolilab/eslint-config";
119
82
 
120
- ```bash
121
- npm install --save-dev typescript
83
+ export default createConfig();
122
84
  ```
123
85
 
124
- Please extend the `.eslintrc.js` file with the correct `tsconfig.js` path if you have a custom path.
125
-
126
- ```js
127
- module.exports = {
128
- parserOptions: {
129
- project: "./tsconfig.eslint.json",
130
- },
131
- };
132
- ```
86
+ <details>
87
+ <summary>
88
+ Combined with legacy config:
89
+ </summary>
133
90
 
134
- For projects that use TypeScript and want additional rules that require type information (rules using type information take longer to run).
135
-
136
- Extend the `.eslintrc.js` file:
91
+ If you still use some configs from the legacy eslintrc format, you can use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
137
92
 
138
93
  ```js
139
- /** @ts-check */
140
- const { defineConfig } = require('@anolilab/eslint-config/define-config');
141
-
142
- /// <reference types="@eslint-types/unicorn" />
143
- /// <reference types="@eslint-types/typescript-eslint" />
144
- /// <reference types="@eslint-types/jsdoc" />
145
- /// <reference types="@eslint-types/import" />
146
- /// <reference types="@eslint-types/deprecation" />
147
-
148
- module.exports = defineConfig({
149
- env: {
150
- // Your environments (which contains several predefined global variables)
151
- //
152
- // browser: true,
153
- // node: true,
154
- // mocha: true,
155
- // jest: true,
156
- // jquery: true
157
- },
158
- extends: ["@anolilab/eslint-config", "@anolilab/eslint-config/typescript-type-checking"],
159
- globals: {
160
- // Your global variables (setting to false means it's not allowed to be reassigned)
161
- //
162
- // myGlobal: false
163
- },
164
- root: true,
165
- rules: {
166
- // Customize your rules
167
- },
168
- });
169
- ```
170
-
171
- > Tip: Run eslint with the TIMING=1 to identify slow rules.
172
- >
173
- > `TIMING=1 eslint . --ext .ts,.tsx`
174
- >
175
- > This is useful to identify rules that are slow because they require type information.
176
-
177
- ### React
94
+ // eslint.config.mjs
95
+ import { createConfig } from "@anolilab/eslint-config";
96
+ import { FlatCompat } from "@eslint/eslintrc";
178
97
 
179
- You need to have "react" and "react-dom" installed.
98
+ const compat = new FlatCompat();
180
99
 
181
- ```bash
182
- npm install --save-dev eslint-plugin-react eslint-plugin-react-hooks
183
-
184
- yarn add -D eslint-plugin-react eslint-plugin-react-hooks
185
-
186
- pnpm add -D eslint-plugin-react eslint-plugin-react-hooks
187
- ```
188
-
189
- Or for the use of `TypeScript` in react install "typescript" as a dev dependency.
190
-
191
- Please extend the `.eslintrc.js` file with the correct `tsconfig.js` path if you have a custom path.
192
-
193
- ```js
194
- module.exports = {
195
- parserOptions: {
196
- project: "./tsconfig.eslint.json",
100
+ export default createConfig(
101
+ {
102
+ ignores: [],
197
103
  },
198
- };
199
- ```
200
104
 
201
- Or for the use of `.jsx` files install "@babel/plugin-syntax-jsx" as a dev dependency.
105
+ // Legacy config
106
+ ...compat.config({
107
+ extends: [
108
+ "eslint:recommended",
109
+ // Other extends...
110
+ ],
111
+ })
202
112
 
203
- ```bash
204
- npm install --save-dev babel @babel/plugin-syntax-jsx
205
-
206
- yarn add -D babel @babel/plugin-syntax-jsx
207
-
208
- pnpm add -D babel @babel/plugin-syntax-jsx
209
- ```
210
-
211
- In your `babel.config.js` file add the plugin.
212
-
213
- ```js
214
- const babelPluginSyntaxJSX = require("@babel/plugin-syntax-jsx");
215
-
216
- module.exports = {
217
- plugins: [
218
- [
219
- babelPluginSyntaxJSX,
220
- {
221
- pragma: "React.createElement",
222
- pragmaFrag: "React.Fragment",
223
- },
224
- ],
225
- ],
226
- };
113
+ // Other flat configs...
114
+ );
227
115
  ```
228
116
 
229
- ### MDX
117
+ > Note that `.eslintignore` no longer works in Flat config.
230
118
 
231
- ```bash
232
- npm install --save-dev eslint eslint-plugin-mdx
233
- ```
119
+ </details>
234
120
 
235
- For more information about `missing` or `optional` to install rules see the `eslint` console output.
121
+ Or you can configure each integration individually, for example:
236
122
 
237
- ### Config
123
+ ```js
124
+ // eslint.config.js
125
+ import { createConfig } from "@anolilab/eslint-config";
238
126
 
239
- You can configure `@anolilab/eslint-config` options with your `package.json` file.
127
+ export default createConfig({
128
+ // Enable stylistic formatting rules
129
+ // stylistic: true,
240
130
 
241
- Add this property to your package.json:
131
+ // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
132
+ ignores: [
133
+ "**/fixtures",
134
+ // ...globs
135
+ ],
242
136
 
243
- ```json5
244
- {
245
- anolilab: {
246
- "eslint-config": {
247
- // options
248
- },
137
+ // Disable jsonc and yaml support
138
+ jsonc: false,
139
+ // Or customize the stylistic rules
140
+ stylistic: {
141
+ indent: 2, // 4, or 'tab'
142
+ quotes: "single", // or 'double'
249
143
  },
250
- }
251
- ```
252
-
253
- #### indent
254
-
255
- Type: `number`
256
-
257
- Default: `4`
258
144
 
259
- It will throw an error if the value is not numeric.
145
+ // TypeScript and Vue are autodetected, you can also explicitly enable them:
146
+ typescript: true,
147
+ vue: true,
260
148
 
261
- #### plugin
262
-
263
- Type: `object` -> key: `string` value: `boolean`
264
-
265
- Disable a plugin in your package.json config to turn it off globally in your project.
266
-
267
- Example using package.json:
268
-
269
- ```json
270
- {
271
- "anolilab": {
272
- "eslint-config": {
273
- "plugin": {
274
- "unicorn": false
275
- }
276
- }
277
- }
278
- }
149
+ yaml: false
150
+ });
279
151
  ```
280
152
 
281
- #### warn_on_unsupported_typescript_version
282
-
283
- Type: `boolean`
153
+ ### Add script for package.json
284
154
 
285
- Default: `undefined`
286
-
287
- To disable the warning, set the value to `false`.
155
+ For example:
288
156
 
289
157
  ```json
290
158
  {
291
- "anolilab": {
292
- "eslint-config": {
293
- "warn_on_unsupported_typescript_version": false
294
- }
159
+ "scripts": {
160
+ "lint": "eslint .",
161
+ "lint:fix": "eslint . --fix"
295
162
  }
296
163
  }
297
164
  ```
298
165
 
299
- #### info_on_disabling_jsx_react_rule
300
-
301
- Type: `boolean`
166
+ The factory function also accepts any number of arbitrary custom config overrides:
302
167
 
303
- Default: `undefined`
168
+ ```js
169
+ // eslint.config.js
170
+ import { createConfig } from "@anolilab/eslint-config";
304
171
 
305
- To disable the info, set the value to `false`.
172
+ export default createConfig(
173
+ {
174
+ // Configures for anolilab's config
175
+ },
306
176
 
307
- ```json
308
- {
309
- "anolilab": {
310
- "eslint-config": {
311
- "info_on_disabling_jsx_react_rule": false
312
- }
313
- }
314
- }
177
+ // From the second arguments they are ESLint Flat Configs
178
+ // you can have multiple configs
179
+ {
180
+ files: ["**/*.ts"],
181
+ rules: {},
182
+ },
183
+ {
184
+ rules: {},
185
+ },
186
+ );
315
187
  ```
316
188
 
317
- #### info_on_disabling_prettier_conflict_rule
318
-
319
- Type: `boolean`
320
-
321
- Default: `undefined`
189
+ We also provided the `overrides` options in each integration to make it easier:
322
190
 
323
- To disable the info, set the value to `false`.
191
+ ```js
192
+ // eslint.config.js
193
+ import { createConfig } from "@anolilab/eslint-config";
324
194
 
325
- ```json
326
- {
327
- "anolilab": {
328
- "eslint-config": {
329
- "info_on_disabling_prettier_conflict_rule": false
330
- }
331
- }
332
- }
195
+ export default createConfig({
196
+ typescript: {
197
+ overrides: {
198
+ "ts/consistent-type-definitions": ["error", "interface"],
199
+ },
200
+ },
201
+ yaml: {
202
+ overrides: {
203
+ // ...
204
+ },
205
+ },
206
+ });
333
207
  ```
334
208
 
335
- #### info_on_disabling_jsonc_sort_keys_rule
336
-
337
- Type: `boolean`
338
-
339
- Default: `undefined`
340
-
341
- To disable the info, set the value to `false`.
342
-
343
- ```json
344
- {
345
- "anolilab": {
346
- "eslint-config": {
347
- "info_on_disabling_jsonc_sort_keys_rule": false
348
- }
349
- }
350
- }
351
- ```
209
+ ## IDE Support (auto fix on save)
352
210
 
353
- #### info_on_disabling_etc_no_deprecated
211
+ <details>
212
+ <summary>🟦 VS Code support</summary>
354
213
 
355
- Type: `boolean`
214
+ <br>
356
215
 
357
- Default: `undefined`
216
+ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
358
217
 
359
- To disable the info, set the value to `false`.
218
+ Add the following settings to your `.vscode/settings.json`:
360
219
 
361
- ```json
220
+ ```jsonc
362
221
  {
363
- "anolilab": {
364
- "eslint-config": {
365
- "info_on_disabling_etc_no_deprecated": false
366
- }
367
- }
368
- }
369
- ```
370
-
371
- #### info_on_testing_library_framework
222
+ // Disable the default formatter, use eslint instead
223
+ "prettier.enable": false,
224
+ "editor.formatOnSave": false,
372
225
 
373
- Type: `boolean`
374
-
375
- Default: `undefined`
226
+ // Auto fix
227
+ "editor.codeActionsOnSave": {
228
+ "source.fixAll.eslint": "explicit",
229
+ "source.organizeImports": "never"
230
+ },
376
231
 
377
- To disable the info, set the value to `false`.
232
+ // Silent the stylistic rules in you IDE, but still auto fix them
233
+ "eslint.rules.customizations": [
234
+ { "rule": "style/*", "severity": "off", "fixable": true },
235
+ { "rule": "format/*", "severity": "off", "fixable": true },
236
+ { "rule": "*-indent", "severity": "off", "fixable": true },
237
+ { "rule": "*-spacing", "severity": "off", "fixable": true },
238
+ { "rule": "*-spaces", "severity": "off", "fixable": true },
239
+ { "rule": "*-order", "severity": "off", "fixable": true },
240
+ { "rule": "*-dangle", "severity": "off", "fixable": true },
241
+ { "rule": "*-newline", "severity": "off", "fixable": true },
242
+ { "rule": "*quotes", "severity": "off", "fixable": true },
243
+ { "rule": "*semi", "severity": "off", "fixable": true }
244
+ ],
378
245
 
379
- ```json
380
- {
381
- "anolilab": {
382
- "eslint-config": {
383
- "info_on_testing_library_framework": false
384
- }
385
- }
246
+ // Enable eslint for all supported languages
247
+ "eslint.validate": [
248
+ "javascript",
249
+ "javascriptreact",
250
+ "typescript",
251
+ "typescriptreact",
252
+ "vue",
253
+ "html",
254
+ "markdown",
255
+ "json",
256
+ "jsonc",
257
+ "yaml",
258
+ "toml",
259
+ "xml",
260
+ "gql",
261
+ "graphql",
262
+ "astro",
263
+ "svelte",
264
+ "css",
265
+ "less",
266
+ "scss",
267
+ "pcss",
268
+ "postcss"
269
+ ]
386
270
  }
387
271
  ```
388
272
 
389
- #### info_on_found_react_version
273
+ </details>
390
274
 
391
- Type: `boolean`
275
+ <details>
276
+ <summary>🟩 Neovim Support</summary>
392
277
 
393
- Default: `undefined`
278
+ <br>
394
279
 
395
- To disable the info, set the value to `false`.
280
+ Update your configuration to use the following:
396
281
 
397
- ```json
398
- {
399
- "anolilab": {
400
- "eslint-config": {
401
- "info_on_found_react_version": false
402
- }
403
- }
282
+ ```lua
283
+ local customizations = {
284
+ { rule = 'style/*', severity = 'off', fixable = true },
285
+ { rule = 'format/*', severity = 'off', fixable = true },
286
+ { rule = '*-indent', severity = 'off', fixable = true },
287
+ { rule = '*-spacing', severity = 'off', fixable = true },
288
+ { rule = '*-spaces', severity = 'off', fixable = true },
289
+ { rule = '*-order', severity = 'off', fixable = true },
290
+ { rule = '*-dangle', severity = 'off', fixable = true },
291
+ { rule = '*-newline', severity = 'off', fixable = true },
292
+ { rule = '*quotes', severity = 'off', fixable = true },
293
+ { rule = '*semi', severity = 'off', fixable = true },
404
294
  }
405
- ```
406
295
 
407
- #### import_ignore_exports
296
+ local lspconfig = require('lspconfig')
297
+ -- Enable eslint for all supported languages
298
+ lspconfig.eslint.setup(
299
+ {
300
+ filetypes = {
301
+ "javascript",
302
+ "javascriptreact",
303
+ "javascript.jsx",
304
+ "typescript",
305
+ "typescriptreact",
306
+ "typescript.tsx",
307
+ "vue",
308
+ "html",
309
+ "markdown",
310
+ "json",
311
+ "jsonc",
312
+ "yaml",
313
+ "toml",
314
+ "xml",
315
+ "gql",
316
+ "graphql",
317
+ "astro",
318
+ "svelte",
319
+ "css",
320
+ "less",
321
+ "scss",
322
+ "pcss",
323
+ "postcss"
324
+ },
325
+ settings = {
326
+ -- Silent the stylistic rules in you IDE, but still auto fix them
327
+ rulesCustomizations = customizations,
328
+ },
329
+ }
330
+ )
331
+ ```
408
332
 
409
- Type: `string[]`
333
+ ### Neovim format on save
410
334
 
411
- Default: `[]`
335
+ There's few ways you can achieve format on save in neovim:
412
336
 
413
- An array with files/paths for which unused exports will not be reported (e.g module entry points in a published package).
337
+ - `nvim-lspconfig` has a `EslintFixAll` command predefined, you can create a autocmd to call this command after saving file.
414
338
 
415
- ```json
416
- {
417
- "anolilab": {
418
- "eslint-config": {
419
- "import_ignore_exports": []
420
- }
421
- }
422
- }
339
+ ```lua
340
+ lspconfig.eslint.setup({
341
+ --- ...
342
+ on_attach = function(client, bufnr)
343
+ vim.api.nvim_create_autocmd("BufWritePre", {
344
+ buffer = bufnr,
345
+ command = "EslintFixAll",
346
+ })
347
+ end,
348
+ })
423
349
  ```
424
350
 
425
- ### Let [Prettier](https://prettier.io/) handle style-related rules
351
+ - Use [conform.nvim](https://github.com/stevearc/conform.nvim).
352
+ - Use [none-ls](https://github.com/nvimtools/none-ls.nvim)
353
+ - Use [nvim-lint](https://github.com/mfussenegger/nvim-lint)
426
354
 
427
- Prettier is a code formatting tool that offers fewer options but is more professional than the style-related rules in ESLint.
355
+ </details>
428
356
 
429
- Now that Prettier has become a necessary tool in front end projects, `@anolilab/eslint-config` does not need to maintain the style-related rules in ESLint anymore,
430
- so we completely removed all Prettier related rules, if `prettier` is found in your `package.json` and use ESLint to check logical errors which it’s good at.
357
+ ## Plugins
431
358
 
432
- As for whether two spaces or four spaces are used for indentation and whether there is a semicolon at the end, you can configure it in the project’s `.prettierrc.js`.
433
- Of course, we also provide a recommended Prettier [configuration](../prettier-config/README.md) for your reference.
359
+ Our configuration integrates a wide array of ESLint plugins to cover various aspects of code quality, language support, security, and specific libraries/frameworks. Many of these are enabled automatically when relevant dependencies are detected in your project.
434
360
 
435
- `@anolilab/eslint-config` does disable all included style-related rules, so there is no need to install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier).
361
+ ### Core & Code Quality
436
362
 
437
- ## Using experimental features with JavaScript
363
+ These plugins form the backbone of our linting rules, focusing on best practices, consistency, and potential errors.
438
364
 
439
- If you are using experimental features such as class fields with JavaScript files you should install `@babel/eslint-parser`.
365
+ - **[@eslint/js](https://www.npmjs.com/package/@eslint/js)**: Core ESLint rules.
366
+ - **[eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)**: Various awesome ESLint rules.
367
+ - **[eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs)**: Rules to detect bugs and code smells.
368
+ - **[eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise)**: Enforce best practices for JavaScript promises.
369
+ - **[eslint-plugin-es-x](https://github.com/eslint-community/eslint-plugin-es-x)** (formerly `eslint-plugin-es`): Prevent ES6+ syntax from being used in ES5 environments.
370
+ - **[eslint-plugin-antfu](https://github.com/antfu/eslint-config)**: Opinionated linting rules by Anthony Fu.
371
+ - **[eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist)**: Rules for sorting and ordering various data structures.
372
+ - **[eslint-plugin-no-for-of-array](https://github.com/smelukov/eslint-plugin-no-for-of-array)**: Disallow `for...of` loops on arrays (promoting array methods).
373
+ - **[eslint-plugin-unused-imports](https://github.com/sweepline/eslint-plugin-unused-imports)**: Find and remove unused ES6 imports.
440
374
 
441
- ```bash
442
- npm install --save-dev @babel/core
443
- ```
375
+ ### Stylistic & Formatting
444
376
 
445
- ## Plugins
377
+ These plugins help maintain a consistent code style. Note that while these are included, you can also use Prettier for formatting, and our config is designed to be compatible.
446
378
 
447
- ### Code Quality
379
+ - **[@stylistic/eslint-plugin](https://eslint.style/packages/default)** (and `@stylistic/eslint-plugin-ts`): ESLint Stylistic, for all stylistic rules.
380
+ - **[eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort)**: Easy import sorting.
381
+ - **[eslint-plugin-format](https://github.com/antfu/eslint-plugin-format)**: Enables formatting of various file types using Prettier or other formatters via ESLint.
448
382
 
449
- This plugin provide a range of code quality rules:
383
+ ### Language Support & Syntax
450
384
 
451
- - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
452
- - [eslint-plugin-antfu](https://github.com/antfu/eslint-config)
385
+ Plugins for specific languages or syntaxes beyond standard JavaScript/TypeScript.
453
386
 
454
- ### Languages
387
+ - **[@typescript-eslint/eslint-plugin](https://typescript-eslint.io/)**: The tooling that enables ESLint to lint TypeScript code.
388
+ - **[eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc)**: ESLint plugin for JSON, JSONC, and JSON5 files.
389
+ - **[eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml)**: ESLint plugin for YAML files.
390
+ - **[eslint-plugin-toml](https://github.com/ota-meshi/eslint-plugin-toml)**: ESLint plugin for TOML files.
391
+ - **[eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html)**: An ESLint plugin to extract and lint script tags from HTML files.
392
+ - **[@html-eslint/eslint-plugin](https://html-eslint.org/)**: Alternative ESLint plugin for HTML files.
393
+ - **[@eslint/markdown](https://www.npmjs.com/package/@eslint/markdown)**: Lint JavaScript code blocks in Markdown documents.
394
+ - **[eslint-plugin-astro](https://github.com/ota-meshi/eslint-plugin-astro)**: ESLint plugin for Astro components.
455
395
 
456
- The following plugins expand esLint to work with json files, and lint JavaScript contained in HTML, and MarkDown:
396
+ ### Import & Module System
457
397
 
458
- - [eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html)
459
- - [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc)
460
- - [eslint-plugin-markdown](https://github.com/eslint/eslint-plugin-markdown)
461
- - [eslint-plugin-mdx](https://github.com/mdx-js/eslint-mdx)
462
- - [eslint-plugin-toml](https://github.com/ota-meshi/eslint-plugin-toml)
463
- - [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml)
398
+ Managing imports and module structure.
464
399
 
465
- When linting code snippets in Markdown files, a few [rules](src/config/plugins/markdown.ts#L3) relating to globals and unused vars are disabled.
400
+ - **[eslint-plugin-import-x](https://github.com/un-es/eslint-plugin-import-x)** (formerly `eslint-plugin-import`): Linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
401
+ * Uses `eslint-import-resolver-node` and `eslint-import-resolver-typescript`.
402
+ - **[eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)** (formerly `eslint-plugin-node`): Additional ESLint rules for Node.js.
466
403
 
467
- ### Library Plugins
404
+ ### Security
468
405
 
469
- If a supported library is part of your project then it’s related esLint plugins will be loaded. The following plugins are supported:
406
+ Plugins focused on identifying potential security vulnerabilities.
470
407
 
471
- - [eslint-plugin-fsa](https://github.com/joseph-galindo/eslint-plugin-fsa)
472
- - [eslint-plugin-lodash](https://github.com/wix/eslint-plugin-lodash)
473
- - You need to install `eslint-plugin-lodash` and `lodash` to use this plugin.
474
- - [eslint-plugin-lodash-fp](https://github.com/jfmengels/eslint-plugin-lodash-fp)
475
- - You need to install `eslint-plugin-lodash-fp` and `lodash` to use this plugin.
476
- - [eslint-plugin-react-redux](https://github.com/DianaSuvorova/eslint-plugin-react-redux#readme)
477
- - You need to install `eslint-plugin-react-redux` and `react-redux` to use this plugin.
478
- - [eslint-plugin-redux-saga](https://github.com/pke/eslint-plugin-redux-saga)
479
- - You need to install `eslint-plugin-redux-saga` and `redux-saga` to use this plugin.
408
+ - **[eslint-plugin-security](https://github.com/eslint-community/eslint-plugin-security)**: ESLint rules for Node Security.
409
+ - **[eslint-plugin-no-secrets](https://github.com/nickdeis/eslint-plugin-no-secrets)**: An ESLint plugin that detects potential secrets/credentials.
410
+ - **[eslint-plugin-no-unsanitized](https://github.com/mozilla/eslint-plugin-no-unsanitized)**: ESLint plugin for security related rules regarding untrusted input.
480
411
 
481
- ### Practices
412
+ ### Testing
482
413
 
483
- The following esLint plugins enforce good coding practices:
414
+ Plugins for various testing frameworks and practices.
484
415
 
485
- - [eslint-plugin-array-func](https://github.com/freaktechnik/eslint-plugin-array-func)
486
- - [eslint-plugin-eslint-comments](https://github.com/mysticatea/eslint-plugin-eslint-comments)
487
- - [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise)
488
- - [eslint-plugin-no-loops](https://github.com/buildo/eslint-plugin-no-loops)
489
- - [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort)
490
- - [eslint-plugin-es-x](https://github.com/eslint-community/eslint-plugin-es-x)
416
+ - **[eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests)**: Disallow `.only` calls in test files.
417
+ - **[eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library)**: ESLint plugin for Testing Library.
418
+ - **[eslint-plugin-playwright](https://github.com/playwright-community/eslint-plugin-playwright)**: ESLint plugin for Playwright.
491
419
 
492
- ### Security
420
+ ### Frameworks & Libraries
493
421
 
494
- These plugins add code security rules to esLint:
495
-
496
- - [eslint-plugin-no-secrets](https://github.com/nickdeis/eslint-plugin-no-secrets)
497
- - [eslint-plugin-no-unsanitized](https://github.com/mozilla/eslint-plugin-no-unsanitized)
498
- - [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs)
499
- - [eslint-plugin-security](https://github.com/eslint-community/eslint-plugin-security)
500
- - [rushstack/eslint-plugin-security](https://www.npmjs.com/package/@rushstack/eslint-plugin-security)
501
-
502
- ### Test Libraries
503
-
504
- The following test plugins are supported:
505
-
506
- - [eslint-plugin-ava](https://github.com/avajs/eslint-plugin-ava)
507
- - You need to install `eslint-plugin-ava` and `ava` to use this plugin.
508
- - [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
509
- - You need to install `eslint-plugin-jest` and `jest` to use this plugin.
510
- - [eslint-plugin-jest-async](https://www.npmjs.com/package/eslint-plugin-jest-async)
511
- - You need to install `eslint-plugin-jest-async` and `jest` to use this plugin.
512
- - [eslint-plugin-cypress](https://github.com/cypress-io/eslint-plugin-cypress)
513
- - You need to install `eslint-plugin-cypress` and `cypress` to use this plugin.
514
-
515
- ### List of used plugins
516
-
517
- - eslint-plugin-security
518
- - @rushstack/eslint-plugin-security
519
- - @typescript-eslint/eslint-plugin
520
- - eslint-plugin-antfu
521
- - eslint-plugin-compat
522
- - eslint-plugin-es-x
523
- - eslint-plugin-eslint-comments
524
- - eslint-plugin-html
525
- - eslint-plugin-i
526
- - eslint-plugin-jsonc
527
- - eslint-plugin-markdown
528
- - eslint-plugin-mdx
529
- - eslint-plugin-no-loops
530
- - eslint-plugin-no-only-tests
531
- - eslint-plugin-no-secrets
532
- - eslint-plugin-no-use-extend-native
533
- - eslint-plugin-promise
534
- - eslint-plugin-regexp
535
- - eslint-plugin-simple-import-sort
536
- - eslint-plugin-sonarjs
537
- - eslint-plugin-toml
538
- - eslint-plugin-typescript-sort-keys
539
- - eslint-plugin-unicorn
540
- - eslint-plugin-yml
541
-
542
- ## Troubleshooting
543
-
544
- ### With VSCode
545
-
546
- ESLint will not lint `.vue`, `.ts` or `.tsx` files in VSCode by default, you need to set your `.vscode/settings.json` like this:
422
+ Support for specific UI frameworks, libraries, and tools.
547
423
 
548
- ```json
549
- {
550
- "eslint.validate": ["css", "html", "javascript", "javascriptreact", "json", "markdown", "typescript", "typescriptreact", "yaml"]
551
- }
552
- ```
424
+ - **[@eslint-react/eslint-plugin](https://github.com/AriPerkkio/eslint-react)**: A comprehensive ESLint plugin for React.
425
+ - **[eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)**: ESLint rules for React Hooks.
426
+ - **[eslint-plugin-react-refresh](https://www.npmjs.com/package/eslint-plugin-react-refresh)**: Enforces best practices for React Fast Refresh.
427
+ - **[eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)**: Static AST checker for accessibility rules on JSX elements.
428
+ - **[eslint-plugin-validate-jsx-nesting](https://github.com/TitTat/eslint-plugin-validate-jsx-nesting)**: Validate JSX element nesting.
429
+ - **[eslint-plugin-tailwindcss](https://github.com/francoismassart/eslint-plugin-tailwindcss)**: ESLint plugin for Tailwind CSS.
430
+ - **[eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook)**: Best practice rules for Storybook.
431
+ - **[@tanstack/eslint-plugin-query](https://tanstack.com/query/latest/docs/eslint/eslint-plugin-query)**: ESLint rules for TanStack Query.
432
+ - **[@tanstack/eslint-plugin-router](https://tanstack.com/router/latest/docs/eslint/eslint-plugin-router)**: ESLint rules for TanStack Router.
433
+ - **[@unocss/eslint-plugin](https://github.com/unocss/unocss/tree/main/packages/eslint-plugin)**: ESLint plugin for UnoCSS.
434
+ - **[eslint-plugin-zod](https://github.com/IsaacScript/eslint-plugin-zod)**: ESLint rules for Zod schemas.
435
+ - **[eslint-plugin-you-dont-need-lodash-underscore](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore)**: Encourages use of native JavaScript methods over Lodash/Underscore.
553
436
 
554
- #### Autofix ESLint errors on save
437
+ ### Documentation & Comments
555
438
 
556
- If you want to enable auto-fix-on-save, you need to set your `.vscode/settings.json` like this:
439
+ - **[@eslint-community/eslint-plugin-eslint-comments](https://github.com/eslint-community/eslint-plugin-eslint-comments)** (formerly `eslint-plugin-eslint-comments`): Additional ESLint rules for ESLint directive comments (`/*eslint-...*/`).
440
+ - **[eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)**: JSDoc specific linting rules.
441
+ - **[eslint-plugin-tsdoc](https://github.com/microsoft/tsdoc/tree/main/eslint-plugin)**: TSDoc specific linting rules.
557
442
 
558
- ```json
559
- {
560
- "editor.codeActionsOnSave": {
561
- "source.fixAll.eslint": true
562
- },
563
- "editor.defaultFormatter": "dbaeumer.vscode-eslint",
564
- "editor.formatOnSave": true
565
- }
566
- ```
443
+ ### Compatibility & Others
444
+
445
+ - **[eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat)**: Lint the browser compatibility of your code.
446
+ - **[eslint-config-flat-gitignore](https://github.com/antfu/eslint-config-flat-gitignore)**: Utility to use .gitignore in flat config.
447
+ - **[eslint-flat-config-utils](https://github.com/antfu/eslint-flat-config-utils)**: Utilities for working with ESLint flat config.
448
+ - **[eslint-merge-processors](https://github.com/eslint/eslint-merge-processors)**: Utility to merge ESLint processors.
449
+ - **[@eslint/compat](https://www.npmjs.com/package/@eslint/compat)**: Utilities for compatibility between ESLint flat config and eslintrc.
567
450
 
568
- Additionally, we found it that being explicit about which formatter you are using for each file improves DX:
451
+ ---
569
452
 
453
+ ### List of Used Plugins (Condensed)
454
+
455
+ This list is a more condensed version and might not be exhaustive if some plugins are very specific or utility-based. It aims to provide a quick overview of the primary active linting plugins.
456
+
457
+ - `@eslint/js`
458
+ - `@stylistic/eslint-plugin`
459
+ - `@typescript-eslint/eslint-plugin`
460
+ - `@eslint-community/eslint-plugin-eslint-comments`
461
+ - `@eslint-react/eslint-plugin`
462
+ - `@tanstack/eslint-plugin-query`
463
+ - `@tanstack/eslint-plugin-router`
464
+ - `@unocss/eslint-plugin`
465
+ - `eslint-plugin-antfu`
466
+ - `eslint-plugin-astro`
467
+ - `eslint-plugin-compat`
468
+ - `eslint-plugin-es-x`
469
+ - `eslint-plugin-format`
470
+ - `eslint-plugin-html` (or `@html-eslint/eslint-plugin`)
471
+ - `eslint-plugin-import-x`
472
+ - `eslint-plugin-jsdoc`
473
+ - `eslint-plugin-jsonc`
474
+ - `eslint-plugin-jsx-a11y`
475
+ - `eslint-plugin-n`
476
+ - `eslint-plugin-no-only-tests`
477
+ - `eslint-plugin-no-secrets`
478
+ - `eslint-plugin-no-unsanitized`
479
+ - `eslint-plugin-perfectionist`
480
+ - `eslint-plugin-playwright`
481
+ - `eslint-plugin-promise`
482
+ - `eslint-plugin-react-hooks`
483
+ - `eslint-plugin-regexp` (often a dependency of other plugins like SonarJS)
484
+ - `eslint-plugin-security`
485
+ - `eslint-plugin-simple-import-sort`
486
+ - `eslint-plugin-sonarjs`
487
+ - `eslint-plugin-storybook`
488
+ - `eslint-plugin-tailwindcss`
489
+ - `eslint-plugin-testing-library`
490
+ - `eslint-plugin-toml`
491
+ - `eslint-plugin-tsdoc`
492
+ - `eslint-plugin-unicorn`
493
+ - `eslint-plugin-unused-imports`
494
+ - `eslint-plugin-yml`
495
+ - `eslint-plugin-zod`
496
+ - `eslint-plugin-you-dont-need-lodash-underscore`
497
+
498
+ ## Our Stance on Formatting
499
+
500
+ This ESLint configuration includes stylistic rules that can format your JavaScript and TypeScript code, promoting consistency.
501
+
502
+ - **ESLint as the Primary Tool:** For JS/TS files, we encourage using ESLint for both linting code quality and enforcing code style. The VSCode settings above are configured to use ESLint as the default formatter for these files.
503
+ - **Working with Prettier:** If you use Prettier in your project, this config is designed to be compatible. It disables ESLint rules that would conflict with Prettier's formatting decisions. You can let Prettier handle formatting for files ESLint doesn't cover (like CSS, HTML, etc.), or even use Prettier for JS/TS formatting and then have ESLint apply further fixes. However, for a streamlined experience with JS/TS, letting ESLint handle all aspects (quality and style) is often simpler.
504
+
505
+ ## Lint Staged / Pre-commit Hooks
506
+
507
+ To ensure code is linted and fixed before committing, we recommend integrating with a pre-commit tool like `lint-staged` and `husky`. Our sister package, `@anolilab/lint-staged-config`, is designed to work seamlessly with this ESLint configuration.
508
+
509
+ Example `lint-staged` configuration in your `package.json` (or relevant file):
570
510
  ```json
511
+ // package.json
571
512
  {
572
- "[css]": {
573
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
574
- },
575
- "[html]": {
576
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
577
- },
578
- "[javascript]": {
579
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
580
- },
581
- "[javascriptreact]": {
582
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
583
- },
584
- "[json]": {
585
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
586
- },
587
- "[markdown]": {
588
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
589
- },
590
- "[typescript]": {
591
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
592
- },
593
- "[typescriptreact]": {
594
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
595
- },
596
- "[yaml]": {
597
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
513
+ "lint-staged": {
514
+ "*.{js,jsx,ts,tsx}": "eslint --fix"
515
+ // Add other linters for other file types if needed
598
516
  }
599
517
  }
600
518
  ```
519
+ Ensure `husky` is set up to run `lint-staged` on pre-commit.
601
520
 
602
- While not required if you've configured explicit formatter for each file type, I advise that you explicitly disable prettier extension in your project:
521
+ ## Versioning Policy
603
522
 
604
- ```json
605
- {
606
- "prettier.enable": false
607
- }
608
- ```
523
+ This project aims to follow Semantic Versioning.
524
+
525
+ - **Major versions:** May include breaking changes to ESLint configurations, Node.js version support, or significant plugin changes.
526
+ - **Minor versions:** May introduce new non-breaking rules, enable new plugins by default (if non-breaking), or update existing rules with new options.
527
+ - **Patch versions:** Typically include bug fixes or minor tweaks to rule configurations.
609
528
 
610
- Sharing these settings in your project should be sufficient to prevent local settings accidentally overriding the desired formatter behavior.
529
+ Changes to rule strictness (e.g., changing a 'warn' to an 'error') might occur in minor versions if they reflect evolving best practices. We recommend reviewing changes when updating.
611
530
 
612
531
  ## Q & A
613
532
 
614
533
  ### Why not standard
615
534
 
616
- The standard specification believes that everyone should not waste time in personalized specifications, but the entire community should unify a specification. This statement makes sense, but it runs against the ESLints design philosophy.
617
- Dont you remember how ESLint defeated JSHint and became the most popular JS code inspection tool? Its because of the plugin and configuration that ESLint advocates, which meets the individual needs of different technology stacks of different teams.
535
+ The standard specification believes that everyone should not waste time in personalized specifications, but the entire community should unify a specification. This statement makes sense, but it runs against the ESLint's design philosophy.
536
+ Don't you remember how ESLint defeated JSHint and became the most popular JS code inspection tool? It's because of the plugin and configuration that ESLint advocates, which meets the individual needs of different technology stacks of different teams.
618
537
 
619
538
  Therefore, `@anolilab/eslint-config` also inherits the philosophy of ESLint. It will not force you to use our config.
620
539
 
621
540
  ## Supported Node.js Versions
622
541
 
623
542
  Libraries in this ecosystem make the best effort to track
624
- [Node.js release schedule](https://nodejs.org/en/about/releases/). Heres [a
543
+ [Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a
625
544
  post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
626
545
 
627
546
  ## Contributing
@@ -632,11 +551,12 @@ If you would like to help take a look at the [list of issues](https://github.com
632
551
 
633
552
  ## Credits
634
553
 
635
- - [Daniel Bannert](https://github.com/prisis)
636
- - [All Contributors](https://github.com/anolilab/javascript-style-guide/graphs/contributors)
637
- - [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb)
638
- - [eslint-config-alloy](https://github.com/AlloyTeam/eslint-config-alloy)
639
- - [eslint-config-canonical](https://github.com/gajus/eslint-config-canonical)
554
+ - [Daniel Bannert](https://github.com/prisis)
555
+ - [All Contributors](https://github.com/anolilab/javascript-style-guide/graphs/contributors)
556
+ - Inspired by and thankful for the work in configurations like:
557
+ - [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb)
558
+ - [eslint-config-canonical](https://github.com/gajus/eslint-config-canonical)
559
+ - [@antfu/eslint-config](https://github.com/antfu/eslint-config) (for its modern approach and clear documentation)
640
560
 
641
561
  ## License
642
562