nx: Lint affected doesn't work after 14.2.4 => 14.3.* migration
Current Behavior
nx affected:lint --base=main fails with '_' is not found in schema error after 14.2.4 => 14.3.* migration.
Linting of individual libs working fine. With 14.2.4 version affected linting working fine too.
Expected Behavior
Lint works
Failure Logs
'_' is not found in schema
> NX Running target "lint" failed
Environment
Node : 16.14.2
OS : win32 x64
npm : 8.5.0
nx : 14.3.5
@nrwl/angular : 14.3.5
typescript : 4.7.3
---------------------------------------
Community plugins:
@storybook/angular: 6.5.9
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 20 (7 by maintainers)
Hi @gxxcastillo, the error I believe originates from @Phillip9587’s
nx-stylelint(if that is what yourstylelinttarget uses as an executor). I have created a PR that should fix this: https://github.com/Phillip9587/nx-stylelint/pull/336 but you will have to wait until Philip checks it, approves it, and releases a new version.Hi @meeroslav, thanks for your work on this issue. I see issues https://github.com/nrwl/nx/pull/10847, https://github.com/nrwl/nx/pull/10848, https://github.com/nrwl/nx/commit/6a65101ec239f1b3eae28734e4109b56a3700599, and https://github.com/nrwl/nx/issues/10806. I’ve updated to NX 14.4.0, and while I’m no longer getting
'_' is not found in schema, I am now gettingNX Schema does not support positional arguments. Argument <...list of files from my commit...>. Is this related to the same problem? Anything I need to do?I’m using lintstaged with eslint, stylelint, and prettier - in that order. Eslint is passing (it wasn’t before upgrading to 14.4.0) but things now break with stylelint.
This is what my linstagedrc looks like (this has been working for the last 6months):
This fix will be contained in the next version - either 14.4.0 or 14.3.7, whichever comes next.
Check this commit - https://github.com/nrwl/nx/commit/6a65101ec239f1b3eae28734e4109b56a3700599.
In the next version, you will be able to define
filesetpattern/glob per target to ensure target is affected only by a subset of files - e.g.buildshould not care aboutspecfiles, whiletestcares about both.Otherwise, you can always use params that underlying libraries (jest, estlint, etc.) define - linting just a single file or running tests that match a certain pattern.
Thanks, @sluger,
That helped me find the issue. The difference between running those two scripts is that
lint-stagedappends the path to the file, and the linter does not expect any positional parameters leading to an unfortunate error with a cryptic message.The same can be reproduced with:
I’ll look into a fix now.
Hi @meeroslav!
I have set up a minimal NX repo with Typescript React here: https://github.com/sluger/nx-issue-lint-affected
With versions and commands on MacOs 12.3.1 with nx version 14.3.6:
Steps to Reproduce
git clone git@github.com:sluger/nx-issue-lint-affected.gitnpm igit add .git committo trigger the lint-staged script in: https://github.com/sluger/nx-issue-lint-affected/blob/main/package.json#L57 or just run it directly vianpx lint-staged -dObserved Behavior
Running the linter without
lint-stagedhowever is successful:I suspect it has something to do with parsing the options of the command via
lint-staged. I have accidentally missed a dash on thebaseoption with a similar error message regarding the schema:Note I have set
NX_VERBOSE_LOGGING=truebut it dit not give me any additional output.Hi @ambeur, @its-ratikant, @jahusa02, @icastillejogomez,
Sorry for the inconvenience. Can one of you create a minimal repro or detailed steps on how can this be reproduced? I tried here https://github.com/meeroslav/test-10768 but I could not reproduce the error.
Additionally, there is no need to set
--base=mainas this is the default setting when running on your main branch locally.