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.

Hi,

Thanks for a great library. 🌹

I’m using lint-staged to run tslint on typescript files (*.ts) but I’d like to exclude certain directories from being linted.

How can I exclude certain paths from being linted?

Cheers

Issue Analytics

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

github_iconTop GitHub Comments

11reactions
tnguyen14commented, Jul 13, 2017

@okonet how would I use the exclude pattern in minimatch to ignore certain files? I need to ignore compiled files. how should my lint-staged config look? what I want is something like this:

"lint-staged": {
  "linters": {
    "*.js,!public/dist/*.js": [
      "prettier --write"",
      "git add"
    ]
  }
}

However, I don’t think *.js,!public/dist/*.js is valid minimatch pattern. Do you know how I could use that?

9reactions
evenfrostcommented, Mar 20, 2019

If anyone like me stumbles upon same issue when trying to exclude some folder from lint-staged scope, here’s the solution:

{
  "linters": {
    "!(client)/**/*.{ts,tsx}": ["npm run lint:server --", "git add"]
  }
}

Here lint-staged will run for every .ts or .tsx file in the project except these in root client folder (I’ve got separate tslint.json for my client files).

Some additional exclude patterns can be found here: https://github.com/mysticatea/cpx/issues/24#issuecomment-285389024.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exclude Certain Paths With the find Command - Baeldung
Exclude Certain Paths With the find Command · Let's create a set of files and directories to use as an example: $ mkdir...
Read more >
How do I exclude a directory when using `find`? - Stack Overflow
If -prune doesn't work for you, this will: find -name "*.js" -not -path "./directory/*". Caveat: requires traversing all of the unwanted directories.
Read more >
Exclude a directory or multiple directories while using find ...
We can exclude directories by using the help of “path“, “prune“, “o” and “print” switches with find command. ... The directory “bit” will...
Read more >
How to Exclude Certain Paths With the find Command in Linux
Ways to exclude paths with the find command: Method 1: The -prune flag. Syntax: find <path_of_the_file> -prune.
Read more >
Exclude Paths — DeepDiff 6.2.2 documentation - Zepworks
Exclude part of your object tree from comparison. use exclude_paths and pass a set or list of paths to exclude, if only one...
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