question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: `filename-case` Pascal case, ignore extensions or consider long extensions

See original GitHub issue

Currently with filename-case it lints every part of the filename before the final extension. So if I select pascalCase and write a file Button.test.ts it will error because test is not Test. I personally prefer to see test in lower case and Button as Pascal case, but this is not currently possible with the rule options supplied.

It would be nice to either disable the rule to the right of the first . or specify that part should be lowercase. Maybe a lint setting as unicorn/extension as ‘long’ or ‘short’ would be a nice way to categorize which part of the filename to consider the name vs the extension.

What setting would process to for linting long: { name: ‘Button’, extension: ‘.test.ts’ } short: { name: ‘Button.test’, extension: ‘.ts’ }

Fail

Button.Test.tsx

Pass

Button.test.tsx

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
sindresorhuscommented, Sep 17, 2021

@fisker I think the rule should just ignore anything after the last two dots. There could be other patterns too, like Foo.config.js. We don’t want to have to manually maintain a list.

2reactions
sindresorhuscommented, Sep 17, 2021

Actually, maybe we can just make Button.test.ts allowed by default and see if anyone complains. I have never seen the format Button.Foo.ts used before. I think a secondary file extension is almost always used as a classifier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-unicorn/filename-case.md at main - GitHub
This rule is enabled in the ✓ recommended config. Enforces all linted files to have their names in a certain case style and...
Read more >
file-name-casing - Rule
Rule : file-name-casing. Enforces a consistent file naming convention. Rationale. Helps maintain a consistent style across a file hierarchy. Config.
Read more >
LimagitoXI File Mover
This software offers quite a few features that make the program very flexible and useful for a variety of file management tasks as...
Read more >
eslint-config-ash-nazg - npm
See index.js (and node.js for ash-nazg/node rules) for the rules we ... In ESLint 7 it is no longer necessary to pass the...
Read more >
Issuehunt
Rule proposal : Improvement for filename-case rule #1745 ... main file extensions ( .ts and .spec.ts ) and each one use a different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found