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.

Ignore and subfolders glob not working

See original GitHub issue

Description

I have a problem with the ignore config and the global globs. The ignore section is not working at all.

MBP15-Faou:sagemcom faou$ git status
 M api/services/ActivityLog.js
 M package.json
"lint-staged": {
    "linters": {
      "package.json": [
        "git add",
        "prettier-package-json --write"
      ],
      "wwww/package.json": [
        "git add",
        "prettier-package-json --write"
      ],
      "*.js": [
        "yarn lint"
      ]
    },
    "ignore": [
        "www/**/*.js"
    ]
  }

It either says that there is no tasks to matching.

 ↓ Running tasks for package.json [skipped]
   → No staged files match package.json
 ↓ Running tasks for wwww/package.json [skipped]
   → No staged files match wwww/package.json
 ↓ Running tasks for *.js [skipped]
   → No staged files match *.js

I’ve tried with using just the glob and no ignore, and it doesn’t work also

 "lint-staged": {
    "linters": {
      "package.json": [
        "git add",
        "prettier-package-json --write"
      ],
      "wwww/package.json": [
        "git add",
        "prettier-package-json --write"
      ],
      "api/**/*.js": [
        "yarn lint"
      ]
    }
  }

Result

MBP15-Faou:sagemcom faou$ npx lint-staged
 ↓ Running tasks for package.json [skipped]
   → No staged files match package.json
 ↓ Running tasks for wwww/package.json [skipped]
   → No staged files match wwww/package.json
 ↓ Running tasks for api/**/*.js [skipped]
   → No staged files match api/**/*.js

Steps to reproduce

  • create a project with a two folders api and www
  • Put some some code in subfoders of those two folders
  • ignore the www folder.
  • run the lint-staged

Debug Logs

Debug with ignore
npx lint-staged --debug
  lint-staged:bin Running `lint-staged@7.2.0` +0ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/Users/faou/Projects/sagemcom/package.json`:
  lint-staged { linters:
  lint-staged    { 'package.json': [ 'git add', 'prettier-package-json --write' ],
  lint-staged      'wwww/package.json': [ 'git add', 'prettier-package-json --write' ],
  lint-staged      '*.js': [ 'git add', 'yarn lint' ] },
  lint-staged   ignore: [ 'www/**/*.js' ] } +3ms
  lint-staged:cfg Normalizing config +0ms
  lint-staged:cfg Validating config +2ms
Running lint-staged with the following config:
{
  linters: {
    'package.json': [
      'git add',
      'prettier-package-json --write'
    ],
    'wwww/package.json': [
      'git add',
      'prettier-package-json --write'
    ],
    '*.js': [
      'git add',
      'yarn lint'
    ]
  },
  ignore: [
    'www/**/*.js'
  ],
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  subTaskConcurrency: 1,
  renderer: 'verbose'
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:run Resolved git directory to be `/Users/faou/Projects/sagemcom` +1ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [] +28ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:cfg Normalizing config +33ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: 'package.json',
  lint-staged:gen-tasks   commands: [ 'git add', 'prettier-package-json --write' ],
  lint-staged:gen-tasks   fileList: [] } +1ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: 'wwww/package.json',
  lint-staged:gen-tasks   commands: [ 'git add', 'prettier-package-json --write' ],
  lint-staged:gen-tasks   fileList: [] } +0ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: '*.js',
  lint-staged:gen-tasks   commands: [ 'git add', 'yarn lint' ],
  lint-staged:gen-tasks   fileList: [] } +0ms
Running tasks for package.json [started]
Running tasks for wwww/package.json [started]
Running tasks for *.js [started]
Running tasks for package.json [skipped]
→ No staged files match package.json
Running tasks for wwww/package.json [skipped]
→ No staged files match wwww/package.json
Running tasks for *.js [skipped]
→ No staged files match *.js
  lint-staged linters were executed successfully! +42ms
Debug without ignore
npx lint-staged --debug
  lint-staged:bin Running `lint-staged@7.2.0` +0ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/Users/faou/Projects/sagemcom/package.json`:
  lint-staged { linters:
  lint-staged    { 'package.json': [ 'git add', 'prettier-package-json --write' ],
  lint-staged      'wwww/package.json': [ 'git add', 'prettier-package-json --write' ],
  lint-staged      'api/**/*.js': [ 'git add', 'yarn lint' ] } } +2ms
  lint-staged:cfg Normalizing config +0ms
  lint-staged:cfg Validating config +1ms
Running lint-staged with the following config:
{
  linters: {
    'package.json': [
      'git add',
      'prettier-package-json --write'
    ],
    'wwww/package.json': [
      'git add',
      'prettier-package-json --write'
    ],
    'api/**/*.js': [
      'git add',
      'yarn lint'
    ]
  },
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  ignore: [],
  subTaskConcurrency: 1,
  renderer: 'verbose'
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:run Resolved git directory to be `/Users/faou/Projects/sagemcom` +1ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [] +28ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:cfg Normalizing config +33ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: 'package.json',
  lint-staged:gen-tasks   commands: [ 'git add', 'prettier-package-json --write' ],
  lint-staged:gen-tasks   fileList: [] } +1ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: 'wwww/package.json',
  lint-staged:gen-tasks   commands: [ 'git add', 'prettier-package-json --write' ],
  lint-staged:gen-tasks   fileList: [] } +0ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: 'api/**/*.js',
  lint-staged:gen-tasks   commands: [ 'git add', 'yarn lint' ],
  lint-staged:gen-tasks   fileList: [] } +0ms
Running tasks for package.json [started]
Running tasks for wwww/package.json [started]
Running tasks for api/**/*.js [started]
Running tasks for package.json [skipped]
→ No staged files match package.json
Running tasks for wwww/package.json [skipped]
→ No staged files match wwww/package.json
Running tasks for api/**/*.js [skipped]
→ No staged files match api/**/*.js
  lint-staged linters were executed successfully! +41ms

Environment

  • OS: macOS Sierra
  • Node.js: v9.11.2
  • lint-staged: 7.2.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
enyosolutionscommented, Aug 7, 2018

i already did it doesn’t change a thing.

On branch wip
Your branch is up to date with 'origin/wip'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   api/services/ActivityLog.js

no changes added to commit (use "git add" and/or "git commit -a")

and my lint-staged

 "lint-staged": {
    "linters": {
      "package.json": [
        "git add",
        "prettier-package-json --write"
      ],
      "wwww/package.json": [
        "git add",
        "prettier-package-json --write"
      ],
      "*.js": [
        "git add",
        "yarn lint"
      ]
    },
    "ignore": ["www/**/*.js"]
  },
0reactions
enyosolutionscommented, Aug 7, 2018

I actually found my mistake : git add

i didn’t add the . at the end.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Globbing pattern to exclude files in directory, but include ...
The following glob should work: ... First part will include all files in all subdirectories. Second part will exclude files in starting directory....
Read more >
Any way to ignore/exclude a file or folder? · Issue #24 - GitHub
I'm looking for a way to ignore a file or folder during the copy. For instance, if I want to copy all js...
Read more >
Ignore List Glob pattern for sub-folders - Insync Forums
The issue I'm having is finding a correct way to ignore sub-folders in a pattern. For example: test – ignore – another –...
Read more >
gitignore Documentation - Git
DESCRIPTION. A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES ......
Read more >
How to Get a List of All Files in a Directory With Python
In this tutorial, you'll be examining a couple of methods to get a list of files and folders in a directory with Python....
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