GithubHelp home page GithubHelp logo

eslintrc's Introduction

ESLintRC Library

This repository contains the legacy ESLintRC configuration file format for ESLint. This package is not intended for use outside of the ESLint ecosystem. It is ESLint-specific and not intended for use in other programs.

Note: This package is frozen except for critical bug fixes as ESLint moves to a new config system.

Installation

You can install the package as follows:

npm install @eslint/eslintrc --save-dev

# or

yarn add @eslint/eslintrc -D

Usage (ESM)

The primary class in this package is FlatCompat, which is a utility to translate ESLintRC-style configs into flat configs. Here's how you use it inside of your eslint.config.js file:

import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import path from "path";
import { fileURLToPath } from "url";

// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
    baseDirectory: __dirname,                  // optional; default: process.cwd()
    resolvePluginsRelativeTo: __dirname,       // optional
    recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended"
    allConfig: js.configs.all,                 // optional unless you're using "eslint:all"
});

export default [

    // mimic ESLintRC-style extends
    ...compat.extends("standard", "example"),

    // mimic environments
    ...compat.env({
        es2020: true,
        node: true
    }),

    // mimic plugins
    ...compat.plugins("airbnb", "react"),

    // translate an entire config
    ...compat.config({
        plugins: ["airbnb", "react"],
        extends: "standard",
        env: {
            es2020: true,
            node: true
        },
        rules: {
            semi: "error"
        }
    })
];

Usage (CommonJS)

Using FlatCompat in CommonJS files is similar to ESM, but you'll use require() and module.exports instead of import and export. Here's how you use it inside of your eslint.config.js CommonJS file:

const { FlatCompat } = require("@eslint/eslintrc");
const js = require("@eslint/js");

const compat = new FlatCompat({
    baseDirectory: __dirname,                  // optional; default: process.cwd()
    resolvePluginsRelativeTo: __dirname,       // optional
    recommendedConfig: js.configs.recommended, // optional unless using "eslint:recommended"
    allConfig: js.configs.all,                 // optional unless using "eslint:all"
});

module.exports = [

    // mimic ESLintRC-style extends
    ...compat.extends("standard", "example"),

    // mimic environments
    ...compat.env({
        es2020: true,
        node: true
    }),

    // mimic plugins
    ...compat.plugins("airbnb", "react"),

    // translate an entire config
    ...compat.config({
        plugins: ["airbnb", "react"],
        extends: "standard",
        env: {
            es2020: true,
            node: true
        },
        rules: {
            semi: "error"
        }
    })
];

Troubleshooting

TypeError: Missing parameter 'recommendedConfig' in FlatCompat constructor

The recommendedConfig option is required when any config uses eslint:recommended, including any config in an extends clause. To fix this, follow the example above using @eslint/js to provide the eslint:recommended config.

TypeError: Missing parameter 'allConfig' in FlatCompat constructor

The allConfig option is required when any config uses eslint:all, including any config in an extends clause. To fix this, follow the example above using @eslint/js to provide the eslint:all config.

License

MIT License

eslintrc's People

Contributors

aladdin-add avatar amareshsm avatar brettz9 avatar coderaiser avatar daidodo avatar fasttime avatar github-actions[bot] avatar henryqdineen avatar kecrily avatar ljharb avatar mdjermanovic avatar nzakas avatar onigoetz avatar opravil-jan avatar realityking avatar regseb avatar richienb avatar santanag avatar simenb avatar snitin315 avatar timvdlippe avatar tjenkinson avatar voxpelli avatar wesbos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eslintrc's Issues

copyight holder seems not a legal entity

The file LICENSE states the following:

Copyright (c) 2020 ESLint

I am not a lawyer, but can only understand that sentence as "ESLint claims to hold legal copyright over substantial inventive work done in 2020".

Is "ESLint" even a legal entity that can claim copyright?

The Project ESLint says that another legal entity - "JS Foundation" - holds copyright for that.

It is worth noting that since 1989 the very act of writing such copyright notice is no longer a legal requirement - copyright is implicit nowadays - and the main reason to do it anyway is as a courtesy for users to let them know who they likely will need to contact if they want to negotiate an unusual deal (i.e. relicensing).

I guess that the a more accurate copyright notice would be same as for ESLint, since this project seems to be a fork of a subset of that other project.

"TypeError: Unexpected array" when importing @typescript-eslint

Hello, I can't tell if the issue I'm experiencing is user error, a bug in this package, or incompatibility in the 3rd party @typescript-eslint plugin. Basically I'm trying to use that plugin to add TypeScript linting rules, while using the new flat config file format.

Here is the folder structure for my repo (a game called "Farmageddon"):

  • Root
    • backend/
      • eslint.config.js
      • tsconfig.json
      • package.json
      • src/
        • .ts files
      • test/
        • .ts files

And file contents:

eslint.config.js

Inspired by:

import path from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";

// Mimic CommonJS variables
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
  // I've also tried every combination of commenting out these properties, but always get the same output
  baseDirectory: __dirname,
  resolvePluginsRelativeTo: __dirname,
});

export default [
  "eslint:recommended",
  compat.config({
    plugins: ["@typescript-eslint"],
    extends: [
      "plugin:@typescript-eslint/recommended",
      "plugin:@typescript-eslint/recommended-requiring-type-checking",
    ]
  }),
  {
    ignores: [
        // ...
    ],
  },
  {
    languageOptions: {
      // I've also tried using `import tsEslintParser from "@typescript-eslint/parser"` then passing `tsEslintParser` to this property, but same output
      parser: "@typescript-eslint/parser",
      ecmaVersion: "latest",
    },
  },
  {
    files: ["*.ts"],
    languageOptions: {
      parserOptions: {
        tsconfigRootDir: __dirname,
        project: ["./tsconfig.json"],
      },
    },
    rules: {
      // ...
    }
  },
];
tsconfig.json

