-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: 1.0 for eslint 9 - migrate to stylistic rules
- breaking: `@stylistic/eslint-plugin` rules migration following this guide https://eslint.style/guide/migration - remove dependency `eslint-config-standard`, all rules imported (replace deprecated rules) - bump `eslint-plugin-import` and restore rule 'import/export' ref import-js/eslint-plugin-import#2556 - disable rule 'import/no-webpack-loader-syntax' - edit rules for 'generator-star-spacing' and 'yield-star-spacing'
- Loading branch information
梁伟然
committed
Oct 17, 2024
1 parent
425b77f
commit db23b54
Showing
12 changed files
with
422 additions
and
143 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,31 +1,23 @@ | ||
/** | ||
* Copyright (c) 2023 Coremail.cn, Ltd. All Rights Reserved. | ||
* Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. | ||
*/ | ||
|
||
import {error} from './util.js'; | ||
|
||
export default { | ||
|
||
languageOptions : { | ||
ecmaVersion : 3, | ||
sourceType : 'script', | ||
parserOptions : {allowReserved : true}, | ||
}, | ||
|
||
rules : { | ||
/* eslint-disable indent *//* @formatter:off */ | ||
plugins : {'@stylistic' : (await import('@stylistic/eslint-plugin')).default}, | ||
|
||
// here two rules are only for ES3 compliant / IE6 supports | ||
'quote-props' : [error, 'as-needed', { | ||
keywords : true, | ||
unnecessary : false, | ||
}], | ||
'dot-notation' : [error, { | ||
allowKeywords : false, | ||
allowPattern : '.*', | ||
}], | ||
'comma-dangle' : [error, 'never'], | ||
// ES3 compliant END | ||
'no-tabs' : [error], | ||
// rules only for ES3 compliant / IE6 ~ IE8 | ||
rules : { | ||
'dot-notation' : [error, {allowKeywords : false, allowPattern : '.*'}], | ||
'@stylistic/quote-props' : [error, 'as-needed', {keywords : true, unnecessary : false}], | ||
'@stylistic/comma-dangle' : [error, 'never'], | ||
'@stylistic/no-tabs' : [error], | ||
}, | ||
}; |
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,85 +1,77 @@ | ||
/** | ||
* Copyright (c) 2023 Coremail.cn, Ltd. All Rights Reserved. | ||
* Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. | ||
*/ | ||
|
||
import standard from 'eslint-config-standard'; | ||
import {baseRules, plugins, styleRules} from './imported.js'; | ||
import {error, first, mergeRules, never, off} from './util.js'; | ||
|
||
export default { | ||
|
||
languageOptions : { | ||
ecmaVersion : 'latest', | ||
parserOptions : {ecmaFeatures : {jsx : true}}, | ||
}, | ||
|
||
plugins : Object.fromEntries(await Promise.all(standard.plugins.map(async key => [ | ||
key, (await import(`eslint-plugin-${key}`)).default, | ||
]))), | ||
plugins, | ||
rules : mergeRules(baseRules, styleRules, { /* eslint-disable @stylistic/indent */// @formatter:off | ||
'no-var' : [error], | ||
'@stylistic/no-tabs' : [error], | ||
'@stylistic/indent' : [error, 4, { | ||
SwitchCase : 0, | ||
VariableDeclarator : {var : 1, let : 1, const : 1}, | ||
ImportDeclaration : first, | ||
ArrayExpression : first, | ||
ObjectExpression : first, | ||
FunctionDeclaration : {parameters: first}, | ||
FunctionExpression : {parameters: first}, | ||
CallExpression : {arguments: 1}, | ||
MemberExpression : off, | ||
ignoreComments : true, | ||
ignoredNodes : styleRules['@stylistic/indent'][2].ignoredNodes, | ||
}], | ||
'@stylistic/semi' : [off], | ||
'@stylistic/quotes' : [error, 'single', 'avoid-escape'], | ||
'@stylistic/arrow-parens' : [error, 'as-needed'], | ||
'@stylistic/operator-linebreak' : [error, 'before'], // ternary operator should have nothing special | ||
'@stylistic/comma-dangle' : [error, { // more friendly to VCS system / manual code arrangements | ||
arrays : 'always-multiline', | ||
objects : 'always-multiline', | ||
imports : 'always-multiline', | ||
exports : 'always-multiline', | ||
functions : 'only-multiline', | ||
}], | ||
'@stylistic/padded-blocks' : [off], // extra space in blocks should not be a problem | ||
'prefer-const' : [off], | ||
'yoda' : [off], | ||
'no-new' : [off], | ||
'no-void' : [off], | ||
'no-case-declarations' : [off], | ||
'no-inner-declarations' : [off], | ||
'default-case' : [off], | ||
'one-var' : [off], | ||
'dot-notation' : [off], | ||
'@stylistic/quote-props' : [off], | ||
'@stylistic/object-curly-spacing' : [off], | ||
'@stylistic/space-before-function-paren' : [error, {named: 'never', anonymous: 'ignore', asyncArrow: 'always'}], | ||
'@stylistic/no-multiple-empty-lines' : [off], | ||
'@stylistic/no-multi-spaces' : [error, { | ||
exceptions: {VariableDeclarator: true, ImportDeclaration: true}, | ||
ignoreEOLComments: true, | ||
}], | ||
'@stylistic/key-spacing' : [off], | ||
'camelcase' : [error, { | ||
properties : never, | ||
ignoreDestructuring : true, | ||
ignoreGlobals : true, | ||
}], | ||
'@stylistic/multiline-ternary' : [off], | ||
'array-callback-return' : [off], | ||
'no-empty' : [off], | ||
'n/no-path-concat' : [off], | ||
'n/no-exports-assign' : [off], | ||
|
||
/* eslint-disable indent */// @formatter:off | ||
rules : mergeRules(standard.rules, { | ||
'no-var' : [error], | ||
'no-tabs' : [error], | ||
'indent' : [error, 4, { | ||
SwitchCase : 0, | ||
VariableDeclarator : { var : 1, let : 1, const : 1 }, | ||
ImportDeclaration : first, | ||
ArrayExpression : first, | ||
ObjectExpression : first, | ||
FunctionDeclaration : {parameters: first}, | ||
FunctionExpression : {parameters: first}, | ||
CallExpression : {arguments: 1}, | ||
MemberExpression : off, | ||
ignoreComments : true, | ||
}], | ||
'semi' : [off, never], | ||
'quotes' : [error, 'single', 'avoid-escape'], | ||
'arrow-parens' : [error, 'as-needed'], | ||
'operator-linebreak' : [error, 'before'], // corrected now, ternary operator should have nothing special | ||
'comma-dangle' : [error, { // more friendly to VCS system / manual code arrangements | ||
arrays : 'always-multiline', | ||
objects : 'always-multiline', | ||
imports : 'always-multiline', | ||
exports : 'always-multiline', | ||
functions : 'only-multiline', | ||
}], | ||
'padded-blocks' : [off], // extra space in blocks should not be a problem | ||
'prefer-const' : [off], | ||
'yoda' : [off], | ||
'no-new' : [off], | ||
'no-void' : [off], | ||
'no-case-declarations' : [off], | ||
'no-inner-declarations' : [off], | ||
'default-case' : [off], | ||
'one-var' : [off], | ||
'dot-notation' : [off], | ||
'quote-props' : [off], | ||
'object-curly-spacing' : [off], | ||
'space-before-function-paren' : [error, {named: never, anonymous: 'ignore', asyncArrow: 'always'}], | ||
'space-before-blocks' : [error], | ||
'no-multiple-empty-lines' : [off], | ||
'no-multi-spaces' : [error, { | ||
exceptions: {VariableDeclarator: true, ImportDeclaration: true}, | ||
ignoreEOLComments: true, | ||
}], | ||
'keyword-spacing' : [error], | ||
'key-spacing' : [off], | ||
'comma-spacing' : [error], | ||
'space-infix-ops' : [error], | ||
'spaced-comment' : [error], | ||
'eol-last' : [error], | ||
'camelcase' : [error, { | ||
properties : never, | ||
ignoreDestructuring : true, | ||
ignoreGlobals : true, | ||
}], | ||
'multiline-ternary' : [off], | ||
'array-callback-return' : [off], | ||
'no-empty' : [off], | ||
'n/no-path-concat' : [off], | ||
'n/no-exports-assign' : [off], | ||
'@stylistic/generator-star-spacing' : [error, 'after'], | ||
'@stylistic/yield-star-spacing' : [error, 'after'], | ||
|
||
// waiting https://github.com/import-js/eslint-plugin-import/issues/2556 | ||
'import/export' : [off], | ||
'import/no-webpack-loader-syntax' : [off], | ||
}), | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name" : "eslint-config-coremail", | ||
"description" : "Javascript Standard Style - ESLint Shareable Config for coremail.cn", | ||
"version" : "0.99.1", | ||
"version" : "1.0.0", | ||
"author" : { | ||
"name" : "William Leung", | ||
"email" : "[email protected]" | ||
|
@@ -24,6 +24,10 @@ | |
|
||
"license" : "MIT", | ||
"main" : "config/index.js", | ||
"exports" : { | ||
"." : "./config/index.js", | ||
"./package.json" : "./package.json" | ||
}, | ||
"files" : [ | ||
"config/*" | ||
], | ||
|
@@ -33,15 +37,18 @@ | |
}, | ||
|
||
"peerDependencies" : { | ||
"eslint" : "^8.52.0", | ||
"eslint" : "^9.12.0", | ||
"globals" : "*" | ||
}, | ||
|
||
"devDependencies" : { | ||
"eslint" : "~8.52.0" | ||
"eslint" : "~9.12.0" | ||
}, | ||
|
||
"dependencies" : { | ||
"eslint-config-standard" : "~17.1.0" | ||
"eslint-plugin-import" : "^2.31.0", | ||
"eslint-plugin-n" : "^17.11.1", | ||
"eslint-plugin-promise" : "^7.1.0", | ||
"@stylistic/eslint-plugin" : "~2.9.0" | ||
} | ||
} |
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,4 @@ | ||
// | ||
|
||
export const one = 1; | ||
export const two = 2; |
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,3 @@ | ||
// | ||
|
||
export * from './esm1.js' |
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,9 +1,8 @@ | ||
// | ||
// The indent rule do not supports '1.5' as unit (6 space) or other multiline alignment technic | ||
/* eslint indent: "off" */ | ||
// The indent rule does not support '1.5' as unit (6 space) or other multiline alignment technic | ||
/* eslint @stylistic/indent: "off" */ | ||
|
||
// noinspection JSUnusedGlobalSymbols | ||
const A = 'a', | ||
B = 'b', | ||
C = 'c'; | ||
|
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
Oops, something went wrong.