@1024pix/eslint-plugin 1.1.3 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/config.js +99 -0
- package/package.json +20 -4
- package/readme.md +74 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.2.1](https://github.com/1024pix/eslint-plugin/compare/v1.2.0...v1.2.1) (2024-05-29)
|
|
2
|
+
|
|
3
|
+
# [1.2.0](https://github.com/1024pix/eslint-plugin/compare/v1.1.3...v1.2.0) (2024-05-23)
|
|
4
|
+
|
|
5
|
+
### :rocket: Amélioration
|
|
6
|
+
|
|
7
|
+
- [#22](https://github.com/1024pix/eslint-plugin/pull/22) Supporter la Flat config ESLint
|
|
8
|
+
|
|
1
9
|
## [1.1.3](https://github.com/1024pix/eslint-plugin/compare/v1.1.2...v1.1.3) (2024-05-14)
|
|
2
10
|
|
|
3
11
|
### :arrow_up: Montée de version
|
package/config.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const { resolve } = require('node:path');
|
|
2
|
+
|
|
3
|
+
const js = require('@eslint/js');
|
|
4
|
+
const comments = require('@eslint-community/eslint-plugin-eslint-comments/configs');
|
|
5
|
+
const eslintPluginYml = require('eslint-plugin-yml');
|
|
6
|
+
const simpleImportSort = require('eslint-plugin-simple-import-sort');
|
|
7
|
+
const pixPlugin = require('./index.js');
|
|
8
|
+
|
|
9
|
+
module.exports = [
|
|
10
|
+
js.configs.recommended,
|
|
11
|
+
...eslintPluginYml.configs['flat/standard'],
|
|
12
|
+
comments.recommended,
|
|
13
|
+
{
|
|
14
|
+
plugins: {
|
|
15
|
+
'@1024pix': pixPlugin,
|
|
16
|
+
'simple-import-sort': simpleImportSort,
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
'arrow-parens': ['error', 'always'],
|
|
20
|
+
'comma-dangle': ['error', 'always-multiline'],
|
|
21
|
+
'computed-property-spacing': ['error', 'never'],
|
|
22
|
+
'eol-last': ['error'],
|
|
23
|
+
'@eslint-community/eslint-comments/no-unused-disable': ['error'],
|
|
24
|
+
indent: [
|
|
25
|
+
'error',
|
|
26
|
+
2,
|
|
27
|
+
{
|
|
28
|
+
SwitchCase: 1,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
'keyword-spacing': ['error'],
|
|
32
|
+
'linebreak-style': ['error', 'unix'],
|
|
33
|
+
'no-multiple-empty-lines': [
|
|
34
|
+
'error',
|
|
35
|
+
{
|
|
36
|
+
max: 1,
|
|
37
|
+
maxEOF: 1,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
'no-restricted-syntax': [
|
|
41
|
+
'error',
|
|
42
|
+
{
|
|
43
|
+
selector:
|
|
44
|
+
'NewExpression[callee.name=Date][arguments.length=1][arguments.0.type=Literal]:not([arguments.0.value=/^[12][0-9]{3}-(0[0-9]|1[0-2])-([0-2][0-9]|3[01])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]Z)?$/])',
|
|
45
|
+
message: "Use only ISO8601 UTC syntax ('2019-03-12T01:02:03Z') in Date constructor",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
selector:
|
|
49
|
+
"CallExpression[callee.object.object.name='faker'][callee.object.property.name='internet'][callee.property.name='email']",
|
|
50
|
+
message: 'Use only faker.internet.exampleEmail()',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
'no-restricted-globals': [
|
|
54
|
+
'error',
|
|
55
|
+
{
|
|
56
|
+
name: 'fetch',
|
|
57
|
+
message: "Use import fetch from 'fetch'",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
'no-unused-vars': [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
argsIgnorePattern: '_',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
'no-var': ['error'],
|
|
67
|
+
'object-curly-spacing': ['error', 'always'],
|
|
68
|
+
'prefer-const': ['error'],
|
|
69
|
+
quotes: ['error', 'single'],
|
|
70
|
+
semi: ['error', 'always'],
|
|
71
|
+
'simple-import-sort/imports': 'error',
|
|
72
|
+
'simple-import-sort/exports': 'error',
|
|
73
|
+
'space-before-blocks': ['error'],
|
|
74
|
+
'space-before-function-paren': [
|
|
75
|
+
'error',
|
|
76
|
+
{
|
|
77
|
+
anonymous: 'never',
|
|
78
|
+
named: 'never',
|
|
79
|
+
asyncArrow: 'ignore',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
'space-in-parens': ['error'],
|
|
83
|
+
'space-infix-ops': ['error'],
|
|
84
|
+
'func-call-spacing': ['error'],
|
|
85
|
+
'key-spacing': ['error'],
|
|
86
|
+
'comma-spacing': ['error'],
|
|
87
|
+
'no-trailing-spaces': ['error'],
|
|
88
|
+
'no-multi-spaces': ['error'],
|
|
89
|
+
'yml/quotes': [
|
|
90
|
+
'error',
|
|
91
|
+
{
|
|
92
|
+
prefer: 'single',
|
|
93
|
+
avoidEscape: true,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
'@1024pix/no-sinon-stub-with-args-oneliner': 'error',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
];
|
package/package.json
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1024pix/eslint-plugin",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Des règles de lint pour les projets 1024pix",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./config": "./config.js"
|
|
8
|
+
},
|
|
6
9
|
"scripts": {
|
|
7
10
|
"test": "node rules/*.test.js"
|
|
8
11
|
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
14
|
+
"eslint-plugin-simple-import-sort": "^12.1.0",
|
|
15
|
+
"eslint-plugin-yml": "^1.14.0"
|
|
16
|
+
},
|
|
9
17
|
"devDependencies": {
|
|
10
|
-
"eslint": "^8.
|
|
11
|
-
}
|
|
18
|
+
"eslint": "^8.57.0"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"eslint": ">=8.56.0"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/1024pix/eslint-plugin.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/1024pix/eslint-plugin#readme"
|
|
12
28
|
}
|
package/readme.md
CHANGED
|
@@ -6,4 +6,77 @@
|
|
|
6
6
|
|
|
7
7
|
### Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev eslint@^8 @1024pix/eslint-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Config `eslint.config.cjs`
|
|
14
|
+
|
|
15
|
+
```cjs
|
|
16
|
+
const pixEslintConfig = require('@1024pix/eslint-plugin/config');
|
|
17
|
+
|
|
18
|
+
module.exports = pixEslintConfig;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Note that this ESLint config is not ready to use with ESM.
|
|
22
|
+
|
|
23
|
+
### Add script for package.json
|
|
24
|
+
|
|
25
|
+
For example:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"scripts": {
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"lint:fix": "eslint . --fix"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Config VS Code auto fix
|
|
37
|
+
|
|
38
|
+
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and create `.vscode/settings.json`
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"prettier.enable": false,
|
|
43
|
+
"editor.formatOnSave": false,
|
|
44
|
+
"editor.codeActionsOnSave": {
|
|
45
|
+
"source.fixAll.eslint": true,
|
|
46
|
+
"source.organizeImports": false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## FAQ
|
|
52
|
+
|
|
53
|
+
### I prefer XXX...
|
|
54
|
+
|
|
55
|
+
Sure, you can override the rules in your `eslint.config.js` file.
|
|
56
|
+
|
|
57
|
+
```cjs
|
|
58
|
+
const pixEslintConfig = require('@1024pix/eslint-plugin/config');
|
|
59
|
+
|
|
60
|
+
module.exports = [
|
|
61
|
+
...eslintConfig,
|
|
62
|
+
{
|
|
63
|
+
rules: {
|
|
64
|
+
// your rules...
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or you can always fork this repo and make your own.
|
|
71
|
+
|
|
72
|
+
## Migration guide
|
|
73
|
+
|
|
74
|
+
### v1.2.0
|
|
75
|
+
|
|
76
|
+
Before v1.2.0, Pix Config was provided by the [@1024pix/eslint-config](https://github.com/1024pix/eslint-config) project.
|
|
77
|
+
|
|
78
|
+
After upgrading, you should migrate from the old `.eslintrc` files to the new `eslint.config.cjs` file format.
|
|
79
|
+
|
|
80
|
+
Take a look at the [official ESLint migration guide](https://eslint.org/docs/latest/use/configure/migration-guide). You can also take inspiration from [this Pix context example](https://github.com/1024pix/pix/pull/8995).
|
|
81
|
+
|
|
82
|
+
Once finished, `@1024pix/eslint-config` can safely be removed.
|