Prettier
- 安装 Prettier - Code formatter 插件
- 本地配置 .prettierrc
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": true,
"semi": false,
"singleQuote": true,
"printWidth": 100
}
Eslint
./node_modules/.bin/eslint --init
module.exports = {
env: {
browser: true,
es6: true,
},
extends: ['plugin:react/recommended'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
parser: 'babel-eslint',
plugins: ['react'],
rules: {
indent: 0,
'linebreak-style': ['error', 'windows'],
quotes: ['error', 'single'],
semi: ['error', 'never'],
'no-console': 0,
'react/prop-types': 0,
},
}
补充:在vscode中使用装饰器会报错
- 解决方式,在本地增加配置文件 jsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true
}
}