@thinkbuff/eslint-config
v0.2.2
Published
Thinkbuff's ESLint config preset
Downloads
9
Readme
@thinkbuff/eslint-config
Thinkbuff's ESLint config preset
Thanks to antfu/eslint-config for the inspiration and reference.
Usage
- Requires Node.js
>=18.18.0
. - Requires ESLint
>=8.57.0
.
Install
pnpm i -D eslint @thinkbuff/eslint-config
Create config file (eslint.config.js
)
See the ESLint docs for more information about extending config files.
ES Module (Recommended)
With "type": "module"
in package.json
(recommended):
// eslint.config.js
import { defineFlatConfigAsync } from '@thinkbuff/eslint-config'
import { FlatCompat } from '@eslint/eslintrc';
const compat = new FlatCompat();
export default defineFlatConfigAsync({
astro: true,
unocss: true,
// Additional ESlint Flat Config
extends: [
{
files: ['src/**/*.ts'],
rules: {
'perfectionist/sort-objects': 'error',
},
},
// Legacy config
...compat.config({
extends: [
'eslint:recommended',
// Other extends...
],
}),
]
}
CommonJS
// eslint.config.js
const { defineFlatConfigAsync } = require('@thinkbuff/eslint-config')
const { FlatCompat } = require('@eslint/eslintrc')
const compat = new FlatCompat()
module.exports = defineFlatConfigAsync({
astro: true,
unocss: true,
// Additional ESlint Flat Config
extends: [
{
files: ['src/**/*.ts'],
rules: {
'perfectionist/sort-objects': 'error',
},
},
// Legacy config
...compat.config({
extends: [
'eslint:recommended',
// Other extends...
],
}),
]
})
Add script for package.json
For example:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
VS Code support
Install VS Code ESLint extension
Add the following settings to your .vscode/settings.json
:
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
// Enable eslint for supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"astro"
]
}