Closed benore closed 6 months ago
I suspect that what you're seeing is from your shell doing the globbing (i.e. expanding the *.js
to be all the files matching instead), try adding echo
in front of npx
in your terminal and see if it shows the asterisk in the output
I think you misunderstood. This runs fine in the terminal. It's the plugin for gradle that craps out.
I had everything in a subfolder (/config/node/node_modules) and it was not working. but when I moved it to the project root, it worked. for some reason it seems to be causing a problem when it is not in the root. this is not a issue with eslint 7.12.1, but it is with 8.x and 9.x.
Of course moving it to the root isn't great either. The "files" and "ignores" attributes seems to be ignored in the root eslint.config.js.
It's not the plugin that's crapping out, what you're configuring in Gradle and what you're doing command-line is two separate things and the reason it works in your terminal is because your shell expands the *
for you. If you want to see how this looks, add an echo
before npx
and run it again in your terminal.
There's no post-processing done on the args, you'll need to tell eslint
what you want it to do, it looks to me like you'd want to point eslint
to the directory, but if you want to specify the exact files Gradle has a good documentation on working with files, the easiest is probably creating a fileTree
and filtering it before providing it as arguments.
I'd recommend giving eslint
a directory instead of a specific set of files, and configuring inputs/outputs so Gradle doesn't re-run the task if nothing has changed since the last time
I am using node 22, npx 10.5.1, eslint 9.1.1. For gradle, I am using gradle v6.8.3 (although I get the same results with 8.7). I am also using the plugin: com.github.node-gradle:gradle-node-plugin:7.0.2
When I run from the terminal, everything works as expected. With gradle I get the error below. Keep in mind, I don't have any ignore rules defined (eslintignore file or eslintIgnore properties) :
Terminal Command: npx eslint [pathto]/src//*.js --format html --config [pathto]/config/node/eslint.config.js --output-file [pathto]/build/reports/eslint/eslint.html
Gradle:
task prepareEslint { doLast { mkdir "$project.buildDir/reports/eslint" } }
// runs eslint task eslint(type: NpxTask, group: 'verification') { dependsOn prepareEslint command = 'eslint' args = [ "${project.projectDir}/src//*.js", "--config", "${project.projectDir}/config/node/eslint.config.js", "--format","html", "--output-file","${project.buildDir}/reports/eslint/eslint.html" ] ignoreExitValue = false }
I have successfully run this without error on the terminal, but I am stumped on why this isn't working with the same config file in gradle.