loeffel-io / ls-lint Goto Github PK
View Code? Open in Web Editor NEWAn extremely fast directory and filename linter - Bring some structure to your project filesystem
Home Page: https://ls-lint.org
License: MIT License
An extremely fast directory and filename linter - Bring some structure to your project filesystem
Home Page: https://ls-lint.org
License: MIT License
Hey great tool, keep up the good work!
In our project, we use a specific convention for naming files. We combined kebabcase and pointcase, so files are named like user-list.component.ts. Is it possible for ls-lint to check for this pattern?
Hi, what would the regex be to allow a file called [id].tsx
?
Many thanks
If I have setup
ls:
src/pages:
.tsx: PascalCase | regex:^_.*
ignore:
- index.tsx
- src/**/index.tsx
I would have expected the creation of a index.tsx
within src/pages
to be OK as it's an ignored pattern but it gets caught by the PascalCase | regex:^_.*
rule.
I can get around this by using
ignore:
- index.tsx
- src/pages/index.tsx
Maybe globs aren't recognised in the ignore list?
Hey, I would like to add this package to my project.
However, it's a big project and I want to make the migration slow-but-steady.
Is there any way to add "warn" rule like eslint just until we migrate all the badly named files/folders?
It would be cool if this would have a check to ensure that a directory/file exists!
@ls-lint/[email protected]: The CPU architecture "arm64" is incompatible with this module.
When I was installing ls-lint with yarn this message showed and I was failed to install ls-lint.
node version 15.3.0
Thanks for the ls-lint tool. ๐
I have following .ls-lint.yml
ls:
.js: lowercase | kebabcase
src/components/:
.dir: pascalcase
.jsx: pascalcase
src/pages:
.jsx: kebabcase
.storybook:
.js: lowercase
ignore:
- .git
- node_modules
- .cache
- public
- storybook-static
- .husky
- dist
- flow-typed/npm/
I am getting following error
<Project Name>/flow-typed/npm/react-dom_v17.x.x.js
31:20 error Identifier 'unstable_batchedUpdates' is not in camel case camelcase
40:20 error Identifier 'unstable_renderSubtreeIntoContainer' is not in camel case camelcase
Here is the react-dom_v17.x.x.js
Hi!
First of all, I'd like to say that I love this! Exactly what I was looking for! Thanks!
One feature that seems to be missing (or would be great to have) is the option to set a general rule for all files. Specifically to say that all files and folders should be lowercase, regardless of their extension.
It seems that something like this isn't possible:
ls:
.*: lowercase
.dir: kebab-case
.js: kebab-case
...
Correct?
The alternative would be to find out what extensions are in a project and what extensions could come up in the future, which isn't really feasible.
Or do you have another idea?
Thanks in advance!
P.S. One could, of course, run something like this to find all files and folders that have uppercase letters in them:
find . -path ./node_modules -prune -false -o -name "*[[:upper:]]*"
But depending on the number of folders to ignore, this can quickly get pretty messy.
After moving to a Macbook with Apple M1 chip the installation of npm package is failing with the following message:
yarn install v1.22.10
[1/5] ๐ Validating package.json...
[2/5] ๐ Resolving packages...
[3/5] ๐ Fetching packages...
error @ls-lint/[email protected]: The CPU architecture "arm64" is incompatible with this module.
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
node's process.arch
is giving me 'arm64'
, I'm on macOS 11.4 and node v14.17.3.
Any advice? I see there are some CPU restrictions on the package.json, but theoretically it should work?
Possibly related issues:
lovell/sharp#2460
gridsome/gridsome#1411
Thank you for 100 000 NPM Downloads! The project is growing constantly and we are starting the development of v2 soon!
Planned features:
|
operator with a ongoing and trailing whitespace to support the regex alternation operator #34 โ
exists
+ not_exists
+ only
directory rules #30 #32 (for example: only:.js,.ts
).yaml
configs #29 โ
ignore
#35 โ
(v2.1.0-beta.0)We are trying to match files with the following regular expression: [a-z][a-zA-Z0-9]*(Resolver|Schema)(\.test)?
using the below config:
ls:
.js: camelCase
.ts: camelCase
app/Handler/**:
.ts: regex:[a-z][a-zA-Z0-9]*(Resolver|Schema)(\.test)?
However, upon running the tool, we receive the following error: rule Schema)(\.test)? not exists
.
Any pointers on escaping the pipe character so we can achieve this functionality? ๐
I'm applying ls-lint
to more of our existing repositories, and I'm at an impasse with files that have acronyms in the name. The PascalCase walker isn't happy with consecutive capital letters, at least more than 2; I see you already have a special case accounted for, citing SsrVFor.ts
.
In my case, I have files with SEO in the name. Consider a file like ManualSEO.tsx
. I know I can lowercase eo
, but it IMO, ManualSeo.tsx
doesn't look correct. A similar argument could be made for files named with HTML or PDF.
In my opinion, considering acronyms, there really shouldn't be a rule stating that there be a limit to the number of consecutive capital letters.
I really would submit a PR, but I don't know go. ๐
But if I could figure out relative imports, what I would suggest is rather than walking the file name, import rule_regex.Validate
and give it /([A-Z][a-z]*[0-9]*)+/
. This pattern would allow for "multi-letter words" like Manual
as well as "single-letter words" like S
, E
, and O
as well as numbers, which seem to be already allowed as long as they don't come first... Although, the regex match is only one line, so maybe it's just easier to copy it.
The extension .yaml
should be preferred over .yml
, in a similar way we use .html
instead of .htm
.
Incorporating yet another tool that screams at you when youโve done something wrong might be hard in some teams.
People will say โah, why do we need this? Just take a look at the other file names for referenceโ.
But, if this tool, after configured properly, would also be able to scaffold parts of the project, that would be super awesome.
I imagine a cli counterpart that, for example, if you can run as follows:
ls-lint create component ComponentName
Would create a folder named ComponentName and within it create ComponentName.tsx
and ComponentName.module.scss
.
For now, these files will be empty files, but in future versions, ls-lint could also generate those files based on templates provided by the user.
Wdyt?
Its support set defalut rule for all files?
Just use a special format for a particular type of file?
ls:
default: kebab-case // default for all files. When not matched , use kebab-case.
.js: camelCase // .js file use camel case
the default error message "failed for rules: kebab-case" is not easy understandable, so I want to config my error message for it.
Waiting for **
support @Glob
Hey, thx for this linter
I want to add your linter to the project, but in my team, people use both platforms: macOS and Linux
for example when Iโm trying to install package for Linux on macOS:
[main]$ yarn add ls-lint-linux ls-lint-darwin --dev
yarn add v1.22.4
[1/5] ๐ Validating package.json...
[2/5] ๐ Resolving packages...
[3/5] ๐ Fetching packages...
error [email protected]: The platform "darwin" is incompatible with this module.
error Found incompatible module.
Maybe it is better to make one package that will load different binaries depending on the platform?
Hi, thanks, I love this, finally something to make file naming consistent
A question:
./docs/5x1000_leads.rb failed for rules: snakecase
./db/migrate/20200109074618_create_dashboards.rb failed for rules: snakecas
Should it fail? Numbers for migration (i.e.) are necessary, i'd like to test them all anyways: how can it be solved?
Thanks!
First off, what a great library. I'm totally loving this ๐ ๐
I don't know if I really can call this a issue, it's rather me and my old codebase that's not up to par (I should probably have them in a separate /tests
folder)
I've got a bunch of .vue-files in PascalCase.vue
and some tests PascalCase.test.js
right next to them (in the same folders)
I would like the rest of my "pure" .js-files to be in camelCase.js
Is this possible? ๐ผ
Cheers,
Linus
Hi the owner, I have a rule like that
.vue: regex:^index| regex:^default | regex:^student | regex:^_id | regex:^_slug
So I want to do like the normal regex --> Just one line
.vue: regex:^(index|default|_id|_slug)
Thank you bro!
On this page the below example is shown:
ls:
.js: kebab-case
models:
.js: PascalCase
src/templates:
.js: snake-case
Notice snake-case
, it should have an _
instead, thus if ya run the above one would get an error.
Tried to find a place to PR the fix but was unable to find such a location, hope the issue will be helpful.
In our projects, we tend to add may items to the ignore
list in the .ls-lint.yml
config file for common Markdown files. Per industry common practices, these files are named with SCREAMING_SNAKE_CASE
. For example:
.ls-lint.yml
ignore:
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- ISSUE_TEMPLATE.md
- PULL_REQUEST_TEMPLATE.md
- README.md
It would be great to not have to add these to the ignore list for many repos. Would it be a possibility to add support for SCREAMING_SNAKE_CASE to ls-lint so that we could configure our projects like:
.ls-lint.yml
ls:
.md: SCREAMING_SNAKE_CASE
...
Hi I have some regex here https://regex101.com/r/ISyaUy/1
And I try it like this:
ls:
apps:
.tsx: 'regex:apps\/web\/components\/[a-z-]+[a-z]\/[a-z-]+[a-z](.stories\|.spec)?'
But it gives an error:
2021/02/27 10:45:04 rule .spec)? not exists
error Command failed with exit code 1.
I have the following .ls-lint.yml
:
ls:
services/*/components/*/__tests__:
.test.ts: PascalCase
services/*/:
.vue: PascalCase
.ts: kebab-case
I want that every TypeScript file validates against kebab-case
except the ones within the components __tests__
directory.
The console is throwing errors that within ../components/Button/__tests__/
Button.test.ts
has not a file-name with kebab-case
Is this intended? I would assume that more specialized rules overwrite the general ones
Hi @loeffel-io
Is there will be Apple Silicon support?
It doesn't look good when you're forced to use only .yml file extension.
I want to store the config in ls-lint.yaml, and I'm sure some people would like the configs in json format as well. is it possible?
Afaik there're some pre-built tools to enable this behaviour.
https://github.com/search?o=desc&q=config+json+yaml&s=stars&type=Repositories
Hi, first of all thanks for the tool, simple, fast, superb!
I found issue with using it on windows.
Given config:
ls:
src/**/*:
.dir: kebab-case | snake_case
ignore:
- src/@types
- src/atoms/dashboard-table
The result is:
>ls-lint
2020/04/20 11:40:42 .\src\@types failed for rules: kebabcase | snakecase
2020/04/20 11:40:42 .\src\atoms\dashboard-table\local-atoms\CustomDate failed for rules: kebabcase | snakecase
2020/04/20 11:40:42 .\src\atoms\dashboard-table\local-atoms\DaysOfAdmissionTag failed for rules: kebabcase | snakecase
2020/04/20 11:40:42 .\src\atoms\dashboard-table\local-atoms\Flag failed for rules: kebabcase | snakecase
2020/04/20 11:40:42 .\src\atoms\dashboard-table\local-atoms\ObraCheckboxes failed for rules: kebabcase | snakecase
I think this is strange, because obviously the ls
part works on windows with slash /
but the ignore part does not (which is correct as the docs mention you should use backslash on windows)
So now I fixed the ignore part to have backslash pattern for windows.
ls:
src/**/*:
.dir: kebab-case | snake_case
ignore:
- src/@types
- src\@types
- src/atoms/dashboard-table
- src\atoms\dashboard-table
But I don't like the inconsistency that the ls
part works while the ignore
does not.
To fix this, the tool should handle the original config so it works properly on Widnows to get better user experience.
As a developer working on multiple projects,
I want to be able to use shared ls-lint configs,
so that I don't have to copy-paste a .ls-lint.yml
file in each repo.
It would be great if ls-lint used Cosmiconfig to find and load configuration like other formatting/linting tools -
The ideal situation would be to create a shared config package like lslint-config-myteam
and have that export a config file named lslint.config.js
that any project could use.
Additionally, having the shared config in JS format instead of YAML format allows for more flexibility to override the shared config if each project has slightly different needs.
First of all, thanks for the great plugin!
I see in the docs that having a directory config causes it to override all rules for the inner directories:
I think most of consumers imagine the rules to work like .gitignore
, so adding a rule for certain extension should automatically nest and only override if explicitly setting another rule for that directory.
Given that I believe this is rather unwanted and as such could you consider adding to V2 #36 ?
Looking forward to V2! ๐
I'd like to prohibit using filename index.css
in my components but cannot find details about the syntax of regex used in the project to build a proper expression.
Please advise.
So that we can use ls-lint from lint-staged, where it passes git staged files as command arguments such as:
node_modules/.bin/ls-lint file1.js path/to/file2.js
The result would be an insanely fast execution.
I want to introduce this into our team's repo but it will be very disruptive to report all the inconistency failures. I want to leverage husky and lint-staged. Not sure if you've thought through this type of support or how to do it
Most linters will exit 0 if there are errors or at least have a flag to do that. Is that something you are interested in adding?
The reason being, right now, if this was in a CI pipeline it would just print the output and not actually cause fail. You could wrap up the command and test the output, but that seems excessive. Thoughts?
First, let me start by saying that I love ls-lint
. This is one of those things I didn't know I needed until I had it.
However despite the advertised speed, ls-lint
isn't all that quick for me. I'm wondering if it has to do with my config, and whether you might have tips on what I could change to speed things up. I'm using version 1.9.2.
First, timing (macOS Big Sur on a 2019 16" with an Intel Core i7):
Here's my config:
ls:
.github/workflows:
.yml: kebab-case
cypress:
fixtures:
.json: kebab-case
integration:
.test.ts: PascalCase
src:
.gql: kebab-case
.svg: kebab-case
.ts: kebab-case
.d.ts: kebab-case
.generated.ts: kebab-case
.test.ts: kebab-case
.tsx: PascalCase
.stories.tsx: PascalCase
.test.tsx: PascalCase
hooks:
.ts: camelCase
.test.ts: camelCase
ignore:
- .git/
- .idea/
- .nyc_output/
- build/
- cypress-coverage/
- jest-coverage/
- node_modules/
- reports/
- src/index.tsx
- src/serviceWorker.ts
The project is a git repo of React with TypeScript, so there's things like .git
and node_modules
to deal with.
Here are some file counts:
$ npx ls-lint
lint livescript source files
Usage: ls-lint [options]... [files]...
Options:
-h, --help output usage information
-v, --version output the version number
-c, --config file::String use specified configuration file
--print-config print the configuration
Version 0.1.2
Done in 0.51s.
On Linux you can create 2 files of the same name, only differing by case. It would be great to have a flag to detect this and fail. The purpose would be to protect Windows users from enduring a git repo with 2 files of the same name.
I donโt know how to call this requirement, but in a lot of React projects youโll see the following pattern:
Within the folder: ./src/components/ComponentName
youโll find: ComponentName.tsx
and ComponentName.module.scss
.
So the containing folderโs name is the name of the files within it.
I suggest the following syntax:
ls:
src/components/PascalCase:$1
$1.tsx
$1.module.scss
Hope this is clear enough, and that I havenโt missed this option somehow.
I use this tool https://github.com/okonet/lint-staged to lint my changed files before committing them.
Only files I changed are linted, so if there are some legacy files that don't meet the rules, they don't get linted and don't break my flow.
Is it possible to make ls-lint work in a similar way - lint only files passed as arguments by lint-staged?
When I try to execute ls-lint
on my windows machine the following error gets returned: . not found
.
Config file is present and in my project root directory:
ls:
.js: kebab-case
.go: kebab-case
ignore:
- .git
- public/js/node_modules
Pretty basic, wanted to test ls-lint
When I try to execute ls-lint
in a directory without a config, the correct error open .ls-lint.yml: The system cannot find the file specified.
gets returned.
Am I missing something here? Thanks in advance!
At the moment the rules kick in if an extension has been matched. It would be nice to stipulate that only files of a certain extension are allowed (with case rules enforced).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.