@w5s/eslint-config 1.0.0-alpha.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/README.md +85 -0
- package/es.js +23 -0
- package/functional.js +51 -0
- package/index.js +19 -0
- package/jest.js +4 -0
- package/json.js +8 -0
- package/package.json +79 -0
- package/react.js +10 -0
- package/rules/_rule.js +15 -0
- package/rules/base.js +464 -0
- package/rules/import.js +118 -0
- package/rules/jest.js +46 -0
- package/rules/jsdoc.js +20 -0
- package/rules/node.js +21 -0
- package/rules/prettier.js +16 -0
- package/rules/react.js +176 -0
- package/rules/typescript.js +132 -0
- package/rules/unicorn.js +58 -0
- package/ts.js +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=# W5s ESLint configuration _(${name})_) -->
|
|
2
|
+
# W5s ESLint configuration _(@w5s/eslint-config)_
|
|
3
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
4
|
+
|
|
5
|
+
[![NPM Version][package-version-svg]][package-url]
|
|
6
|
+
[![License][license-image]][license-url]
|
|
7
|
+
|
|
8
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=> ${description}&unknownTxt= ) -->
|
|
9
|
+
> ESLint configuration presets
|
|
10
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=```console\nnpm install --save-dev ${name}\n```) -->
|
|
15
|
+
```console
|
|
16
|
+
npm install --save-dev @w5s/eslint-config
|
|
17
|
+
```
|
|
18
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Default JS/TS project
|
|
23
|
+
|
|
24
|
+
For most kind of project, just edit `eslintrc.json` and add default configuration
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
{
|
|
28
|
+
"extends": [
|
|
29
|
+
"@w5s/eslint-config"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Features :**
|
|
35
|
+
|
|
36
|
+
- `ES` and `TS` validation
|
|
37
|
+
- `Prettier` formatting
|
|
38
|
+
- `JSX` and `React` syntax validation
|
|
39
|
+
- `Jest` tests
|
|
40
|
+
|
|
41
|
+
### Custom project
|
|
42
|
+
|
|
43
|
+
For most kind of project, just edit `eslintrc.json` and cherry pick only configurations
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
{
|
|
47
|
+
"root": true,
|
|
48
|
+
"extends": [
|
|
49
|
+
"@w5s/eslint-config/es",
|
|
50
|
+
"@w5s/eslint-config/functional",
|
|
51
|
+
"@w5s/eslint-config/jest",
|
|
52
|
+
"@w5s/eslint-config/json",
|
|
53
|
+
"@w5s/eslint-config/react",
|
|
54
|
+
"@w5s/eslint-config/ts",
|
|
55
|
+
// include more configurations here
|
|
56
|
+
]
|
|
57
|
+
//...
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Available configurations :**
|
|
62
|
+
|
|
63
|
+
- `@w5s/eslint-config/es`: for ECMA Script (ES) files
|
|
64
|
+
- `@w5s/eslint-config/jest`: for jest environment tests
|
|
65
|
+
- `@w5s/eslint-config/functional`: for pure functional programming
|
|
66
|
+
- `@w5s/eslint-config/react`: for react capability
|
|
67
|
+
- `@w5s/eslint-config/ts`: for typescript files
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[${license}][license-url] © ${author}) -->
|
|
71
|
+
[MIT][license-url] © Julien Polo <julien.polo@gmail.com>
|
|
72
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
73
|
+
|
|
74
|
+
<!-- VARIABLES -->
|
|
75
|
+
|
|
76
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square) -->
|
|
77
|
+
[package-version-svg]: https://img.shields.io/npm/v/@w5s/eslint-config.svg?style=flat-square
|
|
78
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
79
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}) -->
|
|
80
|
+
[package-url]: https://www.npmjs.com/package/@w5s/eslint-config
|
|
81
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
82
|
+
<!-- AUTO-GENERATED-CONTENT:START (PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square) -->
|
|
83
|
+
[license-image]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
|
|
84
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
85
|
+
[license-url]: ../../LICENSE
|
package/es.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// http://eslint.org/docs/user-guide/configuring
|
|
2
|
+
module.exports = {
|
|
3
|
+
extends: [
|
|
4
|
+
require.resolve('./rules/base'),
|
|
5
|
+
require.resolve('./rules/jsdoc'),
|
|
6
|
+
require.resolve('./rules/import'),
|
|
7
|
+
require.resolve('./rules/unicorn'),
|
|
8
|
+
'prettier',
|
|
9
|
+
require.resolve('./rules/prettier'),
|
|
10
|
+
],
|
|
11
|
+
parser: '@babel/eslint-parser',
|
|
12
|
+
parserOptions: {
|
|
13
|
+
babelOptions: {
|
|
14
|
+
plugins: ['@babel/plugin-syntax-class-properties', '@babel/plugin-syntax-jsx'],
|
|
15
|
+
},
|
|
16
|
+
ecmaFeatures: {
|
|
17
|
+
jsx: true,
|
|
18
|
+
},
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
requireConfigFile: false,
|
|
21
|
+
sourceType: 'module',
|
|
22
|
+
},
|
|
23
|
+
};
|
package/functional.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @see https://github.com/danielnixon/eslint-config-typed-fp/blob/master/src/index.ts
|
|
2
|
+
|
|
3
|
+
const { off, error } = require('./rules/_rule');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
extends: ['plugin:functional/recommended', 'plugin:total-functions/recommended'],
|
|
9
|
+
files: [
|
|
10
|
+
'src/**/!(*.spec|*.ispec).ts',
|
|
11
|
+
// 'src/**/!(*.spec).js'
|
|
12
|
+
],
|
|
13
|
+
rules: {
|
|
14
|
+
'functional/functional-parameters': [
|
|
15
|
+
error,
|
|
16
|
+
{
|
|
17
|
+
allowArgumentsKeyword: false,
|
|
18
|
+
allowRestParameter: false,
|
|
19
|
+
enforceParameterCount: false,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
'functional/no-conditional-statement': off,
|
|
24
|
+
'functional/no-method-signature': off,
|
|
25
|
+
'functional/prefer-readonly-type': [
|
|
26
|
+
// @see https://github.com/jonaskello/eslint-plugin-functional/issues/51
|
|
27
|
+
off, // error
|
|
28
|
+
{
|
|
29
|
+
// When you call methods like `filter` and `concat` on an array (_even a readonly_ array) you always get back a mutable array.
|
|
30
|
+
// By default prefer-readonly-type won't catch these cases, but with the checkImplicit option on it will.
|
|
31
|
+
// See https://github.com/jonaskello/eslint-plugin-functional/blob/master/docs/rules/prefer-readonly-type.md#checkimplicit
|
|
32
|
+
// @see also https://github.com/danielnixon/readonly-types/issues/7
|
|
33
|
+
// @see https://github.com/jonaskello/eslint-plugin-functional/issues/153
|
|
34
|
+
checkImplicit: true,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
'functional/prefer-type-literal': off,
|
|
38
|
+
'total-functions/no-unsafe-readonly-mutable-assignment': [
|
|
39
|
+
// @see https://github.com/danielnixon/eslint-plugin-total-functions/issues?q=is%3Aissue+is%3Aopen+no-unsafe-readonly-mutable-assignment
|
|
40
|
+
off,
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
'total-functions/no-unsafe-type-assertion': [
|
|
44
|
+
// Don't need this given consistent-type-assertions bans type assertions entirely.,
|
|
45
|
+
off,
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
plugins: ['functional', 'total-functions'],
|
|
51
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// http://eslint.org/docs/user-guide/configuring
|
|
2
|
+
module.exports = {
|
|
3
|
+
extends: [require.resolve('./es'), require.resolve('./react'), require.resolve('./json')],
|
|
4
|
+
overrides: [
|
|
5
|
+
{
|
|
6
|
+
extends: [require.resolve('./ts')],
|
|
7
|
+
files: ['*.+(ts|tsx)'],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
extends: [require.resolve('./jest')],
|
|
11
|
+
files: [
|
|
12
|
+
'**/__mocks__/**/*.+(ts|tsx|js|jsx)',
|
|
13
|
+
'**/__tests__/**/*.+(ts|tsx|js|jsx)',
|
|
14
|
+
'**/?(*.)+(spec|test).+(ts|tsx|js|jsx)',
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
root: true,
|
|
19
|
+
};
|
package/jest.js
ADDED
package/json.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@w5s/eslint-config",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"description": "ESLint configuration presets",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint",
|
|
7
|
+
"config",
|
|
8
|
+
"lint"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/w5s/project-config/blob/master/packages/eslint-config#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/w5s/project-config.git/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/w5s/project-config.git",
|
|
17
|
+
"directory": "packages/eslint-config"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Julien Polo <julien.polo@gmail.com>",
|
|
21
|
+
"main": "index.js",
|
|
22
|
+
"files": [
|
|
23
|
+
"*.js",
|
|
24
|
+
"rules/*.js"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm-run-all -p 'build:*'",
|
|
28
|
+
"build:empty": ":",
|
|
29
|
+
"docs": "md-magic --path '**/*.md' --ignore='node_modules'",
|
|
30
|
+
"format": "eslint . --fix",
|
|
31
|
+
"lint": "eslint .",
|
|
32
|
+
"test": "scripts/test"
|
|
33
|
+
},
|
|
34
|
+
"eslintConfig": {
|
|
35
|
+
"rules": {
|
|
36
|
+
"sort-keys-fix/sort-keys-fix": "error"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"eslintIgnore": [
|
|
40
|
+
"__tests__"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@babel/eslint-parser": "^7.0.0",
|
|
44
|
+
"@babel/plugin-syntax-class-properties": "^7.0.0",
|
|
45
|
+
"@babel/plugin-syntax-jsx": "^7.0.0",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
47
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
48
|
+
"eslint-config-prettier": "^8.0.0",
|
|
49
|
+
"eslint-plugin-functional": "^4.2.0",
|
|
50
|
+
"eslint-plugin-import": "^2.25.0",
|
|
51
|
+
"eslint-plugin-jest": "^26.0.0",
|
|
52
|
+
"eslint-plugin-jsdoc": "^37.0.0",
|
|
53
|
+
"eslint-plugin-json-format": "^2.0.1",
|
|
54
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
55
|
+
"eslint-plugin-react": "^7.28.0",
|
|
56
|
+
"eslint-plugin-total-functions": "^5.0.0",
|
|
57
|
+
"eslint-plugin-unicorn": "^40.0.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@babel/eslint-parser": "7.17.0",
|
|
61
|
+
"@types/eslint": "8.4.1",
|
|
62
|
+
"@types/eslint-plugin-prettier": "^3.1.0",
|
|
63
|
+
"@types/prettier": "2.4.4",
|
|
64
|
+
"@types/react": "17.0.2",
|
|
65
|
+
"@typescript-eslint/parser": "5.10.2",
|
|
66
|
+
"eslint": "8.8.0",
|
|
67
|
+
"eslint-config-prettier": "8.3.0",
|
|
68
|
+
"eslint-index": "1.5.0",
|
|
69
|
+
"prettier": "2.5.1",
|
|
70
|
+
"react": "17.0.2"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"eslint": "5.x || 6.x || 7.x || 8.x",
|
|
74
|
+
"prettier": "2.x"
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
}
|
|
79
|
+
}
|
package/react.js
ADDED
package/rules/_rule.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @type {'error'} */
|
|
2
|
+
const error = 'error';
|
|
3
|
+
|
|
4
|
+
/** @type {'warn'} */
|
|
5
|
+
const warn = 'warn';
|
|
6
|
+
|
|
7
|
+
/** @type {'off'} */
|
|
8
|
+
const off = 'off';
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
error,
|
|
12
|
+
fixme: (/** @type {'off'|'warn'|'error'} */ _status) => off,
|
|
13
|
+
off,
|
|
14
|
+
warn,
|
|
15
|
+
};
|