Closed heming6666 closed 4 years ago
If we develop the project with TypeScript, should we use ESLint
or TSLint
? Although I realize that lots of Typescript project are using ESLint
.
I think both are good for our projerct. But ESLint
is recommended because the team behind TSLint
have decided that they would no longer support it. Refer to https://palantir.github.io/tslint/
We use umi-fabric
which provides some presets for eslint
, stylelint
and prettier
. All open rules are meaningful for improving code quality.
Here's the ESLint
configuration:
# .eslintrc.js
module.exports = {
extends: [require.resolve('@umijs/fabric/dist/eslint')],
};
# .prettierrc.js
const fabric = require('@umijs/fabric');
module.exports = {
...fabric.prettier,
};
In addition, use Husky
to do the lint check before commit:
"scripts": {
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**.{js,jsx,tsx,ts,less,md,json}\" --end-of-line auto",
"prettier": "prettier --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
},
Close by pr #21 .
In order to keep the code style in a good shape and format the code automatically, it's recommend to use
ESLint
andPrettier
in our project.