Inspired by tsc --init and the TS configuration docs.

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "include": [
    "src/**/*.ts",
    "test/**/*.ts",
  ],
  "exclude": [
    "node_modules/"
  ],
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */
    "incremental": true,
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "outDir": "dist/",
    "composite": false,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictBindCallApply": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
  }
}
package.json
{
  "name": "<my-package>",
  "version": "0.0.1",
  "type": "module",
  "scripts": {
    "compile": "tsc",
    "lint": "eslint --fix .",
  },
  "dependencies": {
    "source-map-support": "^0.5.20"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^1.3.3",
    "@tsconfig/node16": "^1.0.3",
    "@types/aws-lambda": "^8.10.84",
    "@types/node": "^16.11.0",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.0.0",
    "esbuild": "^0.15.10",
    "eslint": "^8.0.1",
    "jest": "^29.1.2",
    "ts-jest": "^29.0.3",
    "ts-mockito": "^2.6.1",
    "typescript": "^4.4.4"
  }
}

When I run npm run lint -- --debug, I get a TypeError: Unexpected array error with the following debug logs:

ESLint output
eslint:cli CLI args: [ '--fix', '.', '--debug' ] +0ms
  eslint:cli Using flat config? true +8ms
  eslint:cli Running on files +6ms
  eslint:flat-eslint Searching for eslint.config.js +0ms
  eslint:flat-eslint Loading config from /workspaces/Farmageddon/backend/eslint.config.js +1ms
  eslint:flat-eslint Config file URL is file:///workspaces/Farmageddon/backend/eslint.config.js +0ms
  eslintrc:config-array-factory Loading {extends:"plugin:@typescript-eslint/recommended"} relative to  +0ms
  eslintrc:config-array-factory Loading plugin "@typescript-eslint" from  +1ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js) +1ms
  eslint:rules Loading rule 'brace-style' (remaining=287) +0ms
  eslint:rules Loading rule 'comma-dangle' (remaining=286) +11ms
  eslint:rules Loading rule 'dot-notation' (remaining=285) +12ms
  eslint:rules Loading rule 'indent' (remaining=284) +8ms
  eslint:rules Loading rule 'init-declarations' (remaining=283) +16ms
  eslint:rules Loading rule 'keyword-spacing' (remaining=282) +2ms
  eslint:rules Loading rule 'lines-between-class-members' (remaining=281) +2ms
  eslint:rules Loading rule 'no-dupe-class-members' (remaining=280) +27ms
  eslint:rules Loading rule 'no-duplicate-imports' (remaining=279) +3ms
  eslint:rules Loading rule 'no-empty-function' (remaining=278) +4ms
  eslint:rules Loading rule 'no-extra-parens' (remaining=277) +4ms
  eslint:rules Loading rule 'no-extra-semi' (remaining=276) +3ms
  eslint:rules Loading rule 'no-invalid-this' (remaining=275) +15ms
  eslint:rules Loading rule 'no-loop-func' (remaining=274) +2ms
  eslint:rules Loading rule 'no-loss-of-precision' (remaining=273) +1ms
  eslint:rules Loading rule 'no-magic-numbers' (remaining=272) +2ms
  eslint:rules Loading rule 'no-restricted-imports' (remaining=271) +37ms
  eslint:rules Loading rule 'no-unused-expressions' (remaining=270) +71ms
  eslint:rules Loading rule 'no-useless-constructor' (remaining=269) +6ms
  eslint:rules Loading rule 'object-curly-spacing' (remaining=268) +21ms
  eslint:rules Loading rule 'quotes' (remaining=267) +147ms
  eslint:rules Loading rule 'semi' (remaining=266) +52ms
  eslint:rules Loading rule 'space-before-blocks' (remaining=265) +7ms
  eslint:rules Loading rule 'space-infix-ops' (remaining=264) +4ms
  eslintrc:config-array-factory Plugin /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js loaded in: 1598ms +2s
  eslintrc:config-array-factory Loading {extends:"./configs/base"} relative to /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +0ms
  eslintrc:config-array-factory package.json was not found: Cannot find module './configs/base/package.json'
Require stack:
- /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +1ms
  eslintrc:config-array-factory Loaded: ./configs/base (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js) +0ms
  eslintrc:config-array-factory Loading JS config file: /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js +1ms
  eslintrc:config-array-factory Loading parser "@typescript-eslint/parser" from /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js +2ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/parser/dist/index.js) +0ms
  eslintrc:config-array-factory Loading plugin "@typescript-eslint" from /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js +2ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js) +1ms
  eslintrc:config-array-factory Plugin /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js loaded in: 0ms +0ms
  eslintrc:config-array-factory Loading {extends:"./configs/eslint-recommended"} relative to /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +0ms
  eslintrc:config-array-factory package.json was not found: Cannot find module './configs/eslint-recommended/package.json'
Require stack:
- /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +1ms
  eslintrc:config-array-factory Loaded: ./configs/eslint-recommended (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js) +0ms
  eslintrc:config-array-factory Loading JS config file: /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js +0ms
  eslintrc:config-array-factory Loading {extends:"plugin:@typescript-eslint/recommended-requiring-type-checking"} relative to  +5ms
  eslintrc:config-array-factory Loading plugin "@typescript-eslint" from  +0ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js) +1ms
  eslintrc:config-array-factory Plugin /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js loaded in: 0ms +0ms
  eslintrc:config-array-factory Loading {extends:"./configs/base"} relative to /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +0ms
  eslintrc:config-array-factory package.json was not found: Cannot find module './configs/base/package.json'
