Giter VIP home page Giter VIP logo

lint-staged's Issues

Commiting deleted files breaks lint-staged

If I delete a file, and then I try to commit the deletion. The linter throws an error in the pre-commit hook, because it tries to lint the deleted file that doesn't exists anymore.

Running eslint on git staged files: **/*.@(js|jsx)
Running jscs on git staged files: **/*.@(js|jsx)
Error: Path internals/scripts/clean.js was not found.
    at .<anonymous> (node_modules/jscs/lib/checker.js:188:19)
    at Array.<anonymous> (node_modules/vow/lib/vow.js:712:39)
    at Immediate.callFns [as _onImmediate] (node_modules/vow/lib/vow.js:23:35)
    at tryOnImmediate (timers.js:543:15)
    at processImmediate [as _immediateCallback] (timers.js:523:5)
pre-commit: 
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint:staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit: 
pre-commit:   git commit -n (or --no-verify)
pre-commit: 
pre-commit: This is ill-advised since the commit is broken.
pre-commit: 

From: react-boilerplate/react-boilerplate#397

Support npm 2.x

Using npm 2.x lint-staged installs staged-files binary at ./node_modules/lint-staged/node_modules/.bin making all scripts break. We should use some kind of resolving to find the proper path to the staged-files binary.

Code published to npm is not compatible with README

Hi,

I installed the latest version from npm (3.0.3) but it wasn't working. I looked at the code in node_modules and it seems older than the code in the repo.

The README states that I can set the git root in the config 'git-root' but the code that pulls from npm does not support that, so it didn't work.

I manually copied the code from the repo into my node_modules and it works perfectly.

Could you please ensure that the README is in parity with the published code in the future?
Plus, publishing the latest code would be a huge help :)

P.S. This package is super helpful!

Many thanks!

Linting throws npm error because linter returns with non-zero status

When running npm run lint-staged npm throws an error because, I guess, the linter exits with a non-zero status:

