antfu / eslint-config

Anthony's ESLint config preset
https://eslint-config.antfu.me/
MIT License
3.8k stars 425 forks source link

Prettier compatibility for JS/TS (`eslint-config-prettier`) #615

Open fregante opened 4 days ago

fregante commented 4 days ago

Clear and concise description of the problem

I'd like to use Prettier (externally) and this config for everything else. The suggestion is generally to use either stylistic or prettier, but not both. The problem is that stylistic has extra linting rules that Prettier doesn't concern itself with.

We have eslint-config-prettier for this purpose but I don’t think it works when plugins are renamed.

Suggested solution

import antfu from '@antfu/eslint-config'

export default antfu({
    prettierCompat: true,
})

Alternative

I think the alternative is

import antfu from '@antfu/eslint-config'
import eslintConfigPrettier from 'eslint-config-prettier'

export default [
    ...antfu()
        .renamePlugins({
        ts: '@typescript-eslint',
        yaml: 'yml',
        node: 'n'
        // …
    }),
    eslintConfigPrettier,
]

with the drawbacks:

Additional context

No response

Validations

fregante commented 4 days ago

An alternative solution is to find and disable all conflicting rules. In my case, for now, it's:

export default antfu({
    rules: {
        'style/arrow-parens': 'off',
        'style/object-curly-spacing': 'off',
        'style/brace-style': 'off',
        'style/indent': 'off',
        'style/operator-linebreak': 'off',
        'style/quote-props': 'off',
        'svelte/indent': 'off',
    },
});

Which is not terrible, but also it's likely that new contributors will find more issues and won't know how to deal with them. eslint-config-prettier already exists as a solution to this and it would be great to be able to use it.