Require stack:
- /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +0ms
  eslintrc:config-array-factory Loaded: ./configs/base (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js) +0ms
  eslintrc:config-array-factory Loading JS config file: /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js +0ms
  eslintrc:config-array-factory Loading parser "@typescript-eslint/parser" from /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js +1ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/parser/dist/index.js) +0ms
  eslintrc:config-array-factory Loading plugin "@typescript-eslint" from /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js +1ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js) +0ms
  eslintrc:config-array-factory Plugin /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js loaded in: 0ms +0ms
  eslintrc:config-array-factory Loading {extends:"./configs/eslint-recommended"} relative to /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +0ms
  eslintrc:config-array-factory package.json was not found: Cannot find module './configs/eslint-recommended/package.json'
Require stack:
- /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +0ms
  eslintrc:config-array-factory Loaded: ./configs/eslint-recommended (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js) +0ms
  eslintrc:config-array-factory Loading JS config file: /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js +0ms
  eslintrc:config-array-factory Loading plugin "@typescript-eslint" from  +2ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/[email protected] (/workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js) +1ms
  eslintrc:config-array-factory Plugin /workspaces/Farmageddon/backend/node_modules/@typescript-eslint/eslint-plugin/dist/index.js loaded in: 0ms +0ms
  eslintrc:flat-compat Resolving parser 'undefined' relative to /workspaces/Farmageddon/backend/__placeholder.js +0ms
  eslintrc:flat-compat Translating plugins: [object Object] +0ms
  eslintrc:flat-compat Translating plugin: @typescript-eslint +1ms
  eslintrc:flat-compat Resolving plugin '@typescript-eslint relative to /workspaces/Farmageddon/backend/__placeholder.js +0ms
  eslintrc:flat-compat Resolving parser 'undefined' relative to /workspaces/Farmageddon/backend/__placeholder.js +0ms
  eslintrc:flat-compat Translating plugins: [object Object] +0ms
  eslintrc:flat-compat Translating plugin: @typescript-eslint +0ms
  eslintrc:flat-compat Resolving plugin '@typescript-eslint relative to /workspaces/Farmageddon/backend/__placeholder.js +0ms
  eslintrc:flat-compat Translating plugins: [object Object] +0ms
  eslintrc:flat-compat Translating plugin: @typescript-eslint +1ms
  eslintrc:flat-compat Resolving plugin '@typescript-eslint relative to /workspaces/Farmageddon/backend/__placeholder.js +0ms

