Shared ESLint configuration for TypeScript projects.
- Lints TypeScript based on the latest standards.
- Fixes issues and formatting errors with Prettier.
- Supports node and browser environments.
-
Install the package using npm:
npm install -D @mindevieras/eslint-config-mindevieras
-
Create a
.eslintrc
file in the root directory of your project (wherepackage.json
resides). Add the following content to the.eslintrc
file:{ "extends": [ "@mindevieras/eslint-config-mindevieras" ], // Or: "extends": [ "@mindevieras/eslint-config-mindevieras/react" ], }
-
Optionally, you can add scripts to your
package.json
file for linting and fixing:"scripts": { "lint": "eslint .", "lint:fix": "eslint . --fix" }
-
You can now manually lint your code by running
npm run lint
and fix fixable issues withnpm run lint:fix
. However, it's recommended to configure your editor to handle this automatically.
If you want to override ESLint or Prettier settings, you can add the corresponding rules to your .eslintrc
file. For ESLint rules, add them under the "rules"
key. You can refer to the ESLint rules documentation for more details.
Example .eslintrc
file:
{
"extends": ["@mindevieras/eslint-config-mindevieras"],
"rules": {
"no-console": 2,
}
}
-
Install the ESLint extension for Visual Studio Code.
-
Open the
.vscode/settings.json
file in your project and add the following settings:{ "editor.formatOnSave": true, "[javascript]": { "editor.formatOnSave": false, }, "editor.codeActionsOnSave": { "source.fixAll": true }, "editor.autoIndent": "full", "editor.insertSpaces": true, "editor.formatOnPaste": false, "editor.defaultFormatter": "dbaeumer.vscode-eslint", "editor.renderWhitespace": "boundary", "editor.wordWrap": "off", "editor.detectIndentation": true, "editor.rulers": [ 120 ], "files.exclude": { "**/.git": true, "**/.DS_Store": true }, }
-
Restart Visual Studio Code for the changes to take effect.
Note: The extension Prettier - Code formatter is not required as it is already integrated with the ESLint configuration.