Issue with eslint-plugin-import with eslint 8.2.0
dbibbens opened this issue · comments
Issue Type
Bug
Issue Description
this bug when i have plugin:import/recommended in the extends of my .eslintrc.js,
Failed to load plugin 'import' declared in '.eslintrc.js': Invalid URL: eslintrc.cjs
Atom version: 1.58.0
linter-eslint version: 9.0.0
ESLint version: 8.2.0
Hours since last Atom restart: 3.3
Platform: darwin
Using local project ESLint from: /Users/db/winering/hosted-recs/node_modules/eslint
Current file's scopes: [
"source.js",
"meta.delimiter.period"
]
linter-eslint configuration: {
"autofix": {
"fixOnSave": true,
"ignoreFixableRulesWhileTyping": false,
"rulesToDisableWhileFixing": []
},
"disabling": {
"disableWhenNoEslintConfig": false,
"rulesToSilenceWhileTyping": []
},
"scopes": [
"source.js",
"source.jsx",
"source.js.jsx",
"source.flow",
"source.babel",
"source.js-semantic"
],
"lintHtmlFiles": false,
"global": {
"useGlobalEslint": false,
"eslintrcPath": "",
"globalNodePath": ""
},
"advanced": {
"disableEslintIgnore": false,
"disableFSCache": false,
"showRuleIdInMessage": true,
"eslintRulesDirs": [],
"localNodeModules": ""
}
}
var path = require('path');
module.exports = {
root: true,
env: {
browser: true,
commonjs: true,
es2021: true,
},
globals: {
_: false,
angular: false,
$: false,
location: false,
jQuery: false,
Swal: false,
EXIF: false,
__ENV__: false,
},
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 12,
allowImportExportEverywhere: true,
},
settings: {
'import/resolver': {
alias: [
['COMPONENT', path.resolve('src/components')],
['API', path.resolve('src/api')],
['ASSETS', path.resolve('assets')],
['APPS', path.resolve('src/apps')],
['APP', path.resolve('src/app')],
['DATA', path.resolve('src/data')],
['UTILS', path.resolve('src/utils')],
['VENDOR', path.resolve('vendor')],
],
},
'import/extensions': [
'.js',
'.jsx',
],
},
extends: [
'eslint:recommended',
'plugin:jsx-a11y/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
// 'plugin:import/recommended',
// 'plugin:prettier/recommended',
],
plugins: ['arca', 'react', 'jsx-a11y'],
rules: {
// 'arca/import-align': 2,
// 'arca/import-ordering': 2,
'brace-style': ['error'],
camelcase: 0,
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],
'func-names': ['off'],
'global-require': 0,
'guard-for-in': 0,
indent: ['error', 2],
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/label-has-for': 0,
'jsx-a11y/label-has-associated-control': 0,
'jsx-a11y/media-has-caption': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/no-static-element-interactions': 0,
'max-len': [
'error',
{
code: 140,
tabWidth: 4,
ignoreComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
'new-cap': 0,
'no-fallthrough': 0,
'no-multi-spaces': [
'error',
{
exceptions: {
ImportDeclaration: true,
VariableDeclarator: true,
},
},
],
'no-param-reassign': 0,
'no-plusplus': [
1,
{
allowForLoopAfterthoughts: true,
},
],
'no-restricted-syntax': ['error', 'ForOfStatement', 'LabeledStatement', 'WithStatement'],
'no-tabs': 0,
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
// 'no-restricted-imports': [2, {
// 'patterns': ['.*'],
// }],
// 'no-restricted-modules': [2, {
// 'patterns': ['.*'],
// }],
'no-underscore-dangle': [
1,
{
allow: ['__REDUX_DEVTOOLS_EXTENSION__', '_isMounted'],
},
],
'no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
},
],
'no-unused-vars': 1,
'no-use-before-define': 0,
'no-var': ['off'],
'object-shorthand': ['off'],
'prefer-arrow-callback': ['off'],
'prefer-destructuring': [
'error',
{
object: true,
array: false,
},
],
'prefer-template': ['off'],
// 'prettier/prettier': [
// 'error',
// {
// singleQuote: true,
// bracketSpacing: true,
// tabWidth: 2,
// printWidth: 200,
// },
// ],
quotes: ['error', 'single'],
radix: 0,
'react/destructuring-assignment': 0,
'react/jsx-curly-spacing': [
2,
{
when: 'always',
spacing: {
objectLiterals: 'never',
},
},
],
'react/jsx-filename-extension': [
'error',
{
extensions: ['.js'],
},
],
'react/jsx-indent': [
2,
2,
{
checkAttributes: true,
},
],
'react/jsx-indent-props': [2, 2],
'react/no-access-state-in-setstate': 0,
'react/no-did-update-set-state': 0,
'react/sort-comp': ['off'],
'space-before-function-paren': 0,
'space-before-blocks': 0,
'vars-on-top': ['off'],
},
};
"@babel/core": "7.16.0",
"@babel/eslint-parser": "^7.16.3",
"@babel/plugin-proposal-class-properties": "7.16.0",
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-transform-runtime": "7.16.0",
"@babel/preset-env": "7.16.0",
"@babel/preset-react": "7.16.0",
"@svgr/webpack": "^5.5.0",
"autoprefixer": "10.4.0",
"babel-loader": "8.2.3",
"babel-plugin-wildcard": "7.0.0",
"babel-preset-env": "^1.7.0",
"copy-webpack-plugin": "9.1.0",
"css-loader": "6.5.1",
"cssnano": "5.0.10",
"eslint": "8.2.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-arca": "^0.13.3",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0",
"file-loader": "6.2.0",
"html-loader": "^3.0.1",
"html-webpack-inline-svg-plugin": "^2.3.0",
"html-webpack-plugin": "5.5.0",
"mini-css-extract-plugin": "^2.4.4",
"node-sass": "^6.0.1",
"node-sass-tilde-importer": "1.0.2",
"path": "0.12.7",
"postcss": "8.3.11",
"postcss-flexbugs-fixes": "5.0.2",
"postcss-import": "14.0.2",
"postcss-loader": "6.2.0",
"postcss-preset-env": "^6.7.0",
"postcss-scss": "4.0.2",
"postcss-url": "^10.1.3",
"resolve-url-loader": "^4.0.0",
"run-sequence": "2.2.1",
"sass-loader": "12.3.0",
"source-map-loader": "3.0.0",
"style-loader": "3.3.1",
"terser-webpack-plugin": "^5.2.5",
"url-loader": "4.1.1",
"webpack": "^5.64.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.4.0",
"webpack-merge": "^5.8.0",
"webpack-remove-empty-scripts": "^0.7.1",
"webpack-stream": "7.0.0",
"yargs": "17.2.1"
I think this is an issue with the version of node bundled with Atom. There is nothing we can do until Atom updates electron.
Run into the same issue when setting up a new computer. The command-line eslint works but it errors in Atom.
Error while running ESLint: Failed to load plugin 'import' declared in '.eslintrc.js » eslint-config-airbnb-base » PATH/node_modules/eslint-config-airbnb-base/rules/imports.js': Invalid URL: eslintrc.cjs.
Not the right answer, but the Atom plugin mostly works if we comment out the fault: sed -i '' "s/'import'/\/\/ 'import'/g" node_modules/eslint-config-airbnb-base/rules/imports.js
.
For the right answer, I'm not an expert but think @UziTech is right. Looking with grep -rl eslintrc.cjs PATH
shows the URL target in an expected directory (node_modules/@eslint/eslintrc/dist/eslintrc.cjs
) but no config references within node_modules
.
This is also an issue with @typescript-eslint
.
I can confirm that this is still an issue in Atom 1.59 with v9.0.0 of this plugin.
In a brand new Vue-project initialised with npm init vue@latest
linting works fine from the CLI, but Linter ESLint fails in Atom. When the "Disable when no ESLint config is found" option is active, no linting takes place at all and no errors are thrown. If this option is disabled, I get an error on the first line of every *.js
file:
Error while running ESLint: Failed to load plugin 'vue' declared in '.eslintrc.cjs': Invalid URL: eslintrc.cjs.
I played around with some minimal examples (just a project with nothing but ESLint 8.8.0 and a config) and as soon as there’s a plugin like eslint-plugin-import
or eslint-plugin-vue
this error happens in the editor, but not when running through the CLI.
Here’s the Atom-version I’m running:
Atom : 1.59.0
Electron: 9.4.4
Chrome : 83.0.4103.122
Node : 12.14.1
Hi. Same issue here. Does it exists a workaround (different than downgrading eslint) ?
Downgraded to ESLint 7 in local package.json, and it works again.
.eslintrc.json
{
"env": {
"browser": true,
"es2020": true,
"node": false
},
"extends": [
"next/core-web-vitals"
],
"parserOptions": {
"ecmaFeatures": {
"modules": true,
"jsx": true
},
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"semi": [2, "always"]
}
}
We just released linter-eslint-node which should work with eslint v8. We created a new package for this because it required many breaking changes and we want people using linter-eslint successfully with older versions of eslint to be able to continue using it.