Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No valid rules have been specified #3735

Closed
nattyxd opened this issue Feb 26, 2018 · 10 comments

Comments

@nattyxd
Copy link

commented Feb 26, 2018

Bug Report

  • TSLint version: 5.9.1
  • TypeScript version: 2.7.2
  • Running TSLint via: VScode on Mac, but fails on CLI too

With tslint.json configuration:

{
    "defaultSeverity": "none",
    "extends": [
        "tslint:recommended"
    ],
    "jsRules": {},
    "rules": {
        "no-internal-module": false,
        "typedef-whitespace": false,
        "variable-name": [
            true,
            "check-format",
            "allow-leading-underscore"
        ],
        "no-console": false,
        "no-reference": false,
        "no-namespace": false,
        "max-line-length": [true, 140],
        "no-bitwise": false,
        "align": true,
        "arrow-return-shorthand": true,
        "no-magic-numbers": true
    },
    "rulesDirectory": []
}

Actual behavior

Last week my tslint was working fine with the above configuration. Today I updated my VSCode, and TSLint started complaining that no compatible version of Typescript was installed. To fix this I did npm install -g typescript which fixed the TSLint version error.

The TSLint extension in VSCode gives the warning No valid rules have been specified, and doesn't lint anything.

I tried running tslint --project build from the CLI, but I get the same error.

I thought maybe tslint was looking for a global configuration file, but if I add a syntax error to my local tslint.json, I'll get a different error Unexpected token f, so it seems it is looking at the local config but then failing somehow

Expected behavior

TSLint should run over the project as it did before

@liangchunn

This comment has been minimized.

Copy link

commented Feb 26, 2018

I have the same issue coming from 5.8.0 to 5.9.1.

Running tslint --config tslint.json --project tsconfig.json spits the same No valid rules have been specified error.

tslint.json:

{
    "extends": ["tslint-config-prettier", "tslint-react"],
    "rules": {
        "ban": false,
        "class-name": true,
        "comment-format": [
            true,
            "check-space"
        ],
        "curly": true,
        "eofline": false,
        "forin": true,
        "interface-name": [true, "never-prefix"],
        "jsdoc-format": true,
        "jsx-no-lambda": false,
        "jsx-no-multiline-js": false,
        "label-position": true,
        "no-any": false,
        "no-arg": true,
        "no-bitwise": true,
        "no-console": [
            false,
            "log",
            "error",
            "debug",
            "info",
            "time",
            "timeEnd",
            "trace"
        ],
        "no-construct": true,
        "no-debugger": true,
        "no-duplicate-variable": true,
        "no-empty": true,
        "no-eval": true,
        "no-shadowed-variable": true,
        "no-string-literal": true,
        "no-switch-case-fall-through": true,
        "no-trailing-whitespace": false,
        "no-unused-variable": true,
        "no-unused-expression": true,
        "no-use-before-declare": true,
        "radix": true,
        "switch-default": true,

        "trailing-comma": [false],

        "triple-equals": [ true, "allow-null-check" ],
        "typedef": [
            true,
            "parameter",
            "property-declaration"
        ],
        "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"]
    }
}
@liangchunn

This comment has been minimized.

Copy link

commented Feb 26, 2018

I've found a possible solution:
If you're using setting "allowJs": true in tsconfig.json, it will try to find rules and jsRules from tslint.json.

If your jsRules is empty, it will complain. IMO the messages should indicate which rules it is actually parsing.

Adding a rule inside jsRules made the message go away.

"jsRules": {
    "no-empty": true
}
@nattyxd

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

I just tried adding:

"allowJs": true,
"jsRules": {
    "no-empty": true
}

To my tslint.json, but unfortunately the message stays, and it doesn't seem to lint anything still

@liangchunn

This comment has been minimized.

Copy link

commented Feb 26, 2018

What do you get on your output? If there’s no errors then it should be working fine.

@nattyxd

This comment has been minimized.

Copy link
Author

commented Feb 26, 2018

I get the same output/warning, changing it didn't do anything 😢

@ajcrites

This comment has been minimized.

Copy link
Contributor

commented Apr 20, 2018

@nattyxd did you add jsRules to your tsconfig or tslint.json? allowJs is in tsconfig; with allowJs your tslint.json is expecting some jsRules (hence the bug). A workaround would be to add "jsRules": { "no-empty": true } to your tslint.json so that it has a rule and doesn't complain. This shouldn't have any impact I think. It's just a small annoyance.

@liangchunn

This comment has been minimized.

Copy link

commented Apr 20, 2018

@ajcrites Absolutely on point. I think this issue should be closed.

eheikes added a commit to eheikes/finances-visualizer that referenced this issue Apr 23, 2018

chore(lint): Use tslint for linting
Also removed "allowJs" from tsconfig, tslint doesn't like it:
palantir/tslint#3735
@johnwiseheart

This comment has been minimized.

Copy link
Contributor

commented Jul 27, 2018

Closing this issue as it seems to be resolved.

@gkirill

This comment has been minimized.

Copy link

commented Feb 17, 2019

Several months ago I had this issue, then it was solved by the solution explained in this thread, and it was all okey for a while, but recently I started having this issue again, though I do have "no-empty": true. Banging my head and cannot figure out what could be the problem.

@msorens msorens referenced this issue Jun 17, 2019
2 of 4 tasks complete

SudharakaP added a commit to python-sinhala-education-society/OpenLearnr that referenced this issue Jun 19, 2019

@sdakoju

This comment has been minimized.

Copy link

commented Aug 8, 2019

I removed everything from tslint.json and added the following and seems to be working

{
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
"rules": {
"class-name": false,
"export-name": false,
"forin": false,
"label-position": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"variable-name": false,
"whitespace": false
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.