JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4267
  • Score
    100M100P100Q118434F
  • License MIT

Helps dial with ESLint Flat Configs

Package Exports

  • @putout/eslint-flat
  • @putout/eslint-flat/lib/flat.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/eslint-flat) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@putout/eslint-flat NPM version

Helps deal with ESLint FlatConfig.

Install

npm i @putout/eslint-flat

API

matchToFlat(match)

You have ability to write ESLint configs in objects instead of lots of arrays, for example instead of this:

export default [
    ...safeAlign, {
        files: ['bin/putout.mjs'],
        rules: {
            'n/hashbang': 'off',
        },
    }, {
        files: ['**/register.mjs'],
        rules: {
            'n/no-unsupported-features/node-builtins': 'off',
        },
    },
];

You can use matchToFlat:

import {matchToFlat} from '@putout/eslint-flat';
import {safeAlign} from 'eslint-plugin-putout/config';

export const match = {
    'bin/putout.mjs': {
        'n/hashbang': 'off',
    },
    '**/register.mjs': {
        'n/no-unsupported-features/node-builtins': 'off',
    },
};

export default [
    ...safeAlign,
    ...matchToFlat(match),
];

This also gives you ability to use new configs in monorepo:

matchToFlatDir(cwd: DirName|FileURL, path)

If your eslint.config.js exports match, you can use matchToFlatDir to build correct files arrays:

import {safeAlign} from 'eslint-plugin-putout/config';
import {matchToFlatDir} from '@putout/eslint-flat';

export default [
    ...safeAlign,
    ...matchToFlatDir(__dirname, './packages/putout'),
];

or

import {safeAlign} from 'eslint-plugin-putout/config';
import {matchToFlatDir} from '@putout/eslint-flat';

export default [
    ...safeAlign,
    ...matchToFlatDir(import.meta.url, './packages/putout'),
];

This is the same as:

export default [
    ...safeAlign, {
        files: ['**/packages/putout/bin/putout.mjs'],
        rules: {
            'n/hashbang': 'off',
        },
    }, {
        files: ['**/packages/putout/**/register.mjs'],
        rules: {
            'n/no-unsupported-features/node-builtins': 'off',
        },
        ignores: [
            ['**/packages/putout/**/fixture'],
        ],
    },
];

mergeESLintConfigs(cwd, directories)

When you have monorepo with lots of packages in ./packages directory:

import {safeAlign} from 'eslint-plugin-putout/config';
import {mergeESLintConfigs} from '@putout/eslint-flat';

const config = await mergeESlintConfigs(import.meta.url, ['./packages']);

export default [
    ...safeAlign,
    ...config,
];

createESLintConfig(configs)

Gives ability to avoid lots of spreads (alias to defineConfig:

export default createESLintConfig([safeAlign, config]);

License

MIT