coderaiser / putout

🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
https://putout.cloudcmd.io/
MIT License
712 stars 40 forks source link

`eslint-plugin-putout` with ESLint flat config #219

Closed abdul-alhasany closed 2 months ago

abdul-alhasany commented 2 months ago

Is the eslint-plugin-putout available for the new ESLint flat config?

I tried using it this way:

    ...compat.config({
        extends: 'plugin:putout/recommended',
        rules: {
            'putout/add-newlines-between-specifiers': 'warn',
            'putout/add-newline-before-return': 'warn',
            'poutout/multiple-properties-destructuring': 'warn',
        },
    }),

but did not have much success.

coderaiser commented 2 months ago

Sure, here is docs

abdul-alhasany commented 2 months ago

Thankks for the reply. This includes everything (including eslint and n config). I have my own config and I wanted to add few rules from putout. Is that possible?

coderaiser commented 2 months ago

You can turn off everything you don't need

coderaiser commented 2 months ago

Is it works for you?

abdul-alhasany commented 2 months ago

Unfortunately not as I want. The recommneded part adds all these:

const nPlugin = require('eslint-plugin-n');
const {FlatCompat} = require('@eslint/eslintrc');
const putoutPlugin = require('..');

It is conflicting with my eslint config.

I only want putout part but it is not exported.

coderaiser commented 2 months ago

How it is conflicting in your config? Do you have any errors?

coderaiser commented 2 months ago

If you want only putout plugin was exported you can submit PR:

https://github.com/coderaiser/putout/blob/7eda682759840fbd2270807fdda0cd4152102141/packages/eslint-plugin-putout/lib/config/index.js#L5

Don’t forget to update tests, so it wasn’t removed unexpectedly: https://github.com/coderaiser/putout/blob/7eda682759840fbd2270807fdda0cd4152102141/packages/eslint-plugin-putout/lib/config/index.spec.mjs#L32

coderaiser commented 2 months ago

Actually things much more simpler, if you don't need config, and just need a plugin use:

import putout from 'eslint-plugin-putout';

export default [{
    plugins: {
        putout,
    },
    rules: {
        "putout/putout": "error"
    }
}];

That's it, plugins API didn't changed, only format of configs. Is it works for you?

abdul-alhasany commented 2 months ago

Great. It is working now. I find a couple of bugs in rules. I will submit separate issues for them