2.0.0 • Published 3 years ago
@raidorev/eslint-config v2.0.0
My ESLint configuration for TypeScript/Vue projects
This is my personal ESLint configuration for TypeScript/Vue projects. It uses quite a few plugins and have pretty strict rules.
Installation
npm install --save-dev eslint prettier typescript @raidorev/eslint-config
yarn add --save-dev eslint prettier typescript @raidorev/eslint-config
pnpm add --save-dev eslint prettier typescript @raidorev/eslint-config
Usage
In this configuration, the parserOptions.project is set to ./tsconfig.eslint.json
to allow typescript-eslint to work with TypeScript's type checking APIs. Here's an example of what this file might look like:
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"vite.config.ts",
".eslintrc.cjs",
"stylelint.config.cjs"
]
}
Once you have created this file, you can extend the configuration in your ESLint config file like this:
module.exports = {
extends: ["@raidorev"],
};
Plugins
This configuration uses the following plugins:
- typescript-eslint: Provides additional rules specific to TypeScript, as well as the ability to use TypeScript's type checking APIs.
- eslint-plugin-vue: Supports linting for Vue.js code.
- eslint-plugin-prettier with eslint-config-prettier: Prettier integration.
- eslint-plugin-import: Rules for import/export usage. My favorite rule is 'import/order', which enforces a consistent order for imports. I use the following order: builtin, external, internal, parent, sibling, index, object, type, unknown.
@/**
alias is marked as internal import. - eslint-plugin-promise: Provides rules for working with Promises.
- eslint-plugin-regexp: Provides rules for working with regular expressions.
- eslint-plugin-sonarjs: Provides additional rules for code quality and maintainability, based on the SonarQube project.
- eslint-plugin-unicorn: More rules for code quality and maintainability.