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.

Allow glob exclusions

See original GitHub issue

Some projects commit build (dist) files to the repository. Usually, the syntax of these generated files is out of the scope of linters. But ATM all files that matches the glob pattern will run against linters.

Ideally we want *-staged tasks to be configured the same way as normal linter tasks.

But this might require a major rewrite and switch to the Node from CLI.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jharris4commented, May 2, 2017

Ouch, this burned me too. I was trying to use !(node_modules|dist|lib|es)**/*.js for my pattern. And the minimatch docs say:

If the pattern starts with a ! character, then it is negated. Set the nonegate flag to suppress this behavior, and treat leading ! characters normally. This is perhaps relevant if you wish to start the pattern with a negative extglob pattern like !(a|B). Multiple ! characters at the start of a pattern will negate the pattern multiple times.

I’m trying to see if there’s a way to work around this with a different pattern, but otherwise I’ll have to think about making a PR to support passing the nonegate flag to minimatch somehow…

2reactions
nikhil618commented, Sep 17, 2019

Hey there @okonet @jharris4 @davidhund ,

I was naively trying to do something like:

"lint-staged": {
    "src/**/*.js server/src/**/*.js, !server/src/models/**/*.js ": [
      "prettier --write",
      "git add"
    ]
  }

but it doesn’t seem to be working. Do I need to do something else to get the functionality I need?

Maybe you could use https://yarnpkg.com/en/package/multimatch instead of minimatch to support what I’m trying to do?

Thanks!

For anyone who stumbles upon this issue like me it now supports glob match but uses micromatch now read this post I added for the fix. https://stackoverflow.com/a/57981925/1221731

Read more comments on GitHub >

github_iconTop Results From Across the Web

glob exclude pattern - python - Stack Overflow
You can't exclude patterns with the glob function, globs only allow for inclusion patterns. Globbing syntax is very limited (even a [!.
Read more >
Exclude one pattern from glob match - Unix Stack Exchange
GlennJackman's answer shows how to enable extended pattern matching features to negate a match. – Johnny. Oct 24, 2014 at 17:33. Add a...
Read more >
Glob Pattern Exclude Directory in Python - Codeigo
We will start by covering the basics of glob. To see how directories are excluded, you can go directly to the Section “Excluding...
Read more >
Tips for writing glob patterns in DeepSource configuration
exclude_patterns are a list of glob patterns that should be excluded when the analyses are run. These patterns should be relative to the ......
Read more >
Global Exclusions - Sophos Central Admin
To set exclusions: Go to Global Settings > Global Exclusions. Click Add Exclusion. The Add Exclusion dialog is displayed.
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