Skip to content

Commit 22856e0

Browse files
amondnetclaude
andcommitted
feat(eslint-config): enable lessOpinionated with top-level-function
- Set `lessOpinionated: true` to use `curly: ['error', 'all']` instead of antfu's brace-omitting style - Re-enable `antfu/top-level-function` for function declarations - Add explicit `Linter.Config` type annotation in package-json.ts to fix build error from jsonc-eslint-parser reference - Update README FAQ and defaults table Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 96da507 commit 22856e0

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

packages/eslint-config/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This config wraps `@antfu/eslint-config` with the following defaults:
2424
| Semicolons | No |
2525
| TypeScript | Enabled |
2626
| Gitignore | Enabled |
27+
| `lessOpinionated` | `true` — disables `antfu/if-newline` and `antfu/curly`, enables `curly: ['error', 'all']` |
28+
| `antfu/top-level-function` | Re-enabled — prefer `function` declarations at top level |
2729

2830
Additionally, `test/prefer-lowercase-title` is disabled.
2931

@@ -376,6 +378,35 @@ This config inherits `@antfu/eslint-config`'s plugin renaming for a consistent D
376378
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
377379
| `test/*` | `vitest/*` | [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest) |
378380

381+
## FAQ
382+
383+
### Prettier?
384+
385+
This config uses ESLint for both linting and formatting, so Prettier is not needed. See [Why I don't use Prettier](https://antfu.me/posts/why-not-prettier) by Anthony Fu.
386+
387+
If you need to format files that ESLint cannot handle yet (`.css`, `.html`, etc.), use the [formatters](#formatters) option instead.
388+
389+
### How to format CSS?
390+
391+
You can opt-in to the [`formatters`](#formatters) feature to format your CSS. Note that it only does formatting, not linting. If you want proper linting support, give [`stylelint`](https://stylelint.io/) a try.
392+
393+
### Curly braces style?
394+
395+
PleaseAI defaults to `lessOpinionated: true`, which enforces `curly: ['error', 'all']` — always require braces around control flow bodies:
396+
397+
```js
398+
// PleaseAI style
399+
if (foo) {
400+
return
401+
}
402+
403+
// NOT this (antfu default)
404+
if (foo)
405+
return
406+
```
407+
408+
Note: `antfu/top-level-function` is re-enabled, so top-level `function` declarations are still preferred over arrow functions.
409+
379410
## Re-exports
380411

381412
All exports from `@antfu/eslint-config` are re-exported, so you can import fine-grained configs directly:

packages/eslint-config/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function pleaseai(
77
): ReturnType<typeof antfu> {
88
return antfu(
99
{
10+
lessOpinionated: true,
1011
stylistic: {
1112
indent: 2,
1213
quotes: 'single',
@@ -15,6 +16,7 @@ export function pleaseai(
1516
typescript: true,
1617
gitignore: true,
1718
rules: {
19+
'antfu/top-level-function': 'error',
1820
'test/prefer-lowercase-title': 'off',
1921
},
2022
...options,
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import type { Linter } from 'eslint'
12
import packageJson from 'eslint-plugin-package-json'
23

3-
export const recommended = packageJson.configs['recommended-publishable']
4-
export const stylistic = packageJson.configs.stylistic
4+
export const recommended: Linter.Config = packageJson.configs['recommended-publishable']
5+
export const stylistic: Linter.Config = packageJson.configs.stylistic
56

67
export default recommended

0 commit comments

Comments
 (0)