Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RE: Add output when no files match #140

Closed
dan-gamble opened this issue Mar 15, 2017 · 12 comments
Closed

RE: Add output when no files match #140

dan-gamble opened this issue Mar 15, 2017 · 12 comments

Comments

@dan-gamble
Copy link

I've just added lint-staged as we currently have a pre-push hook that takes a while and isn't that intuitive, i figured if we could do it with this instead it might speed up our process a bit.

It's working nicely so far but the output can be very noisy, i think it is in relation to #135. I do like the idea of #135 but it seems to give me a comment for each file it iterates over. Would it be possible to just have 1 [skipped] message for the whole commit instead of a per file basis?

I'm not 100% sure if it is per file as the *.py and *.css messages aren't duplicated.

package.json

  "scripts": {
    "dev": "gulp",
    "build": "gulp production",
    "lint:css": "stylelint \"onespacemedia/{assets/**,apps/*/assets/css}/*.css\"",
    "lint:js": "eslint --ext .js,.vue onespacemedia/assets/js/**/*.js",
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "*.js": ["eslint --ext .js,.vue --fix", "git add"],
    "*.css": "stylelint",
    "*.py": ["pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n", "isort --check-only --diff --quiet --skip-glob=.venv --skip-glob=node_modules --skip-glob=*/migrations/*"]
  },
  "pre-commit": "lint-staged",

Terminal output

❯ g s                                                                                                                         (env: onespacemedia) 
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   onespacemedia/apps/sections/models.py
        modified:   onespacemedia/apps/sections/templates/sections/types/content-careers.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-double-testimonial.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-double-text-editor.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-industries.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-latest-news.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-logo-grid.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-logo-strip.html
        modified:   onespacemedia/apps/sections/templates/sections/types/content-people.html
        modified:   onespacemedia/apps/sections/templates/sections/types/heroes-homepage-hero.html
        modified:   onespacemedia/apps/sections/templates/sections/types/heroes-landing-hero.html
        modified:   onespacemedia/apps/sections/templates/sections/types/text-text-and-carousel.html
        modified:   onespacemedia/apps/sections/templates/sections/types/text-text-and-lists.html
        modified:   onespacemedia/apps/sections/templates/sections/types/text-text-image-and-icons.html
        modified:   onespacemedia/apps/site/templatetags/site.py
        modified:   onespacemedia/assets/css/markdown/markdown.css
        modified:   package.json
        modified:   yarn.lock

                                                                                                                                                    
~/Workspace/onespacemedia develop*
❯ ga .                                                                                                                        (env: onespacemedia) 
                                                                                                                                                    
~/Workspace/onespacemedia develop*
❯ g commit -m "Let section title's be able to use Markdown"                                                                   (env: onespacemedia) 
Alias tip: gcmsg "Let section title's be able to use Markdown"
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ✔ Running tasks for *.css
 ✔ Running tasks for *.py
[develop bbd470e] Let section title's be able to use Markdown
 18 files changed, 269 insertions(+), 23 deletions(-)
@okonet
Copy link
Collaborator

okonet commented Mar 15, 2017

It's related to your config. Please remove --ext option from eslint.

Globs are keys of the config object, so with you current setup you will miss all *.vue files as well.

@okonet okonet closed this as completed Mar 15, 2017
@dan-gamble
Copy link
Author

Awesome, thanks Andrey :)

@dan-gamble
Copy link
Author

Hmm, i still seem to get this even with removing --ext on *.js and the lint:js

@okonet
Copy link
Collaborator

okonet commented Mar 16, 2017

Weird. This should be only displayed once. Can you run lint-staged with verbose: true in config and see what it outputs?

@dan-gamble
Copy link
Author

dan-gamble commented Mar 17, 2017

I just tried it with verbose: true and got:

❯ g commit                                                                                                                                             (env: onespacemedia) 
{ verbose: true,
  '*.js': [ 'eslint --fix', 'git add' ],
  '*.css': 'stylelint',
  '*.py': 
   [ 'pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n',
     'isort --check-only --diff --quiet --skip-glob=.venv --skip-glob=node_modules --skip-glob=*/migrations/*' ] }
