Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Latest commit

 

History

History
101 lines (79 loc) · 2.8 KB

README.md

File metadata and controls

101 lines (79 loc) · 2.8 KB

ESLint Flat Compatibility

NPM Version NPM Downloads ESM Provenance CodeQL Specs Commitlint Editorconfig Prettier ESLint Remark

Table of Contents

Installation

bun i -D @archoleat/eslint-flat-compatibility

Usage

Before

import { fileURLToPath } from 'url';
import path from 'path';

import { defineFlatConfig } from 'eslint-define-config';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
  baseDirectory: __dirname,
  resolvePluginsRelativeTo: __dirname,
});

export default defineFlatConfig([
  ...compat.extends(
    'airbnb-typescript/base',
    'plugin:import/recommended',
    'plugin:import/typescript',
  ),
// ...

After

import { config, env, extend, plugins } from '@archoleat/eslint-flat-compatibility';
import { defineFlatConfig } from 'eslint-define-config';

export default defineFlatConfig([
  // Mimic extends
  ...extend(
    'airbnb-typescript/base',
    'plugin:import/recommended',
    'plugin:import/typescript',
  ),

  // Mimic env
  ...env({
    es2020: true,
    node: true,
  }),

  // Mimic plugins
  ...plugins('airbnb', 'react'),

  // Translate an entire config
  ...config({
    env: {
      es2020: true,
      node: true,
    },
    extends: ['airbnb/base'],
    plugins: ['airbnb', 'unicorn'],
    rules: {
      semi: 'error',
    },
  }),
]);

Contributing

Please read CONTRIBUTING to start contributing.

License

This project is licensed under the MIT license.