-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add eslint-plugin-array-func package * Configure eslint-plugin-array-func * Add more ESLint plugins * Add glue-y flat config compat code for plugins * Configure more ESLint plugins * Configure sort-keys rule * Fix object key sorting in test files * Add and configure eslint-plugin-regexp package * Remove @eslint/eslintrc * Add @eslint/js package and update config, tests * Add and configure eslint-plugin-unicorn * Ditch JSDOC comments in this project * Add and configure sort-class-members plugin * Ignore coverage folder * Remove JSDOC-style comments * Remove (for now) eslint-plugin-import It's got some in-the-weeds issues with passing around data internally that makes the plugin incompatible with flat config: - import-js/eslint-plugin-import#2556 - import-js/eslint-plugin-import#2829
- Loading branch information
1 parent
004b1c4
commit 445f87c
Showing
14 changed files
with
943 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const plugin = require('eslint-plugin-array-func'); | ||
const { configs, rules } = plugin; | ||
|
||
module.exports = { | ||
configs: { | ||
'flat/all': { | ||
plugins: { 'array-func': plugin }, | ||
rules: { | ||
...configs.recommended.rules, | ||
...configs.all.rules | ||
} | ||
}, | ||
'flat/recommended': { | ||
plugins: { 'array-func': plugin }, | ||
rules: { | ||
...configs.recommended.rules | ||
} | ||
} | ||
}, | ||
rules | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const plugin = require('eslint-plugin-promise'); | ||
const { configs, rules } = plugin; | ||
|
||
module.exports = { | ||
configs: { | ||
'flat/recommended': { | ||
plugins: { promise: plugin }, | ||
rules: configs.recommended.rules | ||
} | ||
}, | ||
rules | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const plugin = require('eslint-plugin-regexp'); | ||
const { configs, rules } = plugin; | ||
|
||
module.exports = { | ||
configs: { | ||
'flat/all': { | ||
plugins: { regexp: plugin }, | ||
rules: configs.all.rules | ||
}, | ||
'flat/recommended': { | ||
plugins: { regexp: plugin }, | ||
rules: configs.recommended.rules | ||
} | ||
}, | ||
rules | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const plugin = require('eslint-plugin-sort-class-members'); | ||
const { configs, rules } = plugin; | ||
|
||
module.exports = { | ||
configs: { | ||
'flat/recommended': { | ||
plugins: { 'sort-class-members': plugin }, | ||
rules: configs.recommended.rules | ||
} | ||
}, | ||
rules | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const plugin = require('eslint-plugin-unicorn'); | ||
const { configs, rules } = plugin; | ||
|
||
module.exports = { | ||
configs: { | ||
'flat/all': { | ||
plugins: { unicorn: plugin }, | ||
rules: configs.all.rules | ||
}, | ||
'flat/recommended': { | ||
plugins: { unicorn: plugin }, | ||
rules: configs.recommended.rules | ||
} | ||
}, | ||
rules | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports.arrayFunc = require('./eslint-plugin-array-func'); | ||
module.exports.promise = require('./eslint-plugin-promise'); | ||
module.exports.regexp = require('./eslint-plugin-regexp'); | ||
module.exports.sortClassMembers = require('./eslint-plugin-sort-class-members'); | ||
module.exports.unicorn = require('./eslint-plugin-unicorn'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,88 @@ | ||
const { FlatCompat } = require('@eslint/eslintrc'); | ||
// ESLint shared configurations | ||
const js = require('@eslint/js'); | ||
const standard = require('eslint-config-standard'); | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname | ||
}); | ||
// ESLint plugins | ||
const jsdoc = require('eslint-plugin-jsdoc'); | ||
const n = require('eslint-plugin-n'); | ||
|
||
// Compat module for non-"flat"-compatible plugins | ||
const compat = require('./compat'); | ||
|
||
module.exports = [ | ||
/** | ||
* eslint-config-standard doesn't (yet) provide a "flat" ESLint configuration. | ||
* Until an updated version is released, use `FlatCompat` to provide a "flat"- | ||
* compatible configuration object. | ||
* | ||
* @see {@link https://www.npmjs.com/package/eslint-config-standard} | ||
*/ | ||
...compat.config((() => { | ||
const { plugins, rules } = require('eslint-config-standard'); | ||
|
||
return { | ||
extends: [ | ||
'plugin:import/recommended', | ||
'plugin:n/recommended', | ||
'plugin:promise/recommended' | ||
], | ||
plugins, | ||
rules | ||
}; | ||
})()), | ||
|
||
/** | ||
* Additional configuration to suite my taste. | ||
*/ | ||
// https://www.npmjs.com/package/eslint-plugin-jsdoc | ||
jsdoc.configs['flat/recommended-error'], | ||
|
||
// https://www.npmjs.com/package/eslint-plugin-n | ||
n.configs['flat/recommended'], | ||
|
||
// https://www.npmjs.com/package/eslint-plugin-array-func | ||
compat.arrayFunc.configs['flat/all'], | ||
|
||
// https://www.npmjs.com/package/eslint-plugin-promise | ||
compat.promise.configs['flat/recommended'], | ||
|
||
// https://www.npmjs.com/package/eslint-plugin-regexp | ||
compat.regexp.configs['flat/recommended'], | ||
|
||
// https://www.npmjs.com/package/eslint-plugin-sort-class-members | ||
compat.sortClassMembers.configs['flat/recommended'], | ||
|
||
// https://www.npmjs.com/package/eslint-plugin-unicorn | ||
compat.unicorn.configs['flat/recommended'], | ||
|
||
{ | ||
rules: { | ||
/** | ||
* Enforces consistent use of semicolons. | ||
* | ||
* @see {@link https://eslint.org/docs/latest/rules/semi} | ||
*/ | ||
// https://www.npmjs.com/package/@eslint/js | ||
...js.configs.recommended.rules, | ||
|
||
// https://www.npmjs.com/package/eslint-config-standard | ||
// | ||
// Remove eslint-plugin-import rules until the following "flat" config- | ||
// related issues are resolved. | ||
// | ||
// https://github.com/import-js/eslint-plugin-import/issues/2556 | ||
// https://github.com/import-js/eslint-plugin-import/pull/2829 | ||
...Object.fromEntries( | ||
Object.entries(standard.rules).filter(([key]) => { | ||
return !key.startsWith('import/'); | ||
}) | ||
), | ||
|
||
// https://eslint.org/docs/latest/rules/semi | ||
semi: ['error', 'always'], | ||
|
||
/** | ||
* Enforces consistent spacing before function parentheses and will warn | ||
* whenever whitespace doesn't match the preferences specified. | ||
* | ||
* @see {@link https://eslint.org/docs/latest/rules/space-before-function-paren} | ||
*/ | ||
// https://eslint.org/docs/latest/rules/sort-keys | ||
'sort-keys': ['error', 'asc', { | ||
allowLineSeparatedGroups: true, | ||
natural: true | ||
}], | ||
|
||
// https://eslint.org/docs/latest/rules/space-before-function-paren | ||
'space-before-function-paren': ['error', { | ||
anonymous: 'never', | ||
asyncArrow: 'always', | ||
named: 'never' | ||
}] | ||
}], | ||
|
||
// Disable rules conflicting with eslint-plugin-unicorn. | ||
// | ||
// https://www.npmjs.com/package/eslint-plugin-array-func | ||
'array-func/prefer-flat': 'off', | ||
'array-func/prefer-flat-map': 'off', | ||
|
||
// https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/tag-lines.md | ||
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }], | ||
|
||
// ¯\_(ツ)_/¯ | ||
// | ||
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/no-null.md} | ||
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-module.md} | ||
'unicorn/no-null': 'off', | ||
'unicorn/prefer-module': 'off', | ||
|
||
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prevent-abbreviations.md | ||
'unicorn/prevent-abbreviations': ['warn', { checkFilenames: false }] | ||
} | ||
} | ||
]; |
Oops, something went wrong.