0.0.5 • Published 4 years ago
@appenin/eslint-config v0.0.5
@appenin/eslint-config
Appenin's ESLint config with TypeScript and React support
Setup
1) Install
yarn add -D @appenin/eslint-configFor the backend, add:
yarn add -D eslint@7.32.0 typescript @typescript-eslint/parser eslint-config-prettier prettier eslint-config-standard eslint-plugin-chai-friendly eslint-plugin-import eslint-plugin-simple-import-sort eslint-plugin-mocha eslint-plugin-node eslint-plugin-prettier eslint-plugin-promise eslint-plugin-standardFor the frontend, add:
yarn add -D eslint@7.32.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin prettier eslint-config-prettier eslint-plugin-prettier eslint-config-next2) Configure ESLint
Add "extends": ["@appenin/eslint-config"] to your ESLint config file.
If you need React support, add "extends": ["@appenin/eslint-config/next"] instead.
This config requires knowledge of your TypeScript config.
In your ESLint config, set parserOptions.project to the path of your tsconfig.json.
An example .eslintrc:
{
"extends": ["@appenin/eslint-config/next"]
}3) Run ESLint
Open a terminal to the root of your project, and run the following command:
npx eslint . --ext .js,.jsx,.ts,.tsxESLint will lint all .js, .jsx, .ts, and .tsx files within the current folder, and output results to your terminal.
You can also get results in realtime inside most IDEs via a plugin.
4) Fix on save Eslint errors
JetBrains IDE (WebStorm, Intellij)
- JetBrains IDE already provide Eslint plugins.
- You just need to do to
Preferences > Languages & Framework > Eslintand checkrun eslint --fix on save
VS Code
- Install EsLint plugins for VS Code
- Go to
Preferences > edit settings.json - Paste the following code:
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}