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

'ignored' option badly handled in file-name-casing #4836

Closed
stasberkov opened this issue Aug 22, 2019 · 8 comments · Fixed by #4848
Closed

'ignored' option badly handled in file-name-casing #4836

stasberkov opened this issue Aug 22, 2019 · 8 comments · Fixed by #4848

Comments

@stasberkov
Copy link

stasberkov commented Aug 22, 2019

Bug Report

  • TSLint version: 5.19
  • TypeScript version: 3.2
  • Running TSLint via: CLI

Reproduction

Try using file-name-casing having ignored option.
TSLint will show you a warning Warning: file-name-casing - Unexpected casing option provided: ignored.
This is because of line https://github.com/palantir/tslint/blob/master/src/rules/fileNameCasingRule.ts#L87
since validCasingOptions does not contian 'ignored' option. Since line https://github.com/palantir/tslint/blob/master/src/rules/fileNameCasingRule.ts#L43 misses it.

tslint.yaml:

rules:
    file-name-casing: [true, {"AppComponent.ts": "ignored", ".*": "kebab-case" } ]

Tried using like in here https://palantir.github.io/tslint/rules/file-name-casing/

"file-name-casing": [true, {".ts": "ignored", ".tsx": "pascal-case"}]

Actual behavior

ignored option claimed in docs but cannot be used.

Expected behavior

ability to use ignored option.

@adidahiya
Copy link
Contributor

Can you paste your exact tslint config? It's hard to tell if it's a config error or a bug in the rule.

@stasberkov
Copy link
Author

I updated issue text.

rules:
    file-name-casing: [true, {"AppComponent.ts": "ignored", ".*": "kebab-case" } ]

Tried using like in here https://palantir.github.io/tslint/rules/file-name-casing/

"file-name-casing": [true, {".ts": "ignored", ".tsx": "pascal-case"}]

@adidahiya
Copy link
Contributor

It looks like we have some tests for the ignored option, so in theory it should be working. Can you try a slightly different yaml config syntax?

rules:
  file-name-casing:
  - true
  - ".ts": ignore
    ".tsx": pascal-case

@stasberkov
Copy link
Author

ignore or ignored?

@adidahiya
Copy link
Contributor

Ah, sorry, it should be ignored. I read through your OP again and it looks like there were some bugs in #4204... validCasingOptions should be fixed to contain the new ignored option, and the example in test/rules/file-name-casing/ignore/tslint.json should be fixed to match the documentation & rule implementation.

@tanmoyopenroot
Copy link
Contributor

Hi @adidahiya ,
I was looking into the code and i am not sure it might be a bug.
Lets consider the following config

{
    "rules": {
        "file-name-casing": [
            true,
            {
                ".ts": "kebab-case",
                ".compoent.ts": "camel-case"
            }
        ]
    }
}

And there are two files file-test.ts and file.testComponent.ts.
file-test.ts will pass as it satisfy the conditions
file.testComponent.ts will product an error saying 'It should be in kebab-case' but it should pass the test as condition was satisfied.

But if i consider this config for the same files file-test.ts and file.testComponent.ts.

{
    "rules": {
        "file-name-casing": [
            true,
            {
                ".compoent.ts": "camel-case",
                ".ts": "kebab-case",
            }
        ]
    }
}

file-test.ts:- will pass as it satisfy the conditions
file.testComponent.ts:- it will pass

Its because of this line
It only checks for first matching pattern.

So do i need to write more strict regex in the config file or is it a bug in the code?

@adidahiya
Copy link
Contributor

@tanmoyopenroot that issue is separate from the one reported here. you need a more strict regex.

I opened a PR for the ignored issue: #4848

@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants