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.

"⚠ Some of your tasks use `git add` command."

See original GitHub issue

Description

I’m getting the message “⚠ Some of your tasks use git add command.” during linting, but it isn’t clear what tasks it’s referring to.

Steps to reproduce

https://gist.github.com/jakearchibald/c5e18f54ddd9f8bb852e2d2abdbb3884

  1. Check out the above.
  2. Make a change to test.js.
  3. Stage the change.
  4. Run ./node_modules/.bin/lint-staged

Debug Logs

expand to view
  lint-staged:bin Running `lint-staged@10.0.1` +0ms
  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  debug: true,
  maxArgLength: 131072,
  quiet: false,
  relative: false,
  shell: false
} +2ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/Users/jakearchibald/dev/buildoff/package.json`:
  lint-staged { '*.{js,css,json,md,ts,tsx}': [ 'prettier --write', 'git add' ] } +28ms
  lint-staged:cfg Validating config +0ms
Running lint-staged with the following config:
{
  '*.{js,css,json,md,ts,tsx}': [
    'prettier --write',
    'git add'
  ]
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ] +0ms
  lint-staged:git Running git command [ 'rev-parse', '--show-superproject-working-tree' ] +23ms
  lint-staged:run Resolved git directory to be `/Users/jakearchibald/dev/buildoff` +45ms
  lint-staged:run Resolved git config directory to be `/Users/jakearchibald/dev/buildoff/.git` +0ms
  lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only' ] +21ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [ 'test.js' ] +14ms
  lint-staged:chunkFiles Resolved an argument string length of 41 characters from 1 files +0ms
  lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 131072 +0ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks {
  lint-staged:gen-tasks   pattern: '*.{js,css,json,md,ts,tsx}',
  lint-staged:gen-tasks   commands: [ 'prettier --write', 'git add' ],
  lint-staged:gen-tasks   fileList: [ '/Users/jakearchibald/dev/buildoff/test.js' ]
  lint-staged:gen-tasks } +3ms
  lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'prettier --write', 'git add' ] +0ms
  lint-staged:task cmd: prettier --write /Users/jakearchibald/dev/buildoff/test.js +0ms
  lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
  lint-staged:task cmd: git add /Users/jakearchibald/dev/buildoff/test.js +0ms
  lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +14ms
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.

Preparing... [started]
  lint-staged:git Backing up original state... +0ms
  lint-staged:git Backing up merge state... +0ms
  lint-staged:file Reading buffer from file `/Users/jakearchibald/dev/buildoff/.git/MERGE_HEAD` +0ms
  lint-staged:file Reading buffer from file `/Users/jakearchibald/dev/buildoff/.git/MERGE_MODE` +0ms
  lint-staged:file Reading buffer from file `/Users/jakearchibald/dev/buildoff/.git/MERGE_MSG` +0ms
  lint-staged:file File `/Users/jakearchibald/dev/buildoff/.git/MERGE_HEAD` doesn't exist, ignoring... +4ms
  lint-staged:file File `/Users/jakearchibald/dev/buildoff/.git/MERGE_MODE` doesn't exist, ignoring... +0ms
  lint-staged:file File `/Users/jakearchibald/dev/buildoff/.git/MERGE_MSG` doesn't exist, ignoring... +0ms
  lint-staged:git Done backing up merge state! +4ms
  lint-staged:git Running git command [
  'stash',
  'save',
  '--quiet',
  '--include-untracked',
  '--keep-index',
  'lint-staged automatic backup'
] +39ms
  lint-staged:git Restoring merge state... +92ms
  lint-staged:git Done restoring merge state! +0ms
  lint-staged:git Running git command [ 'ls-files', '--others', '--exclude-standard' ] +92ms
  lint-staged:git Running git command [ 'stash', 'list' ] +6ms
  lint-staged:git Running git command [
  'diff',
  '--binary',
  '--unified=0',
  '--no-color',
  '--no-ext-diff',
  '--patch',
  'stash@{0}',
  '-R'
] +16ms
  lint-staged:git Done backing up original state! +29ms
Preparing... [completed]
Running tasks... [started]
Running tasks for *.{js,css,json,md,ts,tsx} [started]
prettier --write [started]
prettier --write [completed]
git add [started]
git add [completed]
Running tasks for *.{js,css,json,md,ts,tsx} [completed]
Running tasks... [completed]
Applying modifications... [started]
  lint-staged:git Running git command [ 'ls-files', '--modified' ] +198ms
  lint-staged:git Running git command [ 'status', '--porcelain' ] +7ms
  lint-staged:git Running git command [ 'stash', 'list' ] +9ms
  lint-staged:git Running git command [ 'show', '--format=%b', 'stash@{0}^3' ] +15ms
  lint-staged:git Running git command [ 'apply', '-v', '--whitespace=nowarn', '--recount', '--unidiff-zero' ] +9ms
Applying modifications... [completed]
Cleaning up... [started]
  lint-staged:git Dropping backup stash... +239ms
  lint-staged:git Running git command [ 'stash', 'list' ] +8ms
  lint-staged:git Running git command [ 'stash', 'drop', '--quiet', 'stash@{0}' ] +15ms
  lint-staged:git Done dropping backup stash! +38ms
Cleaning up... [completed]
  lint-staged tasks were executed successfully! +485ms

Environment

  • OS: OSX 10.14.6
  • Node.js: v12.4.0
  • lint-staged: 10.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

175reactions
iirojcommented, Jan 22, 2020

This is covered in the changelog. Your configuration looks like the following:

{
  '*.{js,css,json,md,ts,tsx}': [
    'prettier --write',
    'git add'
  ]
}

From v10 onwards the git add part is automatic and not necessary to include in your configuration.

1reaction
aneta-scommented, Nov 22, 2021

@iiroj I appreciate your willingness a lot! If I look in my bin folder, I can’t see gpg2 folder. If I type in git command --no-verify, zsh says command not found. Sorry, I’ve not touch react for a while now. Can you be more specific what you mean by “if bin exist on my system”? I mean I see bin folder, but no hooks related names in it Below are my dependencies, does this help at least?

{
  "name": "gatsby-starter-hello-world",
  "private": true,
  "description": "A simplified bare-bones starter for Gatsby",
  "version": "0.1.0",
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "dependencies": {
    "bootstrap": "^4.4.1",
    "gatsby": "^2.19.5",
    "gatsby-image": "^2.2.39",
    "gatsby-plugin-manifest": "^2.2.38",
    "gatsby-plugin-offline": "^3.0.32",
    "gatsby-plugin-react-helmet": "^3.1.21",
    "gatsby-plugin-sass": "^2.1.27",
    "gatsby-plugin-sharp": "^2.4.0",
    "gatsby-source-filesystem": "^2.1.46",
    "gatsby-transformer-sharp": "^2.3.13",
    "node-sass": "^4.13.1",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.0-beta.16",
    "react-dom": "^16.13.1",
    "react-github-btn": "^1.1.1",
    "react-helmet": "^5.2.1",
    "react-reveal": "^1.2.2",
    "react-tilt": "^0.1.4",
    "uuid": "^3.4.0"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.3",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-config-prettier": "^6.9.0",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.2",
    "eslint-plugin-react": "^7.18.0",
    "eslint-plugin-react-hooks": "^2.3.0",
    "husky": "^4.2.1",
    "lint-staged": "^10.0.2",
    "prettier": "^1.19.1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/gatsbyjs/gatsby-starter-hello-world.git"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.+(js|jsx)": [
      "eslint --fix",
      "git add"
    ],
    "*.+(json|css|md)": [
      "prettier --write",
      "git add"
    ]
  },
  "homepage": "https://github.com/gatsbyjs/gatsby-starter-hello-world#readme",
  "main": ".eslintrc.js",
  "directories": {
    "example": "examples"
  },
  "keywords": [],
  "author": ""
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

lint-staged: what the purpose of 'git add' command
It's using husky to hooks some actions before your commit. See at: https://github.com/typicode/ ...
Read more >
git-add Documentation - Git
This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit....
Read more >
提交时报错Some of your tasks use 'git add' command
提交时报错Some of your tasks use 'git add' command.
Read more >
Git Add | Atlassian Git Tutorial
In review, git add is the first command in a chain of operations that directs Git to "save" a snapshot of the current...
Read more >
Automating Linting: Using Husky and Lint-Staged
⚠ Some of your tasks use `git add ` command. Please remove it from the config since all modifications made by tasks will...
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