const path = require('path'); module.exports = { parser: 'babel-eslint', // JavaScript 语言解析选项 parserOptions: { // ECMAScript 版本 ecmaVersion: 6, sourceType: 'module', // 额外的语言特性: ecmaFeatures: { experimentalDecorators: true, experimentalObjectRestSpread: true, jsx: true, }, }, extends: [ 'plugin:import/errors', 'plugin:import/warnings', 'plugin:react/recommended', 'plugin:prettier/recommended', 'prettier/react', 'prettier/standard', ], plugins: ['babel', 'import', 'flowtype', 'jsx-a11y', 'react', 'redux-saga', 'prettier'], settings: { react: { version: '16.0', }, 'import/resolver': { webpack: { config: path.resolve(__dirname, './config/webpack.config.js'), }, }, }, globals: { _: true, }, // 预定义的全局变量。 env: { browser: true, commonjs: true, es6: true, node: true, }, // 以当前目录为根目录,不再向上查找 root: true, rules: { 'babel/new-cap': 0, 'arrow-body-style': [2, 'as-needed'], 'max-len': 0, 'no-plusplus': 0, 'no-console': 1, 'no-unused-vars': 'warn', 'no-script-url': 0, 'import/first': 0, 'no-underscore-dangle': 0, 'global-require': 0, 'prettier/prettier': 'error', 'import/imports-first': 0, 'import/no-dynamic-require': 0, 'import/extensions': 0, 'import/no-unresolved': [ 0, { commonjs: true, amd: true, }, ], 'import/named': 0, 'import/prefer-default-export': 0, 'redux-saga/no-yield-in-race': 2, 'redux-saga/yield-effects': 2, 'react/require-default-props': 0, 'react/forbid-prop-types': 0, 'jsx-a11y/aria-props': 2, 'jsx-a11y/heading-has-content': 0, 'jsx-a11y/label-has-for': 2, 'jsx-a11y/mouse-events-have-key-events': 2, 'jsx-a11y/role-has-required-aria-props': 2, 'jsx-a11y/role-supports-aria-props': 2, 'jsx-a11y/media-has-caption': 0, 'jsx-a11y/anchor-is-valid': [ 0, { components: ['Link'], specialLink: ['to'], aspects: ['noHref', 'preferButton'], }, ], // 'react/jsx-first-prop-new-line': [2, 'multiline'], // 设置jsx允许的文件扩展名 'react/jsx-filename-extension': [ 1, { extensions: ['.js', '.jsx'], }, ], 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 'prettier/prettier': [ 'error', { endOfLine: 'auto', }, ], }, };