Browse Source

use umi config

pull/4336/head
陈帅 7 years ago
parent
commit
970ff57e90
  1. 72
      .eslintrc.js
  2. 4
      package.json

72
.eslintrc.js

@ -1,76 +1,8 @@
const eslintConfig = require('umi-lint/config/.eslintrc.js');
module.exports = {
extends: [
'airbnb',
'prettier',
'plugin:compat/recommended',
'airbnb-typescript',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-comments/recommended',
'plugin:jest/recommended',
'plugin:promise/recommended',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
env: {
browser: true,
node: true,
es6: true,
mocha: true,
jest: true,
jasmine: true,
},
...eslintConfig,
globals: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
page: true,
},
rules: {
'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
'react/jsx-wrap-multilines': 0,
'react/prop-types': 0,
'react/forbid-prop-types': 0,
'react/jsx-one-expression-per-line': 0,
'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }],
'import/no-extraneous-dependencies': [
2,
{
optionalDependencies: true,
devDependencies: ['**/tests/**.js', '/mock/**/**.js', '**/**.test.js'],
},
],
'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/anchor-is-valid': 0,
'linebreak-style': 0,
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'off',
'import/prefer-default-export': 'off',
'import/no-default-export': [true, 'camel-case'],
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': 'off',
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
'react/jsx-filename-extension': 'off',
// Use function hoisting to improve code readability
'no-use-before-define': ['error', { functions: false, classes: true, variables: true }],
// Makes no sense to allow type inferrence for expression parameters, but require typing the response
'@typescript-eslint/explicit-function-return-type': [
'off',
{ allowTypedFunctionExpressions: true },
],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true, typedefs: true },
],
// Common abbreviations are known and readable
'unicorn/prevent-abbreviations': 'off',
'@typescript-eslint/explicit-member-accessibility': 0,
'import/no-cycle': 0,
},
plugins: ['@typescript-eslint', 'eslint-comments', 'jest', 'promise', 'unicorn'],
settings: {
// support import modules from TypeScript files in JavaScript files
'import/resolver': { node: { extensions: ['.js', '.ts', '.tsx'] } },
polyfills: ['fetch', 'Promise', 'URL', 'object-assign'],
},
};

4
package.json

@ -122,7 +122,6 @@
"import-sort-style-module": "^6.0.0",
"jest-puppeteer": "^4.2.0",
"jsdom-global": "^3.0.2",
"less": "^3.9.0",
"lint-staged": "^8.1.7",
"mockjs": "^1.0.1-beta3",
"netlify-lambda": "^1.4.13",
@ -137,6 +136,7 @@
"stylelint-config-standard": "^18.3.0",
"stylelint-declaration-block-no-ignored-properties": "^2.1.0",
"stylelint-order": "^3.0.0",
"umi-lint": "^2.0.1",
"webpack-theme-color-replacer": "^1.1.5"
},
"optionalDependencies": {
@ -180,4 +180,4 @@
"create-umi"
]
}
}
}

Loading…
Cancel
Save