Oops! Something went wrong! :(

ESLint: 8.24.0

TypeError: Unexpected array.
    at flatTraverse (/workspaces/Farmageddon/backend/node_modules/@humanwhocodes/config-array/api.js:183:12)
    at flatTraverse.next (<anonymous>)
    at normalize (/workspaces/Farmageddon/backend/node_modules/@humanwhocodes/config-array/api.js:201:19)
    at async FlatConfigArray.normalize (/workspaces/Farmageddon/backend/node_modules/@humanwhocodes/config-array/api.js:603:30)
    at async calculateConfigArray (/workspaces/Farmageddon/backend/node_modules/eslint/lib/eslint/flat-eslint.js:443:5)
    at async FlatESLint.lintFiles (/workspaces/Farmageddon/backend/node_modules/eslint/lib/eslint/flat-eslint.js:776:25)
    at async Object.execute (/workspaces/Farmageddon/backend/node_modules/eslint/lib/cli.js:395:23)
    at async main (/workspaces/Farmageddon/backend/node_modules/eslint/bin/eslint.js:135:24)
If this is not a bug, then some guidance would be much appreciated!

Note that I am running this command in a VS Code devcontainer with Node 16.18.1 and npm 8.19.2 installed, on WSL2 on Windows 11 Pro.

Test built-in rule schema validation

refs #14

ESLint should validate configuration for built-in rules, and throw if the configuration is invalid.

We had a regression described in eslint/eslint#13793, due to the lack of tests for this scenario.

An integration test has been added in the eslint/eslint repo (eslint/eslint#13794), but we should add some unit tests to this repository, too.

Upgrade Espree

eslintrc has espree as a dependency, so when we start with v8.0.0 prereleases we should update package.json here.

Unless in the meantime we figure out how to remove the dependency on espree, if possible.

config-array "mergeWithoutOverwrite" make linting fail by transforming Regex into empty object

Issue

When using eslint programmatically, we're allowed to pass parserOptions as an object. If this object contains a regex, it will be transformed to an empty object (following eslint calling extractConfig in linter verify -> _verifyWithConfigArray here) :

function mergeWithoutOverwrite(target, source) {
if (!isNonNullObject(source)) {
return;
}
for (const key of Object.keys(source)) {
if (key === "__proto__") {
continue;
}
if (isNonNullObject(target[key])) {
mergeWithoutOverwrite(target[key], source[key]);
} else if (target[key] === void 0) {
if (isNonNullObject(source[key])) {
target[key] = Array.isArray(source[key]) ? [] : {};
mergeWithoutOverwrite(target[key], source[key]);
} else if (source[key] !== void 0) {
target[key] = source[key];
}
}
}
}

Example
It makes linting fail when using @babel/eslint-parser as parser with babelOptions containing exclude as Regex:

import { ESLint } from "eslint";

const cwd = 'somewhere'
const files = 'somefiles';

const eslintConfig = {
  parser: require.resolve("@babel/eslint-parser"),
  extends: ["eslint:recommended", "plugin:prettier/recommended"],
  plugins: ["eslint-plugin-prettier"],
  rules: {
    "prettier/prettier": "error",
  },
  parserOptions: {
    ecmaVersion: 2022,
    sourceType: "module",
    requireConfigFile: false,
    babelOptions: {
      exclude: /node_modules\/(core-js|@babel\/runtime)/,
      presets: [
        [
          require.resolve("@babel/preset-env"),
          {
            targets: [`defaults and supports es6-module`],
            useBuiltIns: "usage",
            corejs: { version: "3.21", proposals: true },
          },
        ],
      ],
      plugins: [
        [
          require.resolve("@babel/plugin-transform-runtime"),
          { useESModules: true },
        ],
      ],
    },
  },
};

const eslint = new ESLint({
  cwd,
  baseConfig: eslintConfig,
  resolvePluginsRelativeTo: __dirname,
});
const lintResults = await eslint.lintFiles(files);

Would trigger 0:0 error Parsing error: .exclude must be a string/Function/RegExp, or an array of those because the options are transformed to:

babelOptions: {
    exclude: {}, // <= instead of keeping the regex
    presets: [ [Array] ],
    plugins: [ [Array] ]
  },

Proposed change

To solve this issue, mergeWithoutOverwrite need to check is the source[key] is a regex on top of checking for an object:

@@ -146,8 +146,12 @@ function mergeWithoutOverwrite(target, source) {
             mergeWithoutOverwrite(target[key], source[key]);
         } else if (target[key] === void 0) {
             if (isNonNullObject(source[key])) {
+              if (source[key] instanceof RegExp) {
+                target[key] = source[key];
+              } else {
                 target[key] = Array.isArray(source[key]) ? [] : {};
                 mergeWithoutOverwrite(target[key], source[key]);
+              }
             } else if (source[key] !== void 0) {
                 target[key] = source[key];
             }

Missing "globals" dependency

When I'm installing the latest version of eslint in my project, it pulls in this package which gets the wrong version of the globals package because it's not listed in the package.json for this dependency and globals.es2015 is not defined by the version installed globalls in my project (as a side-effect of babel-traverse).

PR incoming

FlatCompat doesn't have a good pattern for applying plugins / extends to files

I'd like to convert our ESLint configs to the flat config format.

However, I'm running into immediate problems where it seems I must choose to use FlatCompat for everything, or use FlatCompat for nothing.

For example, I have plugins and extends that apply to specific files.

Yet, in the documentation, it has plugins and extends spreading into the root configuration array.

Instead, what I want is:

module.exports = [
  // other files
  {
    files: ['*.ts', '*.tsx', '*.vue'],
    // this is an error, because it spreads configs, but I want it to apply extends to JUST THESE FILES based on the compat layer
    ...compat.extends(
      'plugin:vue/vue3-strongly-recommended',
      'standard-with-typescript'
    ),
    languageOptions: {
      parser: VueEsLintParser,
      parserOptions: {
        parser: TSParser,
        project: './tsconfig.json',
        extraFileExtensions: ['.vue']
      }
    }
  }
 ]

In other words, with the old file format, I could use plugins / extends with specific matching files. Yet if I do that, it looks like I must use ...compat.config and use the old configuration for everything (so, not using languageOptions, direct parser imports, etc).

Is there not a way to get the best of both worlds, and import plugins / extends while maintaining the new format for everything else?

Bug: `FlatCompat.config` doesn't work with `overrides`

Step to reproduce

  • eslint: 8.46.0
  • @eslint/eslintrc: 2.1.1

You can open & run: https://runkit.com/ayc0/64cac9cf2e21ef0008bee16d

This runkit gets lost / deleted / edited, here is the raw code
const code = 'console.log(process.pwd())';

const run = async (ESLint, config, filePath) => {
    const eslint = new ESLint(config);
    
    // 2. Lint text.
    const results = await eslint.lintText(code, { filePath });

    // 3. Format the results.
    const formatter = await eslint.loadFormatter("stylish");
    const resultText = formatter.format(results);

    // 4. Output it.
    console.log(resultText);
}

const baseConfig = {
    rules: {
      'no-undef': 'error',
    },
    overrides: [{
        files: ['node.js'],
        env: {
            node: true
        },
    }]
}

const { ESLint } = require("[email protected]");

const config = { useEslintrc: false, overrideConfig: baseConfig };

await run(ESLint, config, 'classic/node.js'); // should be okay โœ…
await run(ESLint, config, 'classic/not-node.js'); // should have an error โœ…
// Check output

const { FlatCompat } = require("@eslint/[email protected]");
const { FlatESLint } = require("[email protected]/use-at-your-own-risk");


const compat = new FlatCompat({
    baseDirectory: __dirname
});
const flatConfig = compat.config(baseConfig);

console.log(flatConfig);

await run(FlatESLint, { overrideConfigFile: true, overrideConfig: flatConfig }, 'flat/node.js'); // should be okay โœ…
await run(FlatESLint, { overrideConfigFile: true, overrideConfig: flatConfig }, 'flat/not-node.js'); // should have an error โŒ
// Check output

Explanation of the bug

If we have this config:

const legacyConfig = {
    rules: {
      'no-undef': 'error',
    },
    overrides: [{
        files: ['node.js'],
        env: {
            node: true
        },
    }]
}

With the legacy config, using process.cwd() shouldn't be allowed in a file like no-node.js, but allowed in node.js

image

And if we use FlatCompat to port it to the new structure, we should have the same result.

But when we do:

const compat = new FlatCompat({
    baseDirectory: __dirname
});
const flatConfig = compat.config(legacyConfig);

We can see that the files and envs' config aren't merged together, instead we have 1 row for the env, and another one empty one for the overrides:

image

And surely, when we run eslint with this config, no errors are reported (see the "" x2):

image

The `files` setting with base configs

From eslint/eslint#8813

The extends setting in the overrides section was a long-standing issue and it's a popular feature now.

Currently, the flat config doesn't provide an easy way for that.
I think a solution is the following one:

import baseConfig from "my-eslint-config"
import mocha from "eslint-plugin-mocha"
export default [
  baseConfig.base,
  {
    "files": ["/scripts/**", "/server/**"],
    "configs": [baseConfig.node], // may have different settings for CJS and ESM. Also, it mey be a function to check `${cwd}/package.json`'s module type.
  },
  {
    "files": ["/client/**/*"],
    "configs": [baseConfig.browser],
  },
  {
    "files": ["/test/**/*.js"],
    "configs": [baseConfig.node, mocha.configs.recommended],
  },
]

It just merges the files properties in the flattening phase by AND patterns.

`FlatCompat#env({es2024: true})` missing builtin globals

new (require('@eslint/eslintrc').FlatCompat)().env({es2024: true})[0]
{
  languageOptions: {
    globals: {
      ArrayBuffer: false,
      DataView: false,
      Float32Array: false,
      Float64Array: false,
      Int16Array: false,
      Int32Array: false,
      Int8Array: false,
      Map: false,
      Promise: false,
      Proxy: false,
      Reflect: false,
      Set: false,
      Symbol: false,
      Uint16Array: false,
      Uint32Array: false,
      Uint8Array: false,
      Uint8ClampedArray: false,
      WeakMap: false,
      WeakSet: false,
      Atomics: false,
      SharedArrayBuffer: false,
      BigInt: false,
      BigInt64Array: false,
      BigUint64Array: false,
      globalThis: false,
      AggregateError: false,
      FinalizationRegistry: false,
      WeakRef: false
    },
    ecmaVersion: 15
  }
}

Shouldn't objects like Array includes?

Caching is not supported when parser is an object

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

import { FlatCompat } from '@eslint/eslintrc'

// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

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

/**
 * @type {import('@types/eslint').Linter.Config}
 */
const legacyConfig = {
  overrides: [
    {
      files: ['**/*.ts?(x)'],
      parser: '@typescript-eslint/parser',
      parserOptions: {
        ecmaVersion: 'latest',
        sourceType: 'module',
        ecmaFeatures: {
          jsx: true
        },
        // typescript-eslint specific options
        warnOnUnsupportedTypeScriptVersion: true
      }
    }
  ],
  plugins: ['@typescript-eslint'],
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:import/typescript'
  ],
  settings: {
    'import/resolver': 'typescript'
  },
  rules: {
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': [
      'error',
      {
        args: 'none',
        ignoreRestSiblings: true
      }
    ]
  }
}

export default compat.config(legacyConfig)

output:

PS C:\Users\liuwei\Desktop\gitlab\eastcoal-pc> pnpm eslint --print-config eslint.config.js

Oops! Something went wrong! :(

ESLint: 8.33.0

Error: Caching is not supported when parser is an object.
    at Object.value (C:\Users\liuwei\Desktop\gitlab\eastcoal-pc\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\config\flat-config-array.js:188:27)
    at JSON.stringify (<anonymous>)
    at Object.execute (C:\Users\liuwei\Desktop\gitlab\eastcoal-pc\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\cli.js:387:27)
    at async main (C:\Users\liuwei\Desktop\gitlab\eastcoal-pc\node_modules\.pnpm\[email protected]\node_modules\eslint\bin\eslint.js:135:24)

I encountered an issue related to Vue templates while using FlatCompat for a smooth ESLint configuration upgrade.

First, my app.vue code is as follows:

<template>
  <div>
    {{ textInTemplate }}
  </div>
</template>

<script lang="ts" setup>
const textInTemplate = 'Hello World'
const unusedText = 'unusedText'
</script>

Here is an example of the simplest configuration:

// eslint.config.js
const { FlatCompat } = require('@eslint/eslintrc') // version "2.0.2"

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

module.exports = [
  ...compat.config({ extends: ['@nuxtjs/eslint-config-typescript'] }),

  {
    files: ['**/*.js'],
    rules: {
      '@typescript-eslint/no-var-requires': 'off'
    }
  }
]

8:7 error 'textInTemplate' is assigned a value but never used @typescript-eslint/no-unused-vars
9:7 error 'unusedText' is assigned a value but never used @typescript-eslint/no-unused-vars

// .eslintrc.js
module.exports = {
  extends: ['@nuxtjs/eslint-config-typescript'],
  overrides: [{
    files: ['**/*.js'],
    rules: {
      '@typescript-eslint/no-var-requires': 'off'
    }
  }]
}

9:7 error 'unusedText' is assigned a value but never used @typescript-eslint/no-unused-vars

It seems that when using FlatCompat for configuration, there are some issues with the detection of the variable textInTemplate that I don't understand. The configuration has already removed other interference items, but I still get incorrect results, which is not as expected.

eslint: 8.37.0
@eslint/eslintrc: 2.0.2
@nuxtjs/eslint-config-typescript: 12.0.0
vue-eslint-parser: 9.1.0

Package tries to access globals and causes error in ESLint

I upgraded to ESLint 7.8 today, and by doing this @eslint/eslintrc was also installed. Now, when I try to run ESLint from Yarn 2, the following error pops up:

Error: @eslint/eslintrc tried to access globals, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: globals (via "globals")
Required by: @eslint/eslintrc@npm:0.1.0 (via /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/@eslint-eslintrc-npm-0.1.0-30c7545ebe-53d20acf9f.zip/node_modules/@eslint/eslintrc/conf/)

Require stack:
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/@eslint-eslintrc-npm-0.1.0-30c7545ebe-53d20acf9f.zip/node_modules/@eslint/eslintrc/conf/environments.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/lib/linter/linter.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/lib/linter/index.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/lib/cli-engine/cli-engine.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/lib/eslint/eslint.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/lib/eslint/index.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/lib/cli.js
- /Users/MY_USERNAME/MY_PROJECT/.yarn/cache/eslint-npm-7.8.0-3feded5885-2c25ff617b.zip/node_modules/eslint/bin/eslint.js
    at internalTools_makeError (/Users/MY_USERNAME/MY_PROJECT/.pnp.js:23429:34)
    at resolveToUnqualified (/Users/MY_USERNAME/MY_PROJECT/.pnp.js:24387:23)
    at resolveRequest (/Users/MY_USERNAME/MY_PROJECT/.pnp.js:24479:29)
    at Object.resolveRequest (/Users/MY_USERNAME/MY_PROJECT/.pnp.js:24545:26)
    at Function.external_module_.Module._resolveFilename (/Users/MY_USERNAME/MY_PROJECT/.pnp.js:23662:34)
    at Function.external_module_.Module._load (/Users/MY_USERNAME/MY_PROJECT/.pnp.js:23527:48)
    at Module.require (internal/modules/cjs/loader.js:1080:19)
    at require (/Users/MY_USERNAME/MY_PROJECT/.yarn/cache/v8-compile-cache-npm-2.1.0-86ea69cdd0-b7490d5484.zip/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/Users/MY_USERNAME/MY_PROJECT/.yarn/cache/@eslint-eslintrc-npm-0.1.0-30c7545ebe-53d20acf9f.zip/node_modules/@eslint/eslintrc/conf/environments.js:11:17)
    at Module._compile (/Users/MY_USERNAME/MY_PROJECT/.yarn/cache/v8-compile-cache-npm-2.1.0-86ea69cdd0-b7490d5484.zip/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)

When downgrading to ESLint 7.7, the error is solved.

How should nested configs be handled with compat?

If I have this .eslintrc.json:

{
  "root": true,
  "plugins": ["@nx"],
  "overrides": [
    {
      "files": ["*.ts", "*.tsx"],
      "extends": ["plugin:@nx/typescript"],
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "extends": ["plugin:@nx/javascript"],
      "rules": {}
    }
  ]
}

Based on the Migration guides and discussion with @nzakas I expected this to be the converted flat config:

const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');

const compat = new FlatCompat({
  baseDirectory: __dirname,
  recommendedConfig: js.configs.recommended, // the compat fails unless this is provided, see my other issue #127
});

module.exports = [
  ...compat.plugins('@nx'),
  {
    files: ['**/*.ts', '**/*.tsx'],
    ...compat.extends('plugin:@nx/typescript'),
    rules: {},
  },
  {
     files: ['**/*.js', '**/*.jsx'],
     ...compat..extends('plugin:@nx/javascript'),
    }),
    rules: {},
  }
];