[15:35:38] Running tasks for verbose [started]
[15:35:38] Running tasks for *.js [started]
[15:35:38] Running tasks for *.css [started]
[15:35:38] Running tasks for *.py [started]
[15:35:38] Running tasks for verbose [skipped]
[15:35:38] → No staged files match verbose
[15:35:38] Running tasks for *.js [skipped]
[15:35:38] → No staged files match *.js
[15:35:38] stylelint [started]
[15:35:38] pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n [started]
[15:35:39] stylelint [completed]
[15:35:39] Running tasks for *.css [completed]
[15:35:47] pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n [failed]
[15:35:47] → 🚫 pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n found some errors. Please fix them and try committing again.
No config file found, using default configuration

************* Module onespacemedia.apps.sections.migrations.0009_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0007_auto_20170317_1434
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0006_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)

[15:35:47] Running tasks for *.py [failed]
[15:35:47] → 🚫 pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n found some errors. Please fix them and try committing again.
No config file found, using default configuration

************* Module onespacemedia.apps.sections.migrations.0009_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0007_auto_20170317_1434
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0006_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)

🚫 pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n found some errors. Please fix them and try committing again.
No config file found, using default configuration

************* Module onespacemedia.apps.sections.migrations.0009_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0007_auto_20170317_1434
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0006_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)

pre-commit: 
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint-staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit: 
pre-commit:   git commit -n (or --no-verify)
pre-commit: 
pre-commit: This is ill-advised since the commit is broken.
pre-commit: 

without:

❯ g commit                                                                                                                                             (env: onespacemedia) 
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js
 ✔ Running tasks for *.css
 ❯ Running tasks for *.py
   → W:  4, 0: Unused models imported from django.db (unused-import)
   ✖ pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n
     → W:  4, 0: Unused models imported from django.db (unused-import)
     isort --check-only --diff --quiet --skip-glob=.venv --skip-glob=node_modules --skip-glob=*/migrations/*
🚫 pylint --load-plugins pylint_django,pylint_mccabe --ignore=migrations,tests -d missing-docstring,invalid-name,no-init,too-many-ancestors,no-member,line-too-long,attribute-defined-outside-init,too-few-public-methods,no-self-use,unused-argument,protected-access,locally-disabled,duplicate-code,fixme --reports=n found some errors. Please fix them and try committing again.
No config file found, using default configuration

************* Module onespacemedia.apps.sections.migrations.0009_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0007_auto_20170317_1434
W:  4, 0: Unused models imported from django.db (unused-import)
************* Module onespacemedia.apps.components.migrations.0006_auto_20170317_1143
W:  4, 0: Unused models imported from django.db (unused-import)

pre-commit: 
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint-staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit: 
pre-commit:   git commit -n (or --no-verify)
pre-commit: 
pre-commit: This is ill-advised since the commit is broken.
pre-commit: 

Sorry for the length but that's how bad my terminal is :(

@okonet
Copy link
Collaborator

okonet commented Mar 17, 2017

It should be:

{
  verbose: true,
  linters: {...}
}

Please refer to README

@dan-gamble
Copy link
Author

I tried it with that config and still get the same output

@okonet
Copy link
Collaborator

okonet commented Mar 17, 2017

@dan-gamble can you isolate the behavior? Please remove your *.py and *.css linters and try running it. Try moving things in the config. I dunno. Anything that leads to the bug.

TBH I don't know how to help you just by looking at the output. Again, I've never seen such behavior before.

@okonet
Copy link
Collaborator

okonet commented Mar 17, 2017

Ideally it would be a github repo where I can reproduce your behavior.

@dan-gamble
Copy link
Author

Sure thing i'll see if i can come up with a small repro repo for you 👍

@ipland
Copy link

ipland commented May 22, 2017

@dan-gamble I came across the same problem 😭 , but I fix that😄.

  1. npm uninstall --save-dev husky pre-commit lint-staged.
  2. npm install --save-dev husky lint-staged.
  3. Configuration like below.
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx}": ["eslint --fix", "git add"]
  },

Hope that it helps.

@dan-gamble
Copy link
Author

Thanks @ipland what on there do you think was causing the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants