1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

lint-stagedでeslintのwarnを許容しなくしたら何故かprettierが終わらなくなったので直した

Last updated at Posted at 2021-11-12

@typescript/use-unused-vars を error にはしたくないけど、コミットには含めたくなかったので、これをやった

そうしたら何故か prettier --write が永遠に終わらなくなったので直した話。

結論

filesprettier --write にも渡す

.lintstagedrc.js
// @see https://github.com/okonet/lint-staged/issues/1017

module.exports = {
  '**/*.{ts,tsx,js,jsx}': async files => {
    const filesToLint = await removeIgnoredFiles(files);
    return [`prettier --write ${filesToLint}`, `eslint --max-warning=0 ${filesToLint}`]
  }
}

詳細

もともとの設定がこんな感じだった

package.json
{
  "lint-staged": {
    "**/*.{ts,tsx,js,jsx}": ["prettier --write", "eslint"]
  }
}

これをwarnを許容しないようにするために設定を書き換えた。書く場所も package.json ではなく .lintstagedrc.js に変更。

.lintstagedrc.js
// @see https://github.com/okonet/lint-staged/issues/1017

module.exports = {
  '**/*.{ts,tsx,js,jsx}': async files => {
    const filesToLint = await removeIgnoredFiles(files);
    return ['prettier --write', `eslint --max-warning=0 ${filesToLint}`]
  }
}

これで動かしたら prettier --write が永遠に終わらなくなったので、色々調べてたら上にあげたissueにたどり着いた。

Since you are using the function syntax, it's assumed to pass the files yourself:

https://github.com/okonet/lint-staged/issues/1017#issuecomment-924312570

とのこと ほえ〜

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?