Unfortunately, I get the following error:

Error: Unexpected key "0" found.
    at ObjectSchema.validate (/private/tmp/nx-e2e/nx/proj7028649/node_modules/.pnpm/@[email protected]/node_modules/@humanwhocodes/object-schema/src/object-schema.js:204:15)

The reason is that the extends is parsed to an array and mapped to key-value pairs.

{
	'0': {
	  rules: {
        // ... some rules
      }
    },
	'1': {
	  rules: {
        // ... some rules
      }
    },
   // ...
   files: ['**/*.js', '**/*.jsx'],
   rules: {}
}

Is FlatCompat meant to be used in the overrides? If so, what should it look like?

Something like this works but doesn't look nice:

module.exports = [
  ...compat.plugins('@nx'),
  Object.assign({},
    ...compat.extends('plugin:@nx/typescript'),
    {
      files: ['**/*.ts', '**/*.tsx'],
      rules: {},
    }
  ),
  Object.assign({},
    ...compat.extends('plugin:@nx/javascript'),
    {
      files: ['**/*.js', '**/*.jsx'],
      rules: {},
    }
  ),
];

Missing parameter 'recommendedConfig' in FlatCompat constructor

Environment:

  • eslint: 8.46.0
  • @eslint/eslintrc: 2.1.1
  • OS: macOS

Steps to reproduce:

  • packages/mylib/eslint.config.js
const baseConfig = require('../../eslint.config.js');
const jsoncEslintParser = require('jsonc-eslint-parser');

module.exports = [
  baseConfig,
  {
    files: ['packages/mylib/**/*.json'],
    languageOptions: {
      parser: jsoncEslintParser,
    },
    rules: { '@nx/dependency-checks': 'error' },
  },
];
  • eslint.config.js:
const nxEslintPlugin = require('@nx/eslint-plugin');
const { FlatCompat } = require('@eslint/eslintrc');
const globals = require('globals');

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

module.exports = [
  { plugins: { '@nx': nxEslintPlugin } },
  {
    files: ['**/*.ts', '**/*.tsx'],
    ...compat.extends('plugin:@nx/typescript'),
    rules: {},
  },
  {
    files: ['**/*.js', '**/*.jsx'],
    ...compat.extends('plugin:@nx/javascript'),
    rules: {},
  },
  { ignores: ['node_modules'] },
];

Current

Reports TypeError: Missing parameter 'recommendedConfig' in FlatCompat constructor.

Expected

The 'recommendedConfig' is not needed since docs mark it as optional

Recommendations Needed for Using FlatCompat in CommonJS eslint Configs

We are currently working on migrating our eslint configs to flat configs, but are facing a high level of complexity in the process. I'm seeking recommendations or best practices on how to effectively use FlatCompat in CommonJS eslint configs.

