eslint-plugin-require-extensions
eslint-plugin-require-extensions copied to clipboard
usage in eslint flat config
how to use it in the new eslint flat config
It appears to not even be importable because it is built in CommonJS. I get No "exports" main defined errors when trying to import anything from this package into an ESLint v9 flat config.
+1
https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config
https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config
Specifically, do this:
import {fileURLToPath} from 'node:url';
import {FlatCompat} from '@eslint/eslintrc';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
// ESM config export
export default [
...compat.plugins('require-extensions'),
...compat.extends('plugin:require-extensions/recommended'),
// rest of your config
]
The new @eslint/compat tool that's supposed to help migrate your .eslintrc incorrectly migrates this plugin, because it can't be imported.
You can still use compat.plugins, but you'll need to remove the import and fixupPluginRules call that is generated.
@jordaaash could you please please please upgrade this plugin to modern eslint v9? it's the only plugin that adds .js automatically
@mesqueeb @electrovir @guoh27 @speelbarrow @SeanMcMillan I've published a new package eslint-plugin-import-extensions