Is there a linter for filenames? #5091
-
Reading the following blogpost I would like to ask if there is a linter in place to lint filenames (and is this is even in scope of golangci-lint)? TL; DR: the author presents an opportunity of naming a go file in a way that shows like a test file, but in fact isn't. This is possible by using non-ascii characters for example. For simplicity I'd like to have the possibility to restrict filenames in my repo to have only ASCII characters. (Many thanks in advance for your answers!) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hello, There is no linter about that. I don't think a linter will help here because IMO this hack should be done inside a dependency to be effective like the Jia Tan approach. ASCII is very limited, and the world is full of non-English languages, so this restriction can be a problem more than a solution. |
Beta Was this translation helpful? Give feedback.
-
Hmm, if I were a repository maintainer, I still would not want anyone to be able to commit malicious test files, the latter being reviewed rather poorly in general. Additionally, I have never seen non-english characters in filenames. That being said, that is just my limited experience and I do see the problems that might come with it. Thank you for your explanation! |
Beta Was this translation helpful? Give feedback.
-
For me this kind of linter often needs to lint more than .go files, so golangci-lint won't be the best candidate to support this. Anyway, I would like to suggest you to take a look at this project https://github.com/loeffel-io/ls-lint This project is great and maintained (hi @loeffel-io 👋) It would allow limiting yourself to ASCII characters, prevent spaces, expect no dash in filenames… There is also a GitHub action to run the validation when needed. It's my number one recommendation for what you might be looking for. |
Beta Was this translation helpful? Give feedback.
-
Follow-up A rule was added to revive about the non-ASCII characters in filenames |
Beta Was this translation helpful? Give feedback.
Hello,
There is no linter about that.
I don't think a linter will help here because IMO this hack should be done inside a dependency to be effective like the Jia Tan approach.
ASCII is very limited, and the world is full of non-English languages, so this restriction can be a problem more than a solution.