Skip to content

Commit 7079b99

Browse files
committed
feat: more work on the configs
Signed-off-by: prisis <[email protected]>
1 parent e1b3205 commit 7079b99

File tree

7 files changed

+31
-434
lines changed

7 files changed

+31
-434
lines changed

packages/eslint-config/README.md

-373
Original file line numberDiff line numberDiff line change
@@ -65,383 +65,10 @@ yarn add -D eslint @anolilab/eslint-config eslint-plugin-import@npm:eslint-plugi
6565

6666
## Usage
6767

68-
If you don’t have a `.eslintrc.js`, we will create the file for you after installing `@anolilab/eslint-config`.
69-
70-
If you already have a `.eslintrc.js`, then you can extend the `.eslintrc.js`, with `@anolilab/eslint-config`.
71-
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-
7668
> Note: Our default export contains all of our ESLint rules, including ECMAScript 6+. `@anolilab/eslint-config` use the `ecmaVersion`:`2021` as default.
7769
>
7870
> To change this configuration, change `env: { es2021: false, then active you needed env }` same for, `parserOptions: { "ecmaVersion": 2021 change the version }`
7971
80-
```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.
117-
118-
### TypeScript
119-
120-
```bash
121-
npm install --save-dev typescript
122-
```
123-
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-
```
133-
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:
137-
138-
```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
178-
179-
You need to have "react" and "react-dom" installed.
180-
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",
197-
},
198-
};
199-
```
200-
201-
Or for the use of `.jsx` files install "@babel/plugin-syntax-jsx" as a dev dependency.
202-
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-
};
227-
```
228-
229-
### MDX
230-
231-
```bash
232-
npm install --save-dev eslint eslint-plugin-mdx
233-
```
234-
235-
For more information about `missing` or `optional` to install rules see the `eslint` console output.
236-
237-
### Config
238-
239-
You can configure `@anolilab/eslint-config` options with your `package.json` file.
240-
241-
Add this property to your package.json:
242-
243-
```json5
244-
{
245-
"anolilab": {
246-
"eslint-config": {
247-
// options
248-
}
249-
}
250-
}
251-
```
252-
253-
#### indent
254-
255-
Type: `number`
256-
257-
Default: `4`
258-
259-
It will throw an error if the value is not numeric.
260-
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-
}
279-
```
280-
281-
#### warn_on_unsupported_typescript_version
282-
283-
Type: `boolean`
284-
285-
Default: `undefined`
286-
287-
To disable the warning, set the value to `false`.
288-
289-
```json
290-
{
291-
"anolilab": {
292-
"eslint-config": {
293-
"warn_on_unsupported_typescript_version": false
294-
}
295-
}
296-
}
297-
```
298-
299-
#### info_on_disabling_jsx_react_rule
300-
301-
Type: `boolean`
302-
303-
Default: `undefined`
304-
305-
To disable the info, set the value to `false`.
306-
307-
```json
308-
{
309-
"anolilab": {
310-
"eslint-config": {
311-
"info_on_disabling_jsx_react_rule": false
312-
}
313-
}
314-
}
315-
```
316-
317-
#### info_on_disabling_prettier_conflict_rule
318-
319-
Type: `boolean`
320-
321-
Default: `undefined`
322-
323-
To disable the info, set the value to `false`.
324-
325-
```json
326-
{
327-
"anolilab": {
328-
"eslint-config": {
329-
"info_on_disabling_prettier_conflict_rule": false
330-
}
331-
}
332-
}
333-
```
334-
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-
```
352-
353-
#### info_on_disabling_etc_no_deprecated
354-
355-
Type: `boolean`
356-
357-
Default: `undefined`
358-
359-
To disable the info, set the value to `false`.
360-
361-
```json
362-
{
363-
"anolilab": {
364-
"eslint-config": {
365-
"info_on_disabling_etc_no_deprecated": false
366-
}
367-
}
368-
}
369-
```
370-
371-
#### info_on_testing_library_framework
372-
373-
Type: `boolean`
374-
375-
Default: `undefined`
376-
377-
To disable the info, set the value to `false`.
378-
379-
```json
380-
{
381-
"anolilab": {
382-
"eslint-config": {
383-
"info_on_testing_library_framework": false
384-
}
385-
}
386-
}
387-
```
388-
389-
#### info_on_found_react_version
390-
391-
Type: `boolean`
392-
393-
Default: `undefined`
394-
395-
To disable the info, set the value to `false`.
396-
397-
```json
398-
{
399-
"anolilab": {
400-
"eslint-config": {
401-
"info_on_found_react_version": false
402-
}
403-
}
404-
}
405-
```
406-
407-
#### import_ignore_exports
408-
409-
Type: `string[]`
410-
411-
Default: `[]`
412-
413-
An array with files/paths for which unused exports will not be reported (e.g module entry points in a published package).
414-
415-
```json
416-
{
417-
"anolilab": {
418-
"eslint-config": {
419-
"import_ignore_exports": []
420-
}
421-
}
422-
}
423-
```
424-
425-
### Let [Prettier](https://prettier.io/) handle style-related rules
426-
427-
Prettier is a code formatting tool that offers fewer options but is more professional than the style-related rules in ESLint.
428-
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.
431-
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.
434-
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).
436-
437-
## Using experimental features with JavaScript
438-
439-
If you are using experimental features such as class fields with JavaScript files you should install `@babel/eslint-parser`.
440-
441-
```bash
442-
npm install --save-dev @babel/core
443-
```
444-
44572
## Plugins
44673

44774
### Code Quality

0 commit comments

Comments
 (0)