lintについてメモ

2019/10/21

htmllint

eslint

stylelint

Prettier

ESLint

stylelint

TypeError: Cannot set property 'useTabs' of nullが表示される場合の対処

Prettier周りのメモ

Stylelint

ESLint

error Replace ・・・・・・ with ・・・・・・・・のようなエラーが大量に出る

  39:1   error  Replace `・・・・・・` with `・・・・・・・・`
                prettier/prettier
  40:1   error  Insert `・・`

のようなエラーが大量に出る

スペース4つルールにしたかったのですが、どうにも直らなかったのでコードの方をデフォルトスペース2つにして適合させることにしました……。

以下試したルール。

.eslintrc.json

    "rules": {
        "indent": ["error", 4],
        "prettier/prettier": [
            "error",
            {
                //一行辺りの文字数
                "printWidth": 120,
                //折り返しをしない
                "proseWrap": "never",
                //インデント
                "indent": ["error", 4],
//略

.orettierrc

{
    "printWidth": 120,
    "proseWrap": "never",
    "indent": ["error", 4],
    "useTabs": false,
    "semi": true,
    "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 4 }],
    "singleQuote": true
}

package.json

    "prettier": {}

3箇所に"indent": ["error", 4],を入れたのですが効果なく、全て"indent": ["error", 2],に変えました……。

newline-per-chained-callが効かない

    "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 4 }],

を指定しているのに、チェーンメソッドが改行されてしまう問題。

//before
$navbar.find('.nav-item:not(.dropdown)').find('a').on('click', function() {

//after
$navbar
    .find('.nav-item:not(.dropdown)')
    .find('a')
    .on('click', function() {

同じ問題に当たっている方は散見されるのですが、これといって解決策が今のところ見付かっていません。


Written by Circle
A mound built by the accumulation of hyperlinks are like Kowloon.