According documentation nx lint should accept --files array like
nx lint --files=apps/main-app/src/main.tsx
Command fails to parse --files=apps/main-app/src/main.tsx
Schema validation failed with the following errors:
Data path ".files" should be array.
No special preparations required. Just run command in nx workspace.
yarn nx lint --files=apps/main-app/src/main.tsx
$ nx report
> NX Report complete - copy this into the issue template
@nrwl/angular : Not Found
@nrwl/cli : 8.11.0
@nrwl/cypress : 8.11.0
@nrwl/eslint-plugin-nx : 8.11.0
@nrwl/express : Not Found
@nrwl/jest : 8.11.0
@nrwl/linter : 8.11.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : 8.11.0
@nrwl/schematics : Not Found
@nrwl/tao : 8.11.0
@nrwl/web : 8.11.0
@nrwl/workspace : 8.11.0
typescript : 3.7.3
packages/tao/src/shared/params.ts#coerceTypes does not check for arrays
Same issue here
> NX Report complete - copy this into the issue template
@nrwl/angular : Not Found
@nrwl/cli : 9.1.1
@nrwl/cypress : 9.1.1
@nrwl/eslint-plugin-nx : 9.1.1
@nrwl/express : Not Found
@nrwl/jest : 9.1.1
@nrwl/linter : 9.2.3
@nrwl/nest : 9.1.1
@nrwl/next : 9.1.1
@nrwl/node : 9.1.1
@nrwl/react : 9.1.1
@nrwl/schematics : Not Found
@nrwl/tao : 9.1.1
@nrwl/web : 9.1.1
@nrwl/workspace : 9.1.1
typescript : 3.8.3
Also seeing this, both --files and --exclude.
yeah same here
@jeffbcross any chance we can get this fixed for the big W? :)
@FrozenPandaz is the decision-maker :)
@FrozenPandaz help me help you help Walmart. 馃檪
Fixed it here: https://github.com/nrwl/nx/commit/a6220f7b0a677dbceb72bc2434cfeac6e4f86061
Should be out in 9.4.
@vsavkin I downloaded the latest release 9.4.0-rc.6 and still not seeing this resolved when running as @zaverden showed: nx lint --files=apps/main-app/src/main.tsx. Is there another way we should be running this?
@vsavkin same here, we are on 9.4.0 and it still reports the same error

@vsavkin it's because we are remapping the args back to the cmd line here: https://github.com/nrwl/nx/blob/7b27ba4daa5185dac63e52f726f75f8b5bf5ec7a/packages/workspace/src/tasks-runner/task-orchestrator.ts#L316
Any suggestions?
Same issue even with 9.5.0. Any news?
@vsavkin any updates on this? really need this for lint-staged.
Hi folks, so to shed some light on this issue, ... it's actually not an issue :)
nx lint needs project name. Without project name it won't worknx lint my-project --files=**/some-folder/** which will run lint on libs/my-project/src/lib/some-folder/**--files accepts a globin that case, @Hotell can you give a recommendation for how to use lint staged with nx? ultimately that's the goal here for me at least. like can we do nx affecte:lint --files=**/foo?
in that case, @Hotell can you give a recommendation for how to use lint staged with nx? ultimately that's the goal here for me at least.
use raw binary :)
eslint --fix
@vsavkin any updates on this? really need this for lint-staged.
I am unable to use raw library as @Hotell mentioned, since all libraries don't have the same tslint configuration.
So I've came up with following solution:
As mentioned in documentation, you can use custom lint function. So I created a script that works like this:
First, load angular.json file, parse it (it's super easy since it's just a json) and store all projects with configured lint tasks (path to lint task in json structure is /projects/*your-project*/architect/lint) in a variable.
Then I try to assign staged files to their projects. It's also easy, because each project has root path (is /projects/*your-project*/root path in json). So I go through all staged files and check that file path starts with any project root path.
After this part, I have array of projects with (staged) files that belongs to these projects.
For each project, I create command ./node_modules/@angular/cli/bin/ng run *your-project*:lint --files libs/*your-project*/src/lib/a.ts --files libs/*your-project*/src/lib/b.ts --files libs/*your-project*/src/lib/c.ts
And finally, I use concurrently to run all these lint commands together.
I know, that isn't ideal nor easy solution, but it's the only way I've found, how to get lint-staged work with multiple projects without linting all files.
@junekpavel interesting. Can you share the script or an example? Many thanks in advance
I believe usual case here is nx lint with eg jest with -affected flag
@Lonli-Lokli If I change a single file then affected:lint is going to lint whole lib and it's dependencies. It may be great if it works this way in CI, but for pre-commit hook I don't want to relint whole project, only changed files to make it fast. that's why I want to use --files flag
@zaverden lint-staged pass array of staged files to the underlined command so I don't know why --files required.
@Lonli-Lokli I'm not sure I've got your point. yes, lint-staged pass list of staged files to command as plain list.
So if my command is eslint --fix then lint-staged calls it as eslint --fix path/to/file1 path/to/file2 and it works because this is how eslint expects to get list of files to lint.
if my command is nx affected:lint --fix then lint-staged calls it as nx affected:lint --fix path/to/file1 path/to/file2. and nx just ignores these paths because this is not how it expect to get a list of paths
Most helpful comment
@vsavkin any updates on this? really need this for lint-staged.