Utilization of FlatCompat in CommonJS:

  • How can FlatCompat be effectively used within CommonJS eslint configs?
  • Are there any best practices or recommended approaches to facilitate this integration?

Support for CommonJS Projects:

  • Has consideration been given to publishing the FlatCompat utility with support specifically for CommonJS projects?

Your insights and advice regarding these queries will be greatly valuable and appreciated.

`eslintrc` brings in a different version of `js-yaml` than `eslint`

@eslint/eslintrc depends on js-yaml@^3.13.1.

"js-yaml": "^3.13.1",

eslint depends on js-yaml@^4.1.0.

https://github.com/eslint/eslint/blob/796587ad950f6804d60473c2b5998ed3ec71c59e/package.json#L74

This means that eslint brings in two semver incompatible versions of js-yaml into the lockfile.

Proposed fix: update the js-yaml dependency in this package to have the same version constraint as that in eslint.

Issue: require() of ES modules is not supported.

Came across this issue for "@eslint/[email protected]"
Using ESLint v2.2.2

_Failed to compile.

Must use import to load ES Module: /node_modules/@eslint/eslintrc/universal.js
require() of ES modules is not supported.
require() of /node_modules/@eslint/eslintrc/universal.js from /node_modules/eslint/lib/linter/linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /node_modules/@eslint/eslintrc/package.json._

I realise it suggests removing the "type": "module" from the package.json but that seems extreme and problematic when dealing with automated build/deploy apps like Bamboo, etc. i.e. a build folder is deleted before every build starts.

Any chance of a fix for this in the source?
Cheers

[Bug] Cannot redefine plugin "vue" error

I'm getting this issue:

TypeError: Cannot redefine plugin "vue".
    at ObjectSchema.merge

I thought it might be because I have this in my root:

    files: ['*.ts', '*.tsx', '*.vue'],
    languageOptions: {
      parser: VueEsLintParser,
      parserOptions: {
        parser: TSParser,
        project: './tsconfig.json',
        extraFileExtensions: ['.vue']
      }
    },

... and then I have this in a sub-project (in my monorepo)

files: ['*.js', '*.ts', '*.tsx', '*.vue'],
    languageOptions: {
      parser: VueEsLintParser,
      parserOptions: {
        parser: TSParser,
        project: './tsconfig.json',
        extraFileExtensions: ['.vue']
      },

However, note that this should override the previous definition, and these are all local imports. This worked with the old file format, and I feel like it's perfectly valid for monorepos, especially as you might have different versions of Vue (and thus Vue parsers) in different projects.

Also note: I removed the base config definition, yet I'm still having this issue.

Why is this a legacy package?

I'm trying to understand the inner workings of ESLint, particularly the way the extends mechanism is implemented. It is my understanding that this package implements all parsing of configuration files. However, the README states (emphasis mine):

This repository contains the legacy ESLintRC configuration file format for ESLint.

What exactly does "legacy" mean in this context?

  • Is there another package for parsing .eslintrc.* files somewhere else that I missed, so that this package is considered deprecated?
  • Are the .eslintrc.* file formats themselves considered deprecated and there is a new, better configuration format?

"ConfigArrayFactory: loading config files should work properly" test failing

This test on main (af96cc5) is failing for me locally.

1) ConfigArrayFactory
       loading config files should work properly.
         Plugins
           should load information from a YML file and load plugins:
     YAMLException: Cannot read config file: /private/var/folders/c1/5j985n355jgdqhvpwwvvhpc00000gn/T/eslintrc/config-array-factory/plugins/.eslintrc.yml
