Bug: eslint cant load esm plugin
See original GitHub issueEnvironment
Node version: npm version: 16.15.0 Local ESLint version: 8.21.0 Global ESLint version: - Operating System: Ubuntu
What parser are you using?
Default (Espree)
What did you do?
Trying to load an esm plugin with new ESLint
and I can’t get it to work. Below should work according to documentation here.
Minimal Example
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { ESLint } from "eslint";
import bf from '@blackflux/eslint-plugin-rules';
import json from "eslint-plugin-json";
import mocha from "eslint-plugin-mocha";
const eslint = new ESLint({
cwd: dirname(fileURLToPath(import.meta.url)),
fix: false,
baseConfig: {
root: true,
extends: [
'airbnb-base',
'plugin:mocha/recommended',
'plugin:markdown/recommended'
],
rules: {
'@blackflux/rules/c8-prevent-ignore': 1
},
env: {
es6: true,
node: true,
mocha: true
},
globals: {},
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: false
},
plugins: [
{ id: '@blackflux/rules', definition: bf }
]
},
// we use glob on passed in files, due to https://github.com/eslint/eslint/issues/5623
ignore: false,
reportUnusedDisableDirectives: 'error'
});
const results = await eslint.lintFiles([
fileURLToPath(import.meta.url)
]);
But I’m getting The "path" argument must be of type string. Received an instance of Object
What did you expect to happen?
Eslint should load the plugin
What actually happened?
Eslint can’t load the plugin
Participation
- I am willing to submit a pull request for this issue.
Additional comments
No response
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Change Request: Support ESM plugins · Issue #15453 · eslint ...
I would like to see ESLint support the eslint-plugin for ESM. This will allow us to import Pure ESM packages from eslint-plugin with...
Read more >ESLint - Error: Must use import to load ES Module
I think the problem is that you are trying to use the deprecated babel-eslint parser, last updated a year ago, which looks like...
Read more >Getting Started with ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >[eslint] failed to load plugin 'prettier' declared in '.eslintrc.js'
[Error] Failed to load plugin 'prettier' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-prettier' Require stack ...
Read more >Using ES Modules (ESM) in Node.js: A Practical Guide (Part 3)
ESLint for linting, including the Node ESLint plugin ... (February 2021) has a bug where it thinks Node.js doesn't support await import(.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was talking about the comment after the one you linked. The last one in the ticket! It details that you can when using eslint programmatically
This isn’t a bug; eslint uses
require
, and you can’t require ESM. Additionally, ESM is async, and eslint plugins/configs must be sync.