Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

No valid rules have been specified #3735

Closed
redpandabytes opened this issue Feb 26, 2018 · 14 comments
Closed

No valid rules have been specified #3735

redpandabytes opened this issue Feb 26, 2018 · 14 comments

Comments

@redpandabytes
Copy link

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
Copy link

liangchunn 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
Copy link

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
}

@redpandabytes
Copy link
Author

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
Copy link

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

@redpandabytes
Copy link
Author

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

@ajcrites
Copy link
Contributor

@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
Copy link

@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
Also removed "allowJs" from tsconfig, tslint doesn't like it:
palantir/tslint#3735
@johnwiseheart
Copy link
Contributor

Closing this issue as it seems to be resolved.

@gkirill
Copy link

gkirill 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.

@sdakoju
Copy link

sdakoju 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
}
}

primiano pushed a commit to catapult-project/perfetto that referenced this issue Sep 5, 2019
This fixes the tslint warnings in the presubmit.
tslint was searching for js rules, but they were not specified in
tslint.json. With empty rules the problem persists, so I had to put
a single rule: palantir/tslint#3735

Bug: 140546666
Change-Id: I5f4b56cf6265ded92a8241d8f2a6cec2ea9441bc
@liranh85
Copy link

liranh85 commented Nov 18, 2019

If you don't want TSLint linting JS files (and you have tslint >= 5.8), simply add the following to your tslint.json:

"linterOptions": {
    "exclude": [
        "**/*.js"
    ]
}

@TaylorPzreal
Copy link

Add tslint --config tslint.js works for me.

@danvln
Copy link

danvln commented Jul 19, 2020

you need to specify the config file, like tslint -c .eslintrc.yml -p tsconfig.json, and there is nothing that's required from above like jsRules or all of those..

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants