Skip to content

Commit

Permalink
feat: turn off prefer-const in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 21, 2025
1 parent 4c2867b commit 12dd5b5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 0 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"source.organizeImports": "never"
},

"eslint.options": {
"flags": ["unstable_ts_config"]
},

"eslint.runtime": "node",

// Silent the stylistic rules in you IDE, but still auto fix them
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,11 @@ export default antfu({

### Editor Specific Disables

Some rules are disabled when inside ESLint IDE integrations, namely [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports) [`test/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
Some rules are disabled when inside ESLint IDE integrations, namely:

- [`prefer-const`](https://eslint.org/docs/rules/prefer-const)
- [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports)
- [`test/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)

This is to prevent unused imports from getting removed by the IDE during refactoring to get a better developer experience. Those rules will be applied when you run ESLint in the terminal or [Lint Staged](#lint-staged). If you don't want this behavior, you can disable them:

Expand Down
16 changes: 9 additions & 7 deletions src/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ export async function javascript(
allowUnboundThis: true,
},
],
'prefer-const': [
'error',
{
destructuring: 'all',
ignoreReadBeforeAssign: true,
},
],
'prefer-const': isInEditor
? 'off'
: [
'error',
{
destructuring: 'all',
ignoreReadBeforeAssign: true,
},
],
'prefer-exponentiation-operator': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
Expand Down
1 change: 0 additions & 1 deletion src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
yaml,
} from './configs'
import { formatters } from './configs/formatters'

import { regexp } from './configs/regexp'
import { interopDefault, isInEditorEnv } from './utils'

Expand Down

0 comments on commit 12dd5b5

Please # to comment.