[BUG] Action unable to handle additional `.eslintrc.yml` in NPM workspaces
1337MARCEL opened this issue · 7 comments
Is there an existing issue for this?
- I have searched the existing issues
Does this issue exist in the latest version?
- I'm using the latest release
Describe the bug?
We use NPM workspaces for our design library.
Yesterday we tried to add a new component to design library but got a bunch of false errors made by the eslint-changed-files
action. I suspect it didn't load the additional .eslintrc.yml
that's in the design library directory which simply extends the .eslintrc.yml
in our root directory and overwrites the import/resolver
setting to the correct path.
To Reproduce
I created a repo that you can use to reproduce and hopefully resolve the issue. You can find the failed workflow run here.
What OS are you seeing the problem on?
ubuntu-latest or ubuntu-20.04
Expected behavior?
The only ESLint error I expect is
/Users/marcel/kode/temp/eslint-changed-files-repo/src/pages/api/hello.mjs
4:3 error Unexpected console statement no-console✖ 1 problem (1 error, 0 warnings)
Relevant log output
eslint-changed-files
{"ruleId":"import/namespace","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-duplicates","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-unresolved","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/default","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-named-as-default","severity":1,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-named-as-default-member","severity":1,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-unresolved","severity":2,"message":"Unable to resolve path to module 'react'.","line":1,"column":19,"nodeType":"Literal","endLine":1,"endColumn":26}
{"ruleId":"import/namespace","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-duplicates","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-unresolved","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/named","severity":2,"message":"Resolve error: unable to load resolver \"build-scripts/eslint-resolver.cjs\".","line":1,"column":1,"nodeType":null}
{"ruleId":"import/no-unresolved","severity":2,"message":"Unable to resolve path to module './CoolTitle'.","line":1,"column":27,"nodeType":"Literal","endLine":1,"endColumn":40}
Anything else?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Based on the error this appears to be an invalid configuration and not a bug with the action. I left a comment on the repo with a possible resolution.
Hey @jackton1,
First of all, thanks for looking into it.
I think I corrected the configuration but unfortunately the action still fails.
The path to the import resolver path should be accurate, see screenshots attached below highlighted in red.
GitHub workflow run locally with act
GitHub workflow run on GitHub workers
Regular eslint
run locally via NPM script
Is there a chance you could look into it?
[Run linter/lint] ✅ Success - bash $GITHUB_ACTION_PATH/entrypoint.sh
[Run linter/lint] ⚙ ::set-output:: any_modified=true
[Run linter/lint] ⚙ ::set-output:: other_modified_files=.eslintrc.yml .github/workflows/run-lint.yml .gitignore
[Run linter/lint] ⚙ ::set-output:: other_deleted_files=.eslintrc.yml
[Run linter/lint] ⚙ ::set-output:: added_files=.eslintrc.cjs
[Run linter/lint] ⚙ ::set-output:: deleted_files=
[Run linter/lint] ⚙ ::set-output:: type_changed_files=
[Run linter/lint] ⚙ ::set-output:: unmerged_files=
[Run linter/lint] ⚙ ::set-output:: any_changed=true
[Run linter/lint] ⚙ ::set-output:: only_changed=false
[Run linter/lint] ⚙ ::set-output:: other_changed_files=.github/workflows/run-lint.yml .gitignore
[Run linter/lint] ⚙ ::set-output:: only_modified=false
[Run linter/lint] ⚙ ::set-output:: only_deleted=false
[Run linter/lint] ⚙ ::set-output:: copied_files=
[Run linter/lint] ⚙ ::set-output:: modified_files=my-design-library/.eslintrc.cjs
[Run linter/lint] ⚙ ::set-output:: renamed_files=
[Run linter/lint] ⚙ ::set-output:: unknown_files=
[Run linter/lint] ⚙ ::set-output:: all_changed_and_modified_files=.eslintrc.cjs my-design-library/.eslintrc.cjs
[Run linter/lint] ⚙ ::set-output:: any_deleted=false
[Run linter/lint] ⚙ ::set-output:: all_changed_files=.eslintrc.cjs my-design-library/.eslintrc.cjs
[Run linter/lint] ⚙ ::set-output:: all_modified_files=.eslintrc.cjs my-design-library/.eslintrc.cjs
[Run linter/lint] ✅ Success - Get changed files
[Run linter/lint] ⭐ Run Run eslint on changed files
[Run linter/lint] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/3-composite-eslint-changed-files.sh] user= workdir=
[Run linter/lint] ❓ ::group::eslint-changed-files
| TESTING /Users/tonyejack/workspaces/eslint-changed-files-repo/build-scripts/eslint-resolver.cjs
| TESTING /Users/tonyejack/workspaces/eslint-changed-files-repo/build-scripts/eslint-resolver.cjs
| TESTING /Users/tonyejack/workspaces/eslint-changed-files-repo/build-scripts/eslint-resolver.cjs
| TESTING /Users/tonyejack/workspaces/eslint-changed-files-repo/build-scripts/eslint-resolver.cjs
|
| /Users/tonyejack/workspaces/eslint-changed-files-repo/.eslintrc.cjs
| 5:1 error Unexpected console statement no-console
|
| /Users/tonyejack/workspaces/eslint-changed-files-repo/my-design-library/.eslintrc.cjs
| 5:1 error Unexpected console statement no-console
|
| ✖ 2 problems (2 errors, 0 warnings)
|
[Run linter/lint] ❓ ::endgroup::
[Run linter/lint] 🚧 ::warning::Error running eslint.
[Run linter/lint] ❌ Failure - Run eslint on changed files
[Run linter/lint] exit with `FAILURE`: 1
[Run linter/lint] ❌ Failure - Run ESLint on changed files
[Run linter/lint] exit with `FAILURE`: 1
Error: Job 'lint' failed
Using
.eslintrc.cjs
const path = require('path');
const resolverPath = path.resolve(__dirname, 'build-scripts', 'eslint-resolver.cjs');
console.log('TESTING', resolverPath);
module.exports = {
root: true,
env: {
browser: true,
node: true,
es2021: true
},
parserOptions: {
ecmaVersion: 2022,
sourceType: "module",
ecmaFeatures: {
jsx: true
},
},
extends: [
"eslint:recommended",
"plugin:import/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
],
rules: {
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"no-console": "error",
"react/prop-types": "off"
},
settings: {
'import/resolver': resolverPath,
"react": {
version: "detect",
}
},
};
@jackton1 aah got it, you're the man! I'm still confused why ESLint worked locally with my previous configuration lol.
Thanks for the quick assistance on a Saturday, I appreciate your work!
@1337MARCEL Your welcome don’t forget to star this project. Thanks