Skip to content

Commit

Permalink
chore: update eslint and babel config
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfield550 committed Apr 7, 2020
1 parent 0180f10 commit 74eebc7
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 57 deletions.
104 changes: 75 additions & 29 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,31 @@
"plugin:prettier/recommended"
],
"overrides": [
{
"files": [
"packages/**/test/**/*.test.js",
"packages/**/test/**/test.js"
],
"rules": {
"taro/no-stateless-component": "off",
"react/react-in-jsx-scope": "off",
"react/no-find-dom-node": "off",
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "Nerv"
}
]
}
},
{
"files": [
"packages/**/*.ts",
"packages/**/*.tsx"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"warnOnUnsupportedTypeScriptVersion": true
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
"plugin:react-hooks/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": [
Expand All @@ -52,7 +41,6 @@
],
"class-methods-use-this": "off",
"prefer-rest-params": "off",
"arrow-body-style": "warn",
"react/jsx-filename-extension": [
2,
{
Expand All @@ -63,34 +51,73 @@
".tsx"
]
}
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "React"
}
],
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
],
"camelcase": [
"error",
{
"allow": [
"^UNSAFE_"
]
}
]
},
"settings": {
"react": {
"version": "detect"
}
}
},
{
"files": [
"packages/taro-ui-docs/**/*.js",
"packages/taro-ui-docs/**/*.jsx"
"packages/**/*.js",
"packages/**/*.jsx"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2017,
"ecmaFeatures": {
"jsx": true
},
"babelOptions": {
"configFile": "./babel.config.json",
"rootMode": "upward"
}
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
"plugin:react-hooks/recommended"
],
"rules": {
"class-methods-use-this": "off",
"prefer-rest-params": "off",
"arrow-body-style": "warn",
"taro/custom-component-children": "off",
"react/jsx-filename-extension": [
2,
{
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
],
"no-unused-vars": [
"error",
{
Expand Down Expand Up @@ -131,6 +158,9 @@
"packages/taro-ui-docs"
]
}
},
"react": {
"version": "detect"
}
}
},
Expand All @@ -139,10 +169,26 @@
"packages/taro-ui-docs/build/*.js"
],
"rules": {
"import/no-commonjs": "off",
"no-console": "off",
"no-undefined": "off"
}
},
{
"files": [
"packages/**/test/**/*.test.js",
"packages/**/test/**/test.js"
],
"rules": {
"taro/no-stateless-component": "off",
"react/react-in-jsx-scope": "off",
"react/no-find-dom-node": "off",
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "Nerv"
}
]
}
}
]
}
26 changes: 5 additions & 21 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
{
"overrides": [
{
"include": "packages/taro-ui-demo/**",
"presets": [
[
"taro",
{
"framework": "react",
"ts": true
}
]
]
},
{
"include": "packages/taro-ui-docs/**",
"presets": [
Expand All @@ -31,19 +19,15 @@
},
"loose": false,
"forceAllTransforms": true,
"useBuiltIns": "entry"
"useBuiltIns": "entry",
"corejs": "3.6"
}
]
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "React.createElement"
}
]
"@babel/plugin-proposal-class-properties"
]
}
]
Expand Down
7 changes: 0 additions & 7 deletions packages/taro-ui-demo/.eslintrc.js

This file was deleted.

56 changes: 56 additions & 0 deletions packages/taro-ui-demo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"root": true,
"extends": [
"plugin:import/errors",
"plugin:import/warnings",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"taro/react"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx"
],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript"
],
"rules": {
"@typescript-eslint/no-explicit-any": [
"off"
],
"@typescript-eslint/member-delimiter-style": [
"off"
],
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
],
"camelcase": [
"error",
{
"allow": [
"^UNSAFE_"
]
}
]
}
},
{
"files": [
"./babel.config.js"
],
"rules": {
"import/no-commonjs": "off"
}
}
]
}
13 changes: 13 additions & 0 deletions packages/taro-ui-demo/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// babel-preset-taro 更多选项和默认值:
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
module.exports = {
presets: [
[
'taro',
{
framework: 'react',
ts: true
}
]
]
}

0 comments on commit 74eebc7

Please sign in to comment.