There isn't a complete tslint.json file in your documentation, nor an example of how to run tslint on a group of files (a project). So I tried guessing how to do it and wrote the below code and got an error:
Running
./node_modules/.bin/tslint -c tslint.json -e node_modules -e typings */**
with tslint.json configuration:
{
"rules": {
"boolean-trivia": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"eofline": true,
"label-position": true,
"label-undefined": true,
"indent": [
true,
"spaces"
],
"member-ordering": true,
"new-parens": true,
"next-line": [
true,
"check-catch",
"check-else"
],
"no-construct": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-increment-decrement": true,
"no-in-operator": true,
"no-internal-module": true,
"no-invalid-this": true,
"no-namespace": true,
"no-shadowed-variable": true,
"no-trailing-whitespace": true,
"no-use-before-declare": true,
"no-unused-variable": true,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-surrounding-space": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"one-variable-per-declaration": true,
"prefer-const": true,
"quotemark": [
true,
"single",
"avoid-escape"
],
"semicolon": [
true,
"always"
],
"trailing-comma": false,
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"type-operator-spacing": true,
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}
No errors
fs.js:651
var r = binding.read(fd, buffer, offset, length, position);
^
Error: EISDIR: illegal operation on a directory, read
at Error (native)
at Object.fs.readSync (fs.js:651:19)
at processFile (/home/rje/projects/ekaya/server/node_modules/tslint/lib/tslint-cli.js:114:12)
at Array.forEach (native)
at Object.<anonymous> (/home/rje/projects/ekaya/server/node_modules/tslint/lib/tslint-cli.js:141:41)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
Try surrounding your glob with quotes, "*/**" -- do you still get the error then?
I agree that we need better documentation about this.
I have the exact same configuration:
$ tslint -v
3.13.0
$ tsc -v
Version 1.8.10
$ node -v
v6.2.0
And the same issue:
$ tslint -c tslint.json -e typings "*/**"
fs.js:725
var r = binding.read(fd, buffer, offset, length, position);
^
Error: EISDIR: illegal operation on a directory, read
...
As you can see, I'm using quotes around the glob pattern.
The compiled TSLint code that fails is this:
var fd = fs.openSync(file, "r");
try {
fs.readSync(fd, buffer, 0, 256, null); // <-- oops
...
}
Quotes don't fix this error. Thanks for the suggestion.
The issue is that "*/**" will match all files and all directories - you only want to match all files I'm guessing. Try something like "**/*.ts" instead.
We could handle this scenario more gracefully though.
@JKillian thanks, that solved my issue :+1:
@JKillian's idea worked, but ts-lint still tried validating my node_modules and typings folders. So I then added quotes to everything and it all finally worked as expected.
Please will someone with rights on this project add this line to your homepage documentation on usage:
./node_modules/.bin/tslint -c "tslint.json" -e "node_modules/**/*" -e "typings/**/*" "**/*.ts*"
(The .ts* is so we can include .tsx, don't know how else to do it)
(Installing all npm modules locally is best practice. I disagree with the homepage saying install it using -g because then you have conflicts working on different versions of different projects with different people. Ideally you want to just clone a repo, go npm update, and then everything works without all these hidden installations.)
The matching is done via https://github.com/isaacs/node-glob so I think ./node_modules/.bin/tslint -c "tslint.json" -e "node_modules/**/*" -e "typings/**/*" "**/*.+(ts|tsx)" should work to get the correct extensions.
I got this error when there was a symlink in the file path that I was copying from. One I removed the symlink, it worked.
I got this error because a directory was had ".ts" in its name... arg
Most helpful comment
The issue is that
"*/**"will match all files and all directories - you only want to match all files I'm guessing. Try something like"**/*.ts"instead.We could handle this scenario more gracefully though.