4.0.22.1.4// Example
// It should complain about argument type and return type for the function
function test(arg) {
console.info('I'm just testing ...');
}
with tslint.json configuration:
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules" : {
// TS Specific
"member-access": false,
"member-ordering": [true, { "order": "statics-first" }], // http://palantir.github.io/tslint/rules/member-ordering/
"no-any": false,
"no-inferrable-types": [true, "ignore-params"],
"no-internal-module": true,
"no-namespace": [true, "allow-declarations"],
"no-reference": true,
"no-var-requires": true,
"only-arrow-functions": [true, "allow-declarations"],
"prefer-for-of": true,
"typedef": [true, "call-signature", "parameter", "property-declaration", "member-variable-declaration"], // http://palantir.github.io/tslint/rules/typedef/
"typedef-whitespace": [true, {
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}],
// Style
"align": [true, "parameters", "statements"],
"arrow-parens": true,
"array-type": [true, "array"],
"class-name": true,
"comment-format": [true, "check-space"],
"jsdoc-format": true,
"new-parens": true,
"no-consecutive-blank-lines": false,
"object-literal-key-quotes": [true, "consistent"],
"object-literal-shorthand": true,
"one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace"],
"one-variable-per-declaration": [true, "ignore-for-loop"],
"ordered-imports": [false, {
"import-sources-order": "lowercase-last",
"named-imports-order": "lowercase-last"
}],
"quotemark": [true, "single"],
"semicolon": true,
"variable-name": [true, "check-format", "allow-leading-underscore", "allow-pascal-case", "ban-keywords"],
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type",
"check-typecast"
],
// Maintainability
"eofline": true,
"indent": [true, "tabs"],
"linebreak-style": [true, "LF"],
"max-classes-per-file": [true, 3],
"max-file-line-count": [true, 300],
"max-line-length": [true, 240],
"no-default-export": true,
"no-mergeable-namespace": true,
"no-require-imports": true,
"no-trailing-whitespace": true,
"object-literal-sort-keys": false,
"trailing-comma": [true, {
"multiline": "never",
"singleline": "never"
}],
// Functionality
"curly": true,
"forin": true,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": [true, "debug", "log", "trace"],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-eval": true,
"no-invalid-this": true,
"no-string-literal": true,
"no-switch-case-fall-through": true,
"no-unused-expression": true,
"no-unused-new": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"radix": true,
"switch-default": true,
"triple-equals": [true, "allow-null-check", "allow-undefined-check"],
"use-isnan": true,
// Angular 2 Styleguide
// Check https://github.com/mgechev/codelyzer for more info and rules.
// https://angular.io/styleguide
"directive-selector": [true, "attribute", "rj", "camelCase"],
"component-selector": [true, "element", "rj", "kebab-case"],
"pipe-naming": [true, "camelCase", "rj"],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-attribute-parameter-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"no-forward-ref": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": [true, "Component"],
"directive-class-suffix": [true, "Directive"],
"import-destructuring-spacing": false,
"templates-use-public": true,
"no-access-missing-member": true,
"invoke-injectable": true
}
}
When I run tslint via npm scripts as npm run lint:
"scripts": {
"lint": "tslint src/**/*.ts -c ./tslint.json -s node_modules/tslint-stylish -t stylish"
}
Nothing is being printed to stdout. Though, if I run the command as standalone, it works as expected.
It should print to stdout.
This also happens if I run the same command from a Makefile:
# Run tests
lint:
tslint src/**/*.ts -c ./tslint.json -s node_modules/tslint-stylish -t stylish
@rolandjitsu where is聽example file located? directly聽in src folder?
Try to add quotes around聽glob
"scripts": {
"lint": "tslint \"src/**/*.ts\" -c ./tslint.json -s node_modules/tslint-stylish -t stylish"
}
@IllusionMH note that with TS 2.0.10 it works as expected. So it might be because of something TS introduced with 2.1.
Adding quotes worked for me. Thanks @IllusionMH
Is this a bug or a feature that we have to add quotes?
@screendriver in your case this may be related on difference in聽how OS expands gobs.聽If聽glob is passed into npm script聽without quotes it may be expanded by OS and聽TSLint will receive only list of files and not glob directly.
Some聽OS with default settings parse src/**/*.ts and will find src/folder/nested.ts but not src/without-nesting.ts. Ttherefore聽TSLint won't receive and聽check聽those files.
If you pass globs in quotes (TSLint support both double and single quotes in npm scripts, but double quotes are preferred) than glob will be processed with glob npm module and will聽match聽all聽files in src folder聽independent from nesting level.
Thank you for the explanation.
I can confirm that the quotes fix the issue.
Sadly this does not fix the issue in every case. :(
Most helpful comment
@rolandjitsu where is聽example file located? directly聽in
srcfolder?Try to add quotes around聽glob