@vinicius1313/eslint-config
v2.3.0
Published
Eslint configuration (includes linting and formatting for JS and TS)
Maintainers
Readme
@vinicius1313/eslint-config
ESLint config I use in my projects.
It supports linting and formatting JavaScript and TypeScript files.
Installation
[!NOTE] This library requires
eslint,@eslint/jsand@stylistic/eslint-plugin. If you use TypeScript, it also requirestypescriptandtypescript-eslint.
[!WARNING] When using TypeScript, be aware of version compatibility! This is due to
typescript-eslint's version compatibility. The configuration may not work if you use an incompatible version.
Install the dependencies with:
NPM
npm install -D @vinicius1313/eslint-config @eslint/js @stylistic/eslint-plugin eslint typescript typescript-eslintPNPM
pnpm add -D @vinicius1313/eslint-config @eslint/js @stylistic/eslint-plugin eslint typescript typescript-eslintYarn
yarn add -D @vinicius1313/eslint-config @eslint/js @stylistic/eslint-plugin eslint typescript typescript-eslint
Version compatibility
| Library version | ESLint version | ESLint Config | TypeScript version | Previous documentation |
|-----------------|----------------|---------------|--------------------|------------------------|
>= 2.1.0 | >= 9 | Flat | >=4.8.4 <6.0.0 | -
>= 2.0.0 | >= 9 | Flat | >=4.8.4 <5.8.0 | -
>= 1.0.0 <=1.2.2 | < 9 | Legacy | ? | See v1 documentation
Usage example
Create a file called eslint.config.mjs at the root of your project and add the following content to it:
import { configs } from '@vinicius1313/eslint-config'
/** @type {import('eslint').Linter.Config[]} */
export default [
...configs.recommended,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
},
]Or, if you want to add other config:
import { configs } from '@vinicius1313/eslint-config'
/** @type {import('eslint').Linter.Config[]} */
export default [
...configs.recommended,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
},
{
// Your ESLint config
},
]Configs
recommendedThis config is the recommended. It includes
formatting,javascriptandtypescriptconfigs.formattingThis config enables formatting rules for JavaScript and TypeScript files.
javascriptThis config enables linting rules for JavaScript and TypeScript files. It does not lint TypeScript syntax, it lints JavaScript syntax written in TypeScript files. To enable linting TypeScript syntax, use
typescriptconfig.typescriptThis config enables linting rules for TypeScript syntax.
Troubleshooting
<file> was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject.If some file can't be lint due to the error above, its probably because the file is not in the
includelist of yourtsconfig.json.To fix this, you can just add the file path to the
includefield of yourtsconfig.jsonor add the following config to youreslint.config.mjs:import { configs } from '@vinicius1313/eslint-config' /** @type {import('eslint').Linter.Config[]} */ export default [ ...configs.recommended, { languageOptions: { parserOptions: { tsconfigRootDir: import.meta.dirname, projectService: { allowDefaultProject: [ // Other files to enable linting ], }, }, }, }, ]
