Giter Club home page Giter Club logo

ls-lint's People

Contributors

caiofbpa avatar fossabot avatar loeffel-io avatar pustovalov avatar renovate[bot] avatar wburningham avatar wiget avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ls-lint's Issues

Be less like eslint and more like prettier

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?

The platform "darwin" is incompatible with this module.

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?

One regex for everything

Hi there 🙂

Maybe I missed something in the documentation, but can I use one regex for any files?

image

Thanks 🙂

UPD: Sorry, Used the wrong account ☹️

Feature request: Allow passing files via argv

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.

Incorrect documentation reference to snake_case

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.

Do the ignores have lower specificity?

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?

ignore not working for file

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

Problem with nested rules

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

How to Shorten the multiple lines regex in one line!

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!

Support for SCREAMING_SNAKE_CASE

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

Version 2

Thank you for 100 000 NPM Downloads! The project is growing constantly and we are starting the development of v2 soon!

Planned features:

  • Extend | 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)
  • Support .yaml configs #29
  • Glob support for ignore #35 ✅ (v2.1.0-beta.0)
  • Reusable rules #22
  • Performance optimizations ✅
  • Support arm arch ✅
  • Support for SCREAMING_SNAKE_CASE ✅
  • ls-lint on an existing project ("warn" option) #63
  • #71

Lint list of dirs/files

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

One regex for everything

Hi there 🙂

Maybe I missed something in the documentation, but can I use one regex for any files?

image

Thanks 🙂

Handling regular expression containing '|' symbol

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 add @ls-lint/ls-lint in my vue3 project,but it cannt work currently.

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

Feature request: Detect duplicate filenames

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.

Acronyms in PascalCase

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.

Slow for my project (1.9.2)

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):

Screen Shot 2021-01-22 at 1 28 19 PM

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:

Screen Shot 2021-01-22 at 1 38 59 PM

exit 0 on errors?

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?

Support for ComponentName/ComponentName.tsx

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.

Wildcard support for file extensions?

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.

Numbers in name

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!

Selectively override rules for inner directories

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:

Screenshot 2021-02-08 at 16 13 29

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! 😃

Cosmiconfig to support shared configuration files

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.

How to lint only a list of passed files?

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?

Rule: Exists

It would be cool if this would have a check to ensure that a directory/file exists!

Custom pattern: kebabcase + pointcase

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?

How to set a default rule?

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

Windows: Inconsistent slash matching

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.

*.test.js & *.js in different casings

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

Installing npm module on M1 CPU fails

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

Directory names

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.

Adding ls-lint on an existing project ("warn" option)

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?

Strict mode?

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

(Windows) Error: . not found

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!

How to disable some specific names?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.