diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..45f9c06 --- /dev/null +++ b/.babelrc @@ -0,0 +1,9 @@ +{ + "presets": ["@babel/preset-react"], + "plugins": ["@babel/plugin-proposal-class-properties", + ["@babel/plugin-proposal-decorators", + { + "legacy": true + }] + ] +} diff --git a/README.md b/README.md index 9fd42a6..5554f74 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm version](https://badge.fury.io/js/eslint-config-za.svg)](https://www.npmjs.com/package/eslint-config-za) -众安 **ESLint** 规则 +众安 **ESLint** 规则 基于[airbnb](https://github.com/airbnb/javascript)的 ESLint 规则,进行二次定制。 @@ -11,7 +11,7 @@ ### JavaScrip ``` -npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-config-za +npm install --save-dev eslint @babel/eslint-parser eslint-plugin-babel eslint-plugin-import eslint-config-za ``` ```json @@ -25,7 +25,7 @@ npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-imp ### React ``` -npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y eslint-config-za +npm install --save-dev eslint @babel/eslint-parser eslint-plugin-babel eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y eslint-config-za ``` ```json @@ -39,7 +39,7 @@ npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-imp ### Vue ``` -npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-plugin-vue eslint-config-za +npm install --save-dev eslint @babel/eslint-parser eslint-plugin-babel eslint-plugin-import eslint-plugin-vue eslint-config-za ``` ```json @@ -82,7 +82,7 @@ VSCode 的 ESLint 插件默认并不支持 `vue` `ts` `tsx`,需要自行修改 ## 提示 -**eslint-config-za** 定义了相应的 `peerDependencies`。因此选择不同规则时需要自行安装对应的依赖。具体参考[使用](#使用)说明。 +**eslint-config-za** 定义了相应的 `peerDependencies`。因此选择不同规则时需要自行安装对应的依赖。具体参考[使用](#使用)说明。 ``` npm info "eslint-config-za@latest" peerDependencies @@ -94,9 +94,9 @@ npx install-peerdeps --dev eslint-config-za > npx eslint --print-config .eslintrc > /path/you/file ## 规则链接 -[eslint](https://github.com/eslint/eslint/tree/master/docs/rules) -[import](https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules) -[jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules) -[react](https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules) -[react-hooks](https://reactjs.org/docs/hooks-rules.html) -[typescript](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules) \ No newline at end of file +[eslint](https://github.com/eslint/eslint/tree/master/docs/rules) +[import](https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules) +[jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules) +[react](https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules) +[react-hooks](https://reactjs.org/docs/hooks-rules.html) +[typescript](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules) diff --git a/index.js b/index.js index 0fd753f..98f12cd 100644 --- a/index.js +++ b/index.js @@ -5,5 +5,5 @@ module.exports = { './rules/es', './rules/import', ].map(require.resolve), - parser: 'babel-eslint', + parser: '@babel/eslint-parser', }; diff --git a/package.json b/package.json index cb6bd4d..5da3ab0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-za", - "version": "2.3.1", + "version": "2.3.2", "description": "ZhongAn's ESLint config", "main": "index.js", "config": { @@ -33,9 +33,12 @@ "eslint-config-airbnb": "^18.2.0" }, "devDependencies": { + "@babel/eslint-parser": "^7.12.1", + "@babel/plugin-proposal-class-properties": "^7.12.1", + "@babel/plugin-proposal-decorators": "^7.12.12", + "@babel/preset-react": "^7.12.10", "@typescript-eslint/eslint-plugin": "^4.9.0", "@typescript-eslint/parser": "^4.9.0", - "babel-eslint": "^10.0.1", "conventional-changelog-cli": "^2.0.25", "eslint": "^7.2.0", "eslint-plugin-babel": "^5.3.0", @@ -51,7 +54,10 @@ "peerDependencies": { "@typescript-eslint/eslint-plugin": "^4.9.0", "@typescript-eslint/parser": "^4.9.0", - "babel-eslint": "^10.0.1", + "@babel/eslint-parser": "^7.12.1", + "@babel/plugin-proposal-class-properties": "^7.12.1", + "@babel/plugin-proposal-decorators": "^7.12.12", + "@babel/preset-react": "^7.12.10", "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0", "eslint-plugin-babel": "^5.3.0", "eslint-plugin-import": "^2.22.1", diff --git a/react.js b/react.js index 49376b9..7773759 100644 --- a/react.js +++ b/react.js @@ -7,5 +7,5 @@ module.exports = { './rules/jsx-a11y', './rules/react', ].map(require.resolve), - parser: 'babel-eslint', + parser: '@babel/eslint-parser', }; diff --git a/vue.js b/vue.js index a8c916a..b83b5c5 100644 --- a/vue.js +++ b/vue.js @@ -8,6 +8,6 @@ module.exports = { ].map(require.resolve), parser: 'vue-eslint-parser', parserOptions: { - parser: 'babel-eslint', + parser: '@babel/eslint-parser', }, };