Lint-staged: "âš  Some of your tasks use `git add` command."

Created on 22 Jan 2020  Â·  8Comments  Â·  Source: okonet/lint-staged

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 `[email protected]` +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

Most helpful comment

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.

All 8 comments

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.

Huh, that was added by npx mrm lint-staged. I guess that has since been updated?

Good catch. Let me see if there’s something we’ve forgot to update.

This seems to be an issue in another package, so I suggest you open an issue there. I don’t have any access to that repo.

https://github.com/sapegin/mrm-tasks/blob/master/packages/mrm-task-lint-staged/index.js#L81

Your docs currently recommend npx mrm lint-staged. To be honest, I didn't realise it was a third-party project.

Is it worth updating the docs to make it clear that npx mrm lint-staged will do the wrong thing?

@okonet what do you think? I see there’s some earlier discussion in that github repo.

I'll update the task since I wrote that.

nice , solved my problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kachkaev picture kachkaev  Â·  5Comments

thedamon picture thedamon  Â·  3Comments

yoannmoinet picture yoannmoinet  Â·  8Comments

timche picture timche  Â·  5Comments

jitenderchand1 picture jitenderchand1  Â·  3Comments