Error: bad indentation of a mapping entry at line 3, column 29:
                                rules:
                                ^
      at generateError (node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
      at throwError (node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
      at readBlockMapping (node_modules/js-yaml/lib/js-yaml/loader.js:1107:7)
      at composeNode (node_modules/js-yaml/lib/js-yaml/loader.js:1359:12)
      at readDocument (node_modules/js-yaml/lib/js-yaml/loader.js:1525:3)
      at loadDocuments (node_modules/js-yaml/lib/js-yaml/loader.js:1588:5)
      at load (node_modules/js-yaml/lib/js-yaml/loader.js:1614:19)
      at Object.safeLoad (node_modules/js-yaml/lib/js-yaml/loader.js:1637:10)
      at loadYAMLConfigFile (lib/config-array-factory.js:161:21)
      at loadConfigFile (lib/config-array-factory.js:319:20)
      at ConfigArrayFactory._loadConfigData (lib/config-array-factory.js:609:42)
      at ConfigArrayFactory.loadFile (lib/config-array-factory.js:475:40)
      at load (tests/lib/config-array-factory.js:1706:18)
      at Context.<anonymous> (tests/lib/config-array-factory.js:2259:32)

All other tests pass.

Node version: v15.14.0
NPM version: 7.7.6

import/no-named-as-default import/no-named-as-default-member issue

Hello, I currently have my eslint config as follows:

import {FlatCompat} from '@eslint/eslintrc'
import path from 'path'
import {fileURLToPath} from 'url'
import globals from 'globals'

import jest from 'eslint-plugin-jest'

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

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

export default [
  ...compat.extends('eslint-config-airbnb-base'),
  prettierConfig,

  {
    files: ['**/*.js'],
    ignores: ['**/*.config.js', '!**/eslint.config.js', '!**/*.test.js'],
    languageOptions: {
      globals: {
        ...globals.node
      },
      ecmaVersion: 'latest'
    },

    rules: {
      'import/extensions': [
        'error',
        {
          js: 'always'
        }
      ],
      'no-console': ['error', {allow: ['info', 'warn', 'error']}],
      'import/no-extraneous-dependencies': [
        'error',
        { 'devDependencies': true },
      ]
    }
  }
]

although I have:
export default 'functionName', and import functionName from './functionName.js'
linter says that import functionName from './functionName.js violates the following lint rules:
import/no-named-as-default
import/no-named-as-default-member

I think I'm missing a configuration, but I can figure out what.
Appreciate any help

call createRequire lazily

I have some success to load eslint using import('https://jspm.dev/eslint@7') and running it too without any eslint config file in the browser. (I'm using useEslintrc: false)

version 8 don't work as grate, think it boils down to this:

const require = createRequire(import.meta.url);

...and also the fact that jspm don't support dynamic require() very well...

the best thing would be to not use createRequire at all and... they should be loaded async with import() instead... but lets not be hanged up on this too much... cuz it require to much refactoring and breakage.

I think the quickest and easiest solution would be to do:

require = (...args) => createRequire(import.meta.url)(...args)

is this ๐Ÿ‘† something you could quickly impl?


currently import('https://jspm.dev/eslint@7') dose not call any require().
i still have yet to figure out how to manually add some eslint plugin without using the rules config that are limited to plain objects.

TypeError: Cannot redefine plugin

happens when migrate legacy eslintrc config with flat configs.

const { FlatCompat } = require("@eslint/eslintrc");
const antfu = require('@antfu/eslint-config').default;

const compat = new FlatCompat({});

module.exports = [
  ...compat.config({
    "extends": "next/core-web-vitals"
  }),
  ...antfu({
    typescript: true,
  }),
];
Oops! Something went wrong! :(

ESLint: 8.53.0

TypeError: Cannot redefine plugin "import".

both legacy and flat from @antfu/eslint-config contains eslint-plugin-import, but seems this was fixed in #91

TypeError: Ajv is not a constructor

not sure where this error is exactly coming from but my open source project (eslint-plugin-jest-dom) uses kcd-scripts which in turn executes eslint. when we run lint in that way we see the following error:

FAIL src/__tests__/lib/rules/prefer-in-document.js
[test]   โ— Test suite failed to run
[test] 
[test]     TypeError: Ajv is not a constructor
[test] 
[test]       at Object.<anonymous>.module.exports (node_modules/@eslint/eslintrc/lib/shared/ajv.js:19:17)

you can see the issue here:
https://github.com/testing-library/eslint-plugin-jest-dom/runs/1476579289?check_suite_focus=true

Convert package to ESM

To convert this package from CommonJS to ECMAScript modules (ESM):

  • Add type: module to package.json
  • Convert files in lib to ESM
  • Convert files in tests/lib to ESM
  • Upgrade Mocha
  • Create build script in package.json to generate CommonJS file (.cjs) in dist directory (use Rollup)
  • Add dist to .gitignore
  • Run build in prepare script in package.json to ensure build is run at key moments
  • Update package.json so that main points in the CJS file in dist and exports provides both require and import options
  • Update README instructions

FlatCompat utility needs documentation (or has wrong documentation)

Even though the documentation says that recommendedConfig is optional, I'm getting this error for ESLint:

TypeError: Missing parameter 'recommendedConfig' in FlatCompat constructor

I think this is because a Nuxt config uses a non-flat file and is using 'eslint:recommended'. But the documentation doesn't make clear when you would / would not need that option.

ESLint Browser Test fails

The current main branch of @eslint/eslintrc breaks Browser Test in eslint/eslint. Consequently, the ESLint demo won't work.

eslint/eslint#14865 (comment)

How to reproduce locally:

  1. Check out the branch from eslint/eslint#14865
  2. Run node Makefile.js karma

The fix might include some updates in eslint/eslintrc repo and/or updates in webpack.config.js in eslint/eslint repo. I tried several approaches and nothing worked (fixing some errors always produces new errors).

I'd suggest reverting #39.

Problems with loading .eslintrc

There seems to be an issue with loading the .eslintrc file:

Cannot read config file: /Users/sh/projects/tests/delete_me/.eslintrc.js Error: require() of ES Module
/Users/sh/projects/tests/delete_me/.eslintrc.js from
/Users/sh/projects/tests/delete_me/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported. Instead change the
require of .eslintrc.js in /Users/sh/projects/tests/delete_me/node_modules/@eslint/eslintrc/dist/eslintrc.cjs to a dynamic
import() which is available in all CommonJS modules.

ESlint related dependency versions:
image

In order to reproduce this issue, you can just initialise a Svelte project with having the eslint / prettier enabled, by running this:
npm init svelte@next.

PS project type set to module.

cc @mdjermanovic

Compat layer handles processors inconsistently

From #20 (comment)

In #20, the compat layer resolves file-extension processors, but not user-configured processors.

Because the flat config can override plugins, this kind of inconsistency causes problems.

import { FlatCompat } from "@eslint/eslintrc"
const compat = new FlatCompat()

export default [
  compat.extends("my-config"), // has `plugins: ["my-plugin"]`
  {
    plugins: {
      // Override my-plugin.
      "my-plugin": { ... }
    }
  }
]

The file-extension processors and the user-defined processors will come from different places.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.