Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add clarification on stylistic overrides and Svelte overrides #446

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export default antfu({
stylistic: {
indent: 2, // 4, or 'tab'
quotes: 'single', // or 'double'
overrides: {
'style/brace-style': ['error', '1tbs', { allowSingleLine: true }],
},
},

// TypeScript and Vue are auto-detected, you can also explicitly enable them:
Expand Down Expand Up @@ -457,6 +460,29 @@ export default antfu({
})
```

To control which rules apply to your Svelte files, you can apply overrides like this:

```js
// eslint.config.js
import { antfu } from '@antfu/eslint-config'

export default antfu({
svelte: true,
}).overrides({
'antfu/svelte/rules': {
rules: {
'svelte/no-dom-manipulating': 'error',
},
},
'antfu/typescript/rules': {
files: ['**/*.svelte'],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break support for other ts files. I guess it's better to append a separate config that overrides that rule for only **/*.svelte but not other ts files.

Copy link
Author

@jacob-8 jacob-8 Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be slow. Why would that break support? It only adds **/*.svelte to the already existing files array. It's working great for me in multiple projects.

rules: {
'prefer-destructuring': 'error',
},
},
})
```

Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:

```bash
Expand Down