Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinkbuff/eslint-config
Thinkbuff's ESLint config preset
https://github.com/thinkbuff/eslint-config
Last synced: 3 months ago
JSON representation
Thinkbuff's ESLint config preset
- Host: GitHub
- URL: https://github.com/thinkbuff/eslint-config
- Owner: thinkbuff
- License: mit
- Created: 2024-03-13T08:09:59.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-08-28T01:22:35.000Z (5 months ago)
- Last Synced: 2024-10-27T22:59:46.615Z (3 months ago)
- Language: TypeScript
- Size: 320 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @thinkbuff/eslint-config
[![npm](https://img.shields.io/npm/v/@thinkbuff/eslint-config.svg)](https://www.npmjs.com/package/@thinkbuff/eslint-config)
[Thinkbuff](https://github.com/thinkbuff)'s ESLint config preset
> Thanks to [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and reference.
## Usage
- **Requires Node.js `>=18.18.0`.**
- **Requires ESLint `>=8.57.0`.**### Install
```bash
pnpm i -D eslint @thinkbuff/eslint-config
```### Create config file (`eslint.config.js`)
See the [ESLint docs](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new) for more information about extending config files.
#### ES Module (Recommended)
With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package.json` (recommended):
```js
// 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
```js
// 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:
```json
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
```## VS Code support
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
Add the following settings to your `.vscode/settings.json`:
```jsonc
{
// 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"
]
}
```## Maintainer
- [Eleven](https://github.com/eteplus)
## License
[MIT](./LICENSE) License © 2024-PRESENT [Thinkbuff](https://github.com/thinkbuff)