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: deprecate prettier integration #346

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,33 +338,6 @@ export default antfu({

We provide some optional configs for specific use cases, that we don't include their dependencies by default.

#### Prettier

ESLint is mainly forced on JavaScript. It can support other languages with custom parsers, but that requires a lot of effort to rule parsers and rules to build ecosystems around them. For example, ESLint does not handle CSS and HTML at this moment. It has been a shame for a long time. But since Prettier supports wider range of languages, why don't we use Prettier for them?

> [!WARNING]
> This is experiemental :)

To enable Prettier support, you need to explicitly turn it on and specify the languages you want to handle:

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

export default antfu({
prettier: {
css: true, // Let Prettier handles CSS, LESS, SCSS, etc
html: true, // Let Prettier handles HTML
}
})
```

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

```bash
npm i -D eslint-plugin-prettier prettier
```

#### React

To enable React support you need to explicitly turn it on:
Expand Down
5 changes: 5 additions & 0 deletions src/configs/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import { ensurePackages, interopDefault } from '../utils'
import type { FlatConfigItem, OptionsPrettier, StylisticConfig } from '../types'
import { StylisticConfigDefaults } from './stylistic'

/**
* @deprecated
*/
export async function prettier(
options: OptionsPrettier = {},
stylistic: StylisticConfig = {},
): Promise<FlatConfigItem[]> {
console.warn('@antfu/eslint-config: `prettier` option is deprecated, please do not use it anymore. We will find better formatters to support that in the future.')

await ensurePackages([
'@antfu/eslint-plugin-prettier',
])
Expand Down
Loading