> npm run lint-staged
> project@ lint-staged C:\Users\user\Projects\project
> lint-staged

  source\script\component\accordion.js:2:1
  ×  2:1  Unexpected space between function name and paren.            no-spaced-func
  ×  2:1  meg is not defined.                                          no-undef
  ×  3:1  Unexpected newline between function and ( of function call.  no-unexpected-multiline

  3 errors
�  scripts:lint found some issues. Fix them and try again.

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint-staged"
npm ERR! node v4.5.0
npm ERR! npm  v3.8.5
npm ERR! code ELIFECYCLE
npm ERR! project@ lint-staged: `lint-staged`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@ lint-staged script 'lint-staged'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     lint-staged
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs project
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls project
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\user\Projects\project\npm-debug.log

package.json looks like this:

{
  "scripts": {
    "scripts:lint": "xo",
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "*.js": "scripts:lint"
  },
  "pre-commit": "lint-staged"
}

Is this a bug or how can I otherwise prevent the npm error?

Re-formatting the code

// directory
.git/
assets/
    javascripts/
    stylesheets/
    package.json
// package.json
{
  "scripts": {
    "lint": "lint-staged",
  },
  "lint-staged": {
    "gitDir": "../",
    "linters": {
      "*.{js,jsx}": ["eslint --fix", "git add"],,
    }
  },
}
// .git/hooks/pre-commit
cd assets
npm run lint

My setting is like ↑.

With this setting it will be "Error: fatal: Not a git repository: '.git'".

Doesnt seem to fire as expected

I followed the steps in the associated blog post

I have things configured correctly (I believe) but when lint-staged script is executed, it does not report any errors. However, if I run eslint from CLI it correctly reports the errors.

$ run lint-staged
> [email protected] lint-staged /Users/mikeerickson/Documents/Projects/sandbox
> lint-staged

I am firing the script manually to see what happens, it appears to do nothing (maybe thinking there are no *.js files) My eslint script runs across whole project (I am trying to run it only against staged items)

I have issued git add . to add files, then running git commit and it commits without errors (but I have placed specific errors into files added)

If I run npm run eslint it correctly reports errors

“scripts”: {
 “eslint”: “eslint \”./src/**/*.js\””,
 “sass-lint”: “sass-lint -v -q”,
 “lint-staged”: “lint-staged”
 },
 “lint-staged”: {
 “eslint”: “*.js”,
 “sass-lint”: “*.sass”
 },
 “pre-commit”: “lint-staged”,
…

2.0.2 version in Windows causing errors

I updated to version 2 and is now on all Windows computers error. In this case all is well on the mac.

{
  "scripts": {
     "lint-staged": "lint-staged",
     "eslint:fix": "eslint --fix",
     "stylelint:less": "stylelint --syntax=less",
     "git:add": "git add"
  },
  "lint-staged": {
      "*.@(js|jsx)": [
        "eslint:fix",
        "git:add"
      ],
      "*.less": [
        "stylelint:less"
      ]
  },
  "pre-commit": [
      "lint-staged"
  ],
}
25h25hevents.js:154
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm ENOENT
    at exports._errnoException (util.js:856:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:475:9)
    at process._tickCallback (node.js:389:17)
pre-commit:
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint-staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit:
pre-commit:   git commit -n (or --no-verify)
pre-commit:
pre-commit: This is ill-advised since the commit is broken.
pre-commit:

npm 3.6.0/3.9.3, node 5.6.0/6.2.1

Run local scripts from package.json before trying a bin lookup

Having eslint installed and the following config in the package.json

"scripts": {
  "eslint": "eslint --fix"
},
"lint-staged": {
  "eslint": "*.js"
}

will run eslint without --fix parameter since it tries a bin lookup before trying to execute the local script. Local npm script should be the default behavior with a fallback to the bin lookup.

Add presets for even simpler installation process

ESLint presets are awesome and I think lint-staged should allow pre-configured presets as well.

In a nutshell, presets should be just plain objects that then should be added to an array during the init phase.

confusion with file patterns

My package.json looks as follows:

{
  "scripts": {
    "lint-staged": "lint-staged"
  },
  "pre-commit": "lint-staged",
  "lint-staged": {
    "*.js": "eslint",
    "src/**/*.js": "eslint"
  },
}

My directory structure looks as follows:

├── .git
├── package.json
├── alpha.js                          [should match "*.js"]
├── src
    └── bravo
        └── charlie.js                [should match "src/**/*.js"]

I'm trying to commit alpha.js and src/bravo/charlie.js and expect both patterns given in lint-staged to each match one pattern, considering everything is relative to CWD. However neither matches.

If I prefix the patterns with **/ the files are matched. That's because the paths handed to minimatch are made absolute based on gitDir but not made relative against CWD again. The test suggests this is an oversight, or the test is mislabeled.

lint-staged v3.2.4
node v7.3.0
npm v3.10.10

my linters are engaged properly, if I replace the resolvePaths.js with the following:

module.exports = function resolvePaths(filePaths, relativeTo) {
    const cwd = process.cwd()
    const base = relativeTo || cwd
    return filePaths.map(file => path.relative(cwd, path.resolve(base, file.filename)))
}

Accept commands in addition to NPM scripts

Hey,

I was wondering why I have to add git add and eslint --fix to the npm scripts to use them with lint-staged.

For example my package.json has to be:

"scripts": {
  "git:add": "git add",
  "eslint:fix": "eslint --fix"
},
"lint-staged": {
  "*.js": ["eslint:fix", "git:add"]
}

and I think it could be:

"lint-staged": {
  "*.js": ["eslint --fix", "git add"]
}

Is there any limitation, I am not aware of, so it can't be supported?

When running with just 1 linter, it throws

node ./index.js
⠋ Starting lint-staged/Users/okonet/Projects/OSS/lint-staged/src/index.js:26
                spinner.text = 'Running ' + Array.isArray(linter) ? linter.join(' → ') : linter + '...'
                                                                           ^

TypeError: linter.join is not a function
    at /Users/okonet/Projects/OSS/lint-staged/src/index.js:26:76
    at Array.forEach (native)
    at /Users/okonet/Projects/OSS/lint-staged/src/index.js:22:30
    at /Users/okonet/Projects/OSS/lint-staged/node_modules/staged-git-files/index.js:20:21
    at ChildProcess.<anonymous> (/Users/okonet/Projects/OSS/lint-staged/node_modules/staged-git-files/index.js:88:9)
    at emitTwo (events.js:100:13)
    at ChildProcess.emit (events.js:185:7)
    at maybeClose (internal/child_process.js:850:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

Spaces in Windows Git executable path causing errors

I'm likely barking up the wrong tree here, but I have to use a Windows 7 virtual machine to develop a project and I ran into a path issue while trying to use lint-staged.

Error: Command failed: C:\Program Files (x86)\Git\cmd\git.EXE rev-parse --show-toplevel
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

    at checkExecSyncError (child_process.js:470:13)
    at Object.execSync (child_process.js:510:13)
    at Object.<anonymous> (E:\project\node_modules\lint-staged\src\index.js:12:15)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (E:\project\node_modules\lint-staged\index.js:2:1)

It seems the path to the Git executable isn't quoted properly, so the space inside is causing an issue. I'd imagine this is very likely to happen on most Windows systems, due to the default installation path containing a space.

I'm using Node v5.11.0 and NPM v3.8.6.

Support sequences of commands

Sometimes it's required to run a set of commands on same file. Consider this example:

  "scripts": {
    "stylelint-staged": "stylelint --syntax scss",
    "postcss-sorting": "postcss --syntax postcss-scss --config postcss-sorting.config.js --replace",
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "postcss-sorting": "*.scss",
    "stylelint-staged": "*.scss"
  }

This will run postcss-sorting and stylelint-staged in parallel. But what we want is to sort rules and then lint it — i.e. sequential run.

Together with #16 it should allow interesting workflows with almost zero configuration.

Support piping

Some packages implement stdin/out piping. For example $path | imageoptim should also be possible.

Work in subdirectory

@okonet thanks for awesome project.

We already add it for ESLint but have some strange issues with Stylelint. Sorry, I don’t know where I should look more.

package.json:

  "scripts": {
    "lint:css": "stylelint",
    "lint:js":  "eslint",
    "build":    "gulp build",
    "test":     "gulp"
  },
  "pre-commit": "lint-staged",
  "lint-staged": {
    "*.sss": "lint:css",
    "*.js":  "lint:js"
  }

When I add any .sss file to stage and run lint-stage I get:

Error: Files glob patterns specified did not match any files
    at /home/ai/Dev/amplifr/front/node_modules/stylelint/dist/standalone.js:83:19
😱  lint:css found some issues. Fix them and try again.

But when I run same stylelint script manually — npm run -s lint:css -- blocks/plan-viewport/plan-viewport.sss, everything works fine :-/

No output from linter

I've configured lint-staged with tslint.
tslint is run via npm-run-script:

"scripts": {
      "tslint": "tslint -c tslint.json"
}

"lint-staged": {
    "*.tsx": "tslint",
    "gitDir": "../"
}

When I run tslint directly via Npm, I get linting messages:

~/workspace/ibanking/ui> npm run --silent tslint -- src/common/ModalDialog.tsx
src/common/ModalDialog.tsx[23, 27]: missing whitespace

But when I run it using lint-staged, I get no messages, just the indication of failed process

~/workspace/ibanking/ui> lint-staged
 ❯ Running tasks for *.tsx
   ✖ tslint

🚫 tslint found some errors. Please fix them and try committing again.

Using [email protected], execa 0.6.0 on MacOS.

Provide a way to specify `--syntax` flag for stylelint

stylelint-staged detects syntax (i.e. SCSS) of committed files incorrectly — it throws errors that don't appear when stylelint is run normally. I'd guess that this is related to a new way that Stylelint requires syntax to be specified — it used to be defined in index.js, but now it is provided as param stylelint --syntax scss.

When a task in a sequence of tasks fails, it should fail the hook

Following config will pass the check and commit even if eslint task fails:

"scripts": {
    "eslint:fix": "eslint --fix",
    "git:add": "git add",
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "*.js": ["eslint:fix", "git:add"]
  },
  "pre-commit": [
    "lint-staged"
  ]

It should stop after the first non-zero exit code apparently.

Double lint errors, NPM errors

First of all: thanks for the neat script 👍

In my current setup I could not get it to work because my package.json is way deep in the project. But: using Husky and an insane gitDir works…

"scripts": {
  "lint-staged": "lint-staged",
  "lint-staged:js": "eslint ./source/Javascript/modules/foo/",
  "lint-staged:css": "stylelint './source/CSS/**/*.css'",
},

"precommit": "lint-staged",

"lint-staged": {
  "gitDir": "../../../../../../../../",
  "linters": {
    "*.js": "lint-staged:js",
    "*.css": "lint-staged:css"
  }
}

However: I noticed running (testing) npm run lint-staged outputs a lint error twice.

screenshot 2016-11-14 13 32 46

When I simply run the task npm run lint-staged:css the linter shows one error.

Any ideas?

PS: related to #45 I have the same question. Because stylelint (in my case) returns non-zero both the stylelint error and the NPM ERR! are shown. This happens both when running npm run lint-staged as well as it being run from precommit.

I guess we need the linter to return a non-zero, but the NPM ERR!'s are a bit noisy...

Doesn’t work in subdir

Preleased lint-staged works in subdirectory, but 3.1 doesn’t.

I tested, and got that lint-staged try to execute eslint with:

/home/ai/Dev/amplifr/front/node_modules/.bin/eslint -- /home/ai/Dev/amplifr/front/front/blocks/upload/upload.js

There are a two front/front in file path.

Error message in Github Desktop

This tool gave error nicely in CLI but I just wanted to share that I use GitHub for desktop too along with CLI and some other developers in my team use SourceTree too.

Commit error in Github Desktop looks like this

image

Whole error code copied

/Users/jitendravyas/.zim/init.zsh: line 16: syntax error near unexpected token `('
/Users/jitendravyas/.zim/init.zsh: line 16: `  for wanted_module (${zmodules}); do'
�[?25l �[33m❯�[39m Running tasks for *.css
   �[33m⠙�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠹�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠸�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠼�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠴�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠦�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠧�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠇�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠏�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠋�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠙�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠹�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠸�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠼�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[33m⠴�[39m stylelint
�[?25l�[1000D�[K�[1A�[1000D�[K�[1A�[1000D�[K �[33m❯�[39m Running tasks for *.css
   �[31m✖�[39m stylelint
�[?25h
🚨  stylelint found some errors. Please fix them and try committing again.



�[4mapp/styles/main.css�[24m
 �[2m2:17�[22m  �[31m�[31m�[31m�[31m�[31m�[31m�[31m�[31m�[31m�[31m✖�[31m�[39m  Expected "#FFFFFF" to be "#ffffff"              �[2m�[2m�[2m�[2mcolor-hex-case�[22m        
 �[2m7:1�[22m   �[31m�[31m�[31m�[31m�[31m�[31m�[31m�[31m�[31m�[31m✖�[31m�[39m  Unexpected duplicate selector ".main-section"   �[2m�[2m�[2m�[2mno-duplicate-selectors�[22m



�[?25hpre-commit: 
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint-staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit: 
pre-commit:   git commit -n (or --no-verify)
pre-commit: 
pre-commit: This is ill-advised since the commit is broken.
pre-commit: 
 (1)

git: 'Files\Git\mingw64\libexec\git-core\git.EXE' is not a git command. See 'git --help'.

Hi,
I just upgraded from 3.0.3 to 3.2.4 and got this error:

[12:16:25] Running tasks for **/scripts/**/*.js [started]
[12:16:25] eslint --fix --config ./.eslintrc-fix.yml [started]
[12:16:25] eslint --fix --config ./.eslintrc-fix.yml [completed]
[12:16:25] git add [started]
[12:16:25] git add [failed]
[12:16:25] Running tasks for **/scripts/**/*.js [failed]

� git add found some errors. Please fix them and try committing again.

git: 'Files\Git\mingw64\libexec\git-core\git.EXE' is not a git command. See 'git --help'.

I have lint-staged configured like this:

  "lint-staged": {
    ...,
    "**/scripts/**/*.js": [
      "eslint --fix --config ./.eslintrc-fix.yml",
      "git add"
    ],
    ...
  },

My guess is that there is some issue when git binary location contains space characters. In my case it is: C:\Program Files\Git\mingw64\libexec\git-core\git.exe

OS: Windows 10 Pro
npm: 3.10.10
node: 7.2.1

For the time being I am staying on 3.0.3 3.2.0 where everything works just fine.
Thank you for work you put in this awesome project 😄

Update:
It works on 3.2.0 as well

Lint staged array calling pre-configured scripts

Is it possible to do this (simply just run lint-staged on a script already pre-configured in the scripts section?)

"scripts": {
    "eslint": "./node_modules/.bin/eslint .",
    "stylelint": "./node_modules/.bin/stylelint statics/css/**/*.less --syntax less",
    "htmlhint": "./node_modules/.bin/htmlhint mvc/views",
    "lint": "npm run htmlhint && npm run stylelint && npm run eslint",
    "lint-staged": "lint-staged"
  },
  "lint-staged" [
    "htmlhint",
    "lesshint",
    "eslint"
  ]
  "pre-commit": [
    "lint-staged"
  ]

Make linters optional

  1. Remove linter packages from dependencies.
  2. Check in Shell scripts that particular linter is installed, show installation instructions otherwise.

Linting happening on unstaged files

So things seem to work as I would expect in 1.0.1 but not in 2.0.3 or @next.

I have 2 changed .scss files. One contains a linting error, the other does not.

In 1.0.1 I am able to do the following with no issues.

git add non-error-file.scss
git commit -m 'test'

It seems in v2+, the linter runs on staged and unstaged files as I get an error about the unstaged error-file.scss. Is this the intended behavior? I have no issues being on version 1 but I generally like to keep up to date on things.

Using .lintstagedrc file gives error

I get the following error:
TypeError: Cannot read property 'config' of null

I've copied the "lint-staged" section into the .lintstagedrc file.
{ "gitDir": "../../", "linters": { "*.js": "eslint" } }

Did I miss something?

Specify a different linter config file

Is there a way to specify a different linter config file than the .eslintrc in the project's root? There are certain rules I want disabled when I'm developing but still want to lint at commit time.

Wrong path with gitDir

My config is located in front/package.json and contains:

    "gitDir": "../",
    "*.sss": [
      "stylelint",
      "node ./front/postcss/sort",
      "git add"
    ],
    "*.js": "eslint"

If I was staged front/a.js file, lint-stage will execute front/node_modules/.bin/eslint a.js. There is no front/ in file path.

Maybe we should use absolute path there?

TypeError: Cannot create property 'context' on string

Hi there

I have the following setup in place on a project running on node 7.2.1 and npm 3.10.10.

{
  "scripts": {
    "lint:js": "semistandard",
    "lint:fix": "semistandard --fix",
    "lint:staged": "lint-staged",
  },
  "lint-staged": {
    "*.{js,jsx}": "lint:js"
  },
  "pre-commit": {
    "run": "lint:staged",
    "colors": true,
    "silent": true
  },
  "devDependencies": {
    "lint-staged": "^3.2.3",
    "pre-commit": "^1.2.2",
    "semistandard": "^9.2.1",
  }
}

All is okay here:

$ npm run lint:js

> [email protected] lint:js /Users/mberridge/Sites/example
> semistandard | snazzy

semistandard: Semicolons For All! (https://github.com/Flet/semistandard)

/Users/mberridge/Sites/example/src/index.js
  9:1  error  Parsing error: Unexpected token

✖ 1 problem

But running npm run lint:staged returns an error wrapped around the output:

$ npm run lint:staged

> [email protected] lint:staged /Users/mberridge/Sites/example
> lint-staged

 ❯ Running tasks for *.{js,jsx}
   ✖ lint:js
{ TypeError: Cannot create property 'context' on string '
🚫 lint:js found some errors. Please fix them and try committing again.

semistandard: Semicolons For All! (https://github.com/Flet/semistandard)

/Users/mberridge/Sites/example/src/index.js
  9:1  error  Parsing error: Unexpected token

✖ 1 problem

'
    at tasks.then.catch.err (/Users/mberridge/Sites/example/node_modules/lint-staged/node_modules/listr/index.js:74:17)
    at process._tickCallback (internal/process/next_tick.js:103:7) context: {} }

Not the end of the world, as it's still linting and working with pre-commit too.
But have I done something wrong to cause the error?

Any help appreciated, thanks all!

How to let 💩 slip into your code base

Hey,

thank you for the great work on #47 👍
Today I found out that you can trick lint-staged if you add code to the staging area which doesn't meet the linting rules and then change the file again to meet the rules before committing.

For example if you have forbidden semicolons in your .eslintrc you can commit code with semicolons if you:

  1. Stage the file with semicolons
  2. Change the file and remove all semicolons
  3. Commit the first file with semicolons but lint-staged will lint the second file without semicolons

I think it's not a big deal because you can always check the styleguide with travis on GitHub and you can run git commit --no-verify to skip commit hooks.

[Error: fatal: Not a git repository: '.git'

/home/theodor/projects/xxxxx/app/node_modules/lint-staged/src/resolvePaths.js:8
return filePaths.map(file => path.relative(cwd, path.resolve(base, file.filename)))
^

What am I missing ?

Switch from CLI to Node versions of libraries

It seems like using the shell (CLI) versions has too many issues: #5 #6 #7

The only way to resolve all of them would be going away from CLI and using Node API of libraries. This would allow more flexible configs. It should also fix issues with npm 2.x paths.

Issues with git workflow

This is valid for #75 and doesn't affect the published version!

Not sure how to reproduce but seems like if there were some stashes before for this file it ends up with

If one of the linters update the file contents then when we execute git stash pop where will be merge conflict for this file. We should execute git stash pop after the commit. I've added a test case here: 80ba161

 ✔ Running tasks for *.js
src/lib/__tests__/parseConfig.spec.js: unmerged (10b204cca737bc26f901456372c503354c43f815)
src/lib/__tests__/parseConfig.spec.js: unmerged (2f3e3c5f14e40ba9dcf6f5418deed76cb3757605)
src/lib/__tests__/parseConfig.spec.js: unmerged (a9ea7e10e0dda3995f214d84a0e72738d2115579)
error: Error building trees

Allow glob exclusions

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.