71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
module.exports = {
|
|
extends: ['taro/react'],
|
|
parser: '@typescript-eslint/parser',
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
jsx: true
|
|
},
|
|
useJSXTextNode: true,
|
|
project: './tsconfig.json'
|
|
},
|
|
plugins: [
|
|
'@typescript-eslint',
|
|
'react',
|
|
'react-hooks'
|
|
],
|
|
rules: {
|
|
// TypeScript 相关规则
|
|
'@typescript-eslint/no-unused-vars': ['error', {
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_'
|
|
}],
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
'@typescript-eslint/no-empty-function': 'warn',
|
|
|
|
// React 相关规则
|
|
'react/jsx-uses-react': 'off',
|
|
'react/react-in-jsx-scope': 'off',
|
|
'react/prop-types': 'off',
|
|
'react-hooks/rules-of-hooks': 'error',
|
|
'react-hooks/exhaustive-deps': 'warn',
|
|
|
|
// 通用规则
|
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'no-unused-vars': 'off', // 使用 TypeScript 版本
|
|
'prefer-const': 'error',
|
|
'no-var': 'error',
|
|
|
|
// 代码风格
|
|
'indent': ['error', 2],
|
|
'quotes': ['error', 'single'],
|
|
'semi': ['error', 'always'],
|
|
'comma-dangle': ['error', 'never'],
|
|
'object-curly-spacing': ['error', 'always'],
|
|
'array-bracket-spacing': ['error', 'never'],
|
|
|
|
// Taro 特定规则
|
|
'taro/this-props-function': 'error',
|
|
'taro/no-stateless-component': 'off',
|
|
'taro/jsx-handler-names': 'off'
|
|
},
|
|
env: {
|
|
browser: true,
|
|
es6: true,
|
|
node: true
|
|
},
|
|
settings: {
|
|
react: {
|
|
version: 'detect'
|
|
}
|
|
},
|
|
ignorePatterns: [
|
|
'dist/',
|
|
'node_modules/',
|
|
'*.config.js',
|
|
'*.config.ts'
|
|
]
|
|
};
|