A shared ESLint configuration with Chinese comments by mingelz.
一份带有完整中文注释的 ESLint 规则。请打开 rules 目录下的文件,阅读每个规则的详细说明。
npm install eslint-config-mingelz --save-dev
Add a .eslintrc.js
file with following content to your project root directory:
在项目根目录下新建 .eslingrc.js
文件,并写入下列内容:
module.exports = {
env: {
browser: true,
node: true,
},
extends: [
'mingelz',
],
}
NOTICE:
This configuration is dependent on eslint@^7.24,
please install it manually: npm install -D eslint
.
注意:
此配置依赖 eslint@^7.24,请先手动安装此依赖: npm install -D eslint
。
module.exports = {
env: {
browser: true,
node: true,
},
extends: [
'mingelz',
],
rules: {
// your special rules
// 你的需要补充的规则
},
}
NOTICE:
This configuration is dependent on eslint-plugin-vue@^7.9,
please install it manually: npm install -D eslint-plugin-vue
.
注意:
此配置依赖 eslint-plugin-vue@^7.9,请先手动安装此依赖: npm install -D eslint-plugin-vue
。
module.exports = {
// ...
extends: [
'mingelz',
// The configuration will detect Vue.js version of your project automatic.
// 此配置会自动检查你使用的 Vue.js 版本,并开启相应规则
'mingelz/rules/vue',
],
// ...
}
NOTICE:
This configuration is dependent on eslint-plugin-react@^7.23,
please install it manually: npm install -D eslint-plugin-react
注意:
此配置依赖 eslint-plugin-react@^7.23,请先手动安装此依赖: npm install -D eslint-plugin-react
。
module.exports = {
// ...
extends: [
'mingelz',
'mingelz/rules/react',
],
// ...
}
The ESLint built-in Node.js/CommonJS-specific rules are deprecating, use eslint-plugin-node instead.
ESLint 自带的 Node.js/CommonJS 规则已废弃,请使用 eslint-plugin-node 替代。
NOTICE:
This configuration is dependent on eslint-plugin-node@^11.1,
please install it manually: npm install -D eslint-plugin-node
注意:
此配置依赖 eslint-plugin-node@^11.1,请先手动安装此依赖: npm install -D eslint-plugin-node
。
module.exports = {
// ...
extends: [
'mingelz',
'mingelz/rules/node',
],
// ...
}
NOTICE:
This configuration is dependent on eslint-plugin-import@^2.23,
please install it manually: npm install -D eslint-plugin-import
注意:
此配置依赖 eslint-plugin-import@^2.23,请先手动安装此依赖: npm install -D eslint-plugin-import
。
If you are using Webpack resolve.alias,
it is recommended to install eslint-import-resolver-webpack via npm install -D eslint-import-resolver-webpack
,
and configure it according to the webpack configuration file.
如果你正在使用 Webpack 的 resolve.alias 能力,建议通过命令 npm install -D eslint-import-resolver-webpack
安装 eslint-import-resolver-webpack 插件,并参照下述代码正确配置你的 Webpack 配置文件路径。
module.exports = {
// ...
extends: [
'mingelz',
'mingelz/rules/es-module',
],
settings: {
'import/resolver': {
// webpack config example
// webpack 配置示例
webpack: {
config: './webpack.config.js',
},
},
},
// ...
}
The ESLint built-in JSDoc rules was deprecated, use eslint-plugin-jsdoc instead.
ESLint 自带的 JSDoc 规则已废弃,请使用 eslint-plugin-jsdoc 替代。
NOTICE:
This configuration is dependent on eslint-plugin-jsdoc@32.2,
please install it manually: npm install -D eslint-plugin-jsdoc
注意:
此配置依赖 eslint-plugin-jsdoc@^32.2,请先手动安装此依赖: npm install -D eslint-plugin-jsdoc
。
module.exports = {
// ...
extends: [
'mingelz',
'mingelz/rules/jsdoc',
],
// ...
}
NOTICE:
This configuration is dependent on eslint-plugin-jsx-a11y,
please install it manually: npm install -D eslint-plugin-jsx-a11y
注意:
此配置依赖 eslint-plugin-jsx-a11y,请先手动安装此依赖: npm install -D eslint-plugin-jsx-a11y
。
module.exports = {
// ...
extends: [
'mingelz',
'mingelz/rules/jsx-a11y',
],
// ...
}