@jgarber/eslint-config 1.1.1 → 3.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.
- package/README.md +27 -14
- package/lib/ava.js +22 -0
- package/lib/commonjs.js +29 -0
- package/lib/compat/eslint-plugin-array-func.js +21 -0
- package/lib/compat/eslint-plugin-promise.js +12 -0
- package/lib/compat/eslint-plugin-regexp.js +16 -0
- package/lib/compat/eslint-plugin-sort-class-members.js +12 -0
- package/lib/compat/eslint-plugin-unicorn.js +16 -0
- package/lib/compat/index.js +5 -0
- package/lib/index.js +100 -0
- package/package.json +33 -13
- package/index.js +0 -59
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# eslint-config
|
|
2
2
|
|
|
3
|
-
Shareable [ESLint](https://eslint.org)
|
|
3
|
+
Shareable [ESLint](https://eslint.org) configurations.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@jgarber/eslint-config)
|
|
6
|
+
[](https://www.npmjs.com/package/@jgarber/eslint-config)
|
|
7
|
+
[](https://github.com/jgarber623/eslint-config/actions/workflows/ci.yml)
|
|
4
8
|
|
|
5
9
|
> [!IMPORTANT]\
|
|
6
|
-
>
|
|
10
|
+
> These shareable configurations use ESLint's new "flat" configuration file format, which may not be suitable for every project. See [the official documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new) for details.
|
|
7
11
|
|
|
8
12
|
## Installation
|
|
9
13
|
|
|
@@ -13,26 +17,35 @@ npm install --save-dev @jgarber/eslint-config
|
|
|
13
17
|
|
|
14
18
|
## Usage
|
|
15
19
|
|
|
16
|
-
Using [
|
|
20
|
+
Using [ECMAScript module (ESM)](https://nodejs.org/api/esm.html) syntax:
|
|
17
21
|
|
|
18
22
|
```js
|
|
19
23
|
// eslint.config.js
|
|
20
|
-
|
|
24
|
+
import config from '@jgarber/eslint-config';
|
|
25
|
+
|
|
26
|
+
export default config;
|
|
21
27
|
```
|
|
22
28
|
|
|
23
|
-
Using [
|
|
29
|
+
Using [CommonJS module](https://nodejs.org/api/modules.html) syntax:
|
|
24
30
|
|
|
25
31
|
```js
|
|
26
32
|
// eslint.config.js
|
|
27
|
-
|
|
33
|
+
const config = require('@jgarber/eslint-config');
|
|
34
|
+
const commonjs = require('@jgarber/eslint-config/commonjs');
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
files: ['**/*.js'],
|
|
33
|
-
languageOptions: {
|
|
34
|
-
sourceType: 'module'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
36
|
+
module.exports = [
|
|
37
|
+
...commonjs,
|
|
38
|
+
...config
|
|
37
39
|
];
|
|
38
40
|
```
|
|
41
|
+
|
|
42
|
+
### Additional Configurations
|
|
43
|
+
|
|
44
|
+
This package exports several other configurations that may be useful in conjunction with the main configuration (or, by themselves!):
|
|
45
|
+
|
|
46
|
+
- `@jgarber/eslint-config/commonjs`: configures `languageOptions` and `globals` for CommonJS modules (especially useful if your `*.js` files target Node.js environments)
|
|
47
|
+
- `@jgarber/eslint-config/ava`: configures linting for tests written using the [AVA](https://www.npmjs.com/package/ava) test framework
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
Ths package is freely available under the [MIT License](https://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.
|
package/lib/ava.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const ava = require('eslint-plugin-ava');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
// Use AVA's default file-matching patterns.
|
|
6
|
+
//
|
|
7
|
+
// https://github.com/avajs/ava/blob/HEAD/docs/05-command-line.md
|
|
8
|
+
files: [
|
|
9
|
+
'test.js',
|
|
10
|
+
'src/test.js',
|
|
11
|
+
'source/test.js',
|
|
12
|
+
'**/test-*.js',
|
|
13
|
+
'**/*.spec.js',
|
|
14
|
+
'**/*.test.js',
|
|
15
|
+
'**/test/**/*.js',
|
|
16
|
+
'**/tests/**/*.js',
|
|
17
|
+
'**/__tests__/**/*.js'
|
|
18
|
+
],
|
|
19
|
+
plugins: { ava },
|
|
20
|
+
rules: ava.configs.recommended.rules
|
|
21
|
+
}
|
|
22
|
+
];
|
package/lib/commonjs.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// By default, ESLint's "flat" config considers `*.js` files to be ECMAScript
|
|
2
|
+
// modules (ESM). `*.mjs` files are always parsed as ESM modules and `*.cjs`
|
|
3
|
+
// files are always parsed as CommonJS modules.
|
|
4
|
+
//
|
|
5
|
+
// This configures ESLint to treat `*.js` files as CommonJS modules.
|
|
6
|
+
//
|
|
7
|
+
// Authors may also specify the module type in `package.json` using either
|
|
8
|
+
// `"type": "commonjs"` or `"type": "module"`.
|
|
9
|
+
//
|
|
10
|
+
// https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects
|
|
11
|
+
// https://nodejs.org/dist/latest-v18.x/docs/api/modules.html#enabling
|
|
12
|
+
module.exports = [
|
|
13
|
+
{
|
|
14
|
+
files: ['**/*.js'],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
// https://www.npmjs.com/package/globals
|
|
17
|
+
// https://github.com/sindresorhus/globals/blob/HEAD/globals.json
|
|
18
|
+
globals: {
|
|
19
|
+
__dirname: 'readonly',
|
|
20
|
+
__filename: 'readonly',
|
|
21
|
+
exports: 'writable',
|
|
22
|
+
global: 'readonly',
|
|
23
|
+
module: 'readonly',
|
|
24
|
+
require: 'readonly'
|
|
25
|
+
},
|
|
26
|
+
sourceType: 'commonjs'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const plugin = require('eslint-plugin-array-func');
|
|
2
|
+
const { configs, rules } = plugin;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
configs: {
|
|
6
|
+
'flat/all': {
|
|
7
|
+
plugins: { 'array-func': plugin },
|
|
8
|
+
rules: {
|
|
9
|
+
...configs.recommended.rules,
|
|
10
|
+
...configs.all.rules
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
'flat/recommended': {
|
|
14
|
+
plugins: { 'array-func': plugin },
|
|
15
|
+
rules: {
|
|
16
|
+
...configs.recommended.rules
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
rules
|
|
21
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const plugin = require('eslint-plugin-regexp');
|
|
2
|
+
const { configs, rules } = plugin;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
configs: {
|
|
6
|
+
'flat/all': {
|
|
7
|
+
plugins: { regexp: plugin },
|
|
8
|
+
rules: configs.all.rules
|
|
9
|
+
},
|
|
10
|
+
'flat/recommended': {
|
|
11
|
+
plugins: { regexp: plugin },
|
|
12
|
+
rules: configs.recommended.rules
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
rules
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const plugin = require('eslint-plugin-sort-class-members');
|
|
2
|
+
const { configs, rules } = plugin;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
configs: {
|
|
6
|
+
'flat/recommended': {
|
|
7
|
+
plugins: { 'sort-class-members': plugin },
|
|
8
|
+
rules: configs.recommended.rules
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
rules
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const plugin = require('eslint-plugin-unicorn');
|
|
2
|
+
const { configs, rules } = plugin;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
configs: {
|
|
6
|
+
'flat/all': {
|
|
7
|
+
plugins: { unicorn: plugin },
|
|
8
|
+
rules: configs.all.rules
|
|
9
|
+
},
|
|
10
|
+
'flat/recommended': {
|
|
11
|
+
plugins: { unicorn: plugin },
|
|
12
|
+
rules: configs.recommended.rules
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
rules
|
|
16
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
module.exports.arrayFunc = require('./eslint-plugin-array-func');
|
|
2
|
+
module.exports.promise = require('./eslint-plugin-promise');
|
|
3
|
+
module.exports.regexp = require('./eslint-plugin-regexp');
|
|
4
|
+
module.exports.sortClassMembers = require('./eslint-plugin-sort-class-members');
|
|
5
|
+
module.exports.unicorn = require('./eslint-plugin-unicorn');
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// ESLint shared configurations
|
|
2
|
+
const js = require('@eslint/js');
|
|
3
|
+
const standard = require('eslint-config-standard');
|
|
4
|
+
|
|
5
|
+
// ESLint plugins
|
|
6
|
+
const jsdoc = require('eslint-plugin-jsdoc');
|
|
7
|
+
const n = require('eslint-plugin-n');
|
|
8
|
+
|
|
9
|
+
// Compat module for non-"flat"-compatible plugins
|
|
10
|
+
const compat = require('./compat');
|
|
11
|
+
|
|
12
|
+
module.exports = [
|
|
13
|
+
// https://www.npmjs.com/package/eslint-plugin-jsdoc
|
|
14
|
+
jsdoc.configs['flat/recommended'],
|
|
15
|
+
|
|
16
|
+
// https://www.npmjs.com/package/eslint-plugin-n
|
|
17
|
+
n.configs['flat/recommended'],
|
|
18
|
+
|
|
19
|
+
// https://www.npmjs.com/package/eslint-plugin-array-func
|
|
20
|
+
compat.arrayFunc.configs['flat/all'],
|
|
21
|
+
|
|
22
|
+
// https://www.npmjs.com/package/eslint-plugin-promise
|
|
23
|
+
compat.promise.configs['flat/recommended'],
|
|
24
|
+
|
|
25
|
+
// https://www.npmjs.com/package/eslint-plugin-regexp
|
|
26
|
+
compat.regexp.configs['flat/recommended'],
|
|
27
|
+
|
|
28
|
+
// https://www.npmjs.com/package/eslint-plugin-sort-class-members
|
|
29
|
+
compat.sortClassMembers.configs['flat/recommended'],
|
|
30
|
+
|
|
31
|
+
// https://www.npmjs.com/package/eslint-plugin-unicorn
|
|
32
|
+
compat.unicorn.configs['flat/recommended'],
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
rules: {
|
|
36
|
+
// https://www.npmjs.com/package/@eslint/js
|
|
37
|
+
...js.configs.recommended.rules,
|
|
38
|
+
|
|
39
|
+
// https://www.npmjs.com/package/eslint-config-standard
|
|
40
|
+
//
|
|
41
|
+
// Remove eslint-plugin-import rules until the following "flat" config-
|
|
42
|
+
// related issues are resolved.
|
|
43
|
+
//
|
|
44
|
+
// https://github.com/import-js/eslint-plugin-import/issues/2556
|
|
45
|
+
// https://github.com/import-js/eslint-plugin-import/pull/2829
|
|
46
|
+
...Object.fromEntries(
|
|
47
|
+
Object.entries(standard.rules).filter(([key]) => {
|
|
48
|
+
return !key.startsWith('import/');
|
|
49
|
+
})
|
|
50
|
+
),
|
|
51
|
+
|
|
52
|
+
// https://eslint.org/docs/latest/rules/semi
|
|
53
|
+
semi: ['error', 'always'],
|
|
54
|
+
|
|
55
|
+
// https://eslint.org/docs/latest/rules/sort-imports
|
|
56
|
+
'sort-imports': ['error', { allowSeparatedGroups: true }],
|
|
57
|
+
|
|
58
|
+
// https://eslint.org/docs/latest/rules/sort-keys
|
|
59
|
+
'sort-keys': ['error', 'asc', {
|
|
60
|
+
allowLineSeparatedGroups: true,
|
|
61
|
+
caseSensitive: false,
|
|
62
|
+
natural: true
|
|
63
|
+
}],
|
|
64
|
+
|
|
65
|
+
// https://eslint.org/docs/latest/rules/space-before-function-paren
|
|
66
|
+
'space-before-function-paren': ['error', {
|
|
67
|
+
anonymous: 'never',
|
|
68
|
+
asyncArrow: 'always',
|
|
69
|
+
named: 'never'
|
|
70
|
+
}],
|
|
71
|
+
|
|
72
|
+
// https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/tag-lines.md
|
|
73
|
+
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
|
|
74
|
+
|
|
75
|
+
// ¯\_(ツ)_/¯
|
|
76
|
+
//
|
|
77
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
|
78
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/no-null.md
|
|
79
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-module.md
|
|
80
|
+
'unicorn/filename-case': 'off',
|
|
81
|
+
'unicorn/no-null': 'off',
|
|
82
|
+
'unicorn/prefer-module': 'off',
|
|
83
|
+
|
|
84
|
+
// Disable rules conflicting with eslint-plugin-array-func.
|
|
85
|
+
//
|
|
86
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
|
|
87
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
|
|
88
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-spread.md
|
|
89
|
+
'unicorn/prefer-array-flat': 'off',
|
|
90
|
+
'unicorn/prefer-array-flat-map': 'off',
|
|
91
|
+
'unicorn/prefer-spread': 'off',
|
|
92
|
+
|
|
93
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prevent-abbreviations.md
|
|
94
|
+
'unicorn/prevent-abbreviations': ['warn', { checkFilenames: false }],
|
|
95
|
+
|
|
96
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-top-level-await.md
|
|
97
|
+
'unicorn/prefer-top-level-await': 'warn'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
];
|
package/package.json
CHANGED
|
@@ -1,36 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jgarber/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Shareable ESLint configuration.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"config",
|
|
7
|
+
"configuration",
|
|
8
|
+
"eslint-config",
|
|
6
9
|
"eslint",
|
|
7
10
|
"eslintconfig",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
11
|
+
"javascript",
|
|
12
|
+
"lint"
|
|
10
13
|
],
|
|
11
14
|
"homepage": "https://github.com/jgarber623/eslint-config",
|
|
12
15
|
"bugs": "https://github.com/jgarber623/eslint-config/issues",
|
|
13
16
|
"license": "MIT",
|
|
14
17
|
"author": "Jason Garber <jason@sixtwothree.org> (https://sixtwothree.org)",
|
|
15
|
-
"
|
|
18
|
+
"files": [
|
|
19
|
+
"lib/*"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
".": "./lib/index.js",
|
|
24
|
+
"./ava": "./lib/ava.js",
|
|
25
|
+
"./commonjs": "./lib/commonjs.js"
|
|
26
|
+
},
|
|
16
27
|
"repository": "github:jgarber623/eslint-config",
|
|
17
28
|
"scripts": {
|
|
18
29
|
"lint": "eslint .",
|
|
19
|
-
"test": "
|
|
30
|
+
"test": "c8 ava"
|
|
20
31
|
},
|
|
21
32
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
33
|
+
"node": ">=18.0.0"
|
|
23
34
|
},
|
|
24
|
-
"
|
|
25
|
-
"eslint": "^8.
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@eslint/js": "^8.51.0",
|
|
26
37
|
"eslint-config-standard": "^17.1.0",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
38
|
+
"eslint-plugin-ava": "^14.0.0",
|
|
39
|
+
"eslint-plugin-array-func": "^4.0.0",
|
|
40
|
+
"eslint-plugin-jsdoc": "^46.8.2",
|
|
41
|
+
"eslint-plugin-n": "^16.2.0",
|
|
42
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
43
|
+
"eslint-plugin-regexp": "^1.15.0",
|
|
44
|
+
"eslint-plugin-sort-class-members": "^1.19.0",
|
|
45
|
+
"eslint-plugin-unicorn": "^48.0.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"ava": "^5.3.1",
|
|
49
|
+
"c8": "^8.0.1",
|
|
50
|
+
"eslint": "^8.51.0"
|
|
29
51
|
},
|
|
30
52
|
"peerDependencies": {
|
|
31
|
-
"eslint": ">=8.
|
|
32
|
-
"eslint-config-standard": ">=17.1",
|
|
33
|
-
"globals": ">=13.20"
|
|
53
|
+
"eslint": ">=8.51.0"
|
|
34
54
|
},
|
|
35
55
|
"publishConfig": {
|
|
36
56
|
"access": "public"
|
package/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Import global identifiers from different JavaScript environments.
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://www.npmjs.com/package/globals}
|
|
5
|
-
* @see {@link https://github.com/sindresorhus/globals/blob/HEAD/globals.json}
|
|
6
|
-
*/
|
|
7
|
-
const globals = require('globals');
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* Import Standard's ESLint configurtation for use with ESLint's new "flat"
|
|
11
|
-
* configuration file format.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json}
|
|
14
|
-
* @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new}
|
|
15
|
-
*/
|
|
16
|
-
const standard = require('eslint-config-standard');
|
|
17
|
-
|
|
18
|
-
module.exports = [
|
|
19
|
-
{
|
|
20
|
-
plugins: Object.fromEntries(standard.plugins.map(plugin => [plugin, require(`eslint-plugin-${plugin}`)])),
|
|
21
|
-
rules: {
|
|
22
|
-
...standard.rules,
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
* Enforces consistent use of semicolons.
|
|
26
|
-
*
|
|
27
|
-
* @see {@link https://eslint.org/docs/latest/rules/semi}
|
|
28
|
-
*/
|
|
29
|
-
semi: ['error', 'always'],
|
|
30
|
-
|
|
31
|
-
/*
|
|
32
|
-
* Enforces consistent spacing before function parentheses and will warn
|
|
33
|
-
* whenever whitespace doesn't match the preferences specified.
|
|
34
|
-
*
|
|
35
|
-
* @see {@link https://eslint.org/docs/latest/rules/space-before-function-paren}
|
|
36
|
-
*/
|
|
37
|
-
'space-before-function-paren': ['error', {
|
|
38
|
-
anonymous: 'never',
|
|
39
|
-
asyncArrow: 'always',
|
|
40
|
-
named: 'never'
|
|
41
|
-
}]
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
/*
|
|
46
|
-
* By default, ESLint's "flat" config considers `*.js` files as ECMAScript
|
|
47
|
-
* modules (ESM). Instead, consider `*.js` files to be CommonJS modules.
|
|
48
|
-
*
|
|
49
|
-
* @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects}
|
|
50
|
-
*/
|
|
51
|
-
files: ['**/*.js'],
|
|
52
|
-
languageOptions: {
|
|
53
|
-
globals: {
|
|
54
|
-
...globals.commonjs
|
|
55
|
-
},
|
|
56
|
-
sourceType: 'commonjs'
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
];
|