为语句中的特定填充保留规则

时间:2020-02-25 19:35:35

标签: eslint

我希望能够格式化我的语句,使其看起来像这样

if (accepts === 'json') {

    next()
}

if (!isTestEnv) {

    // @ts-ignore
    if (nuxtConfig.dev) {

        const builder = new Builder(nuxt)

        await builder.build()

    } else {

        await nuxt.ready()
    }

    nuxt(req, res, next)
}

我在.eslintrc.js中的当前尝试如下:

rules: {
        'arrow-parens': 0,
        'generator-star-spacing': 0,
        // allow debugger during development
        'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
        'space-before-function-paren': ['error', 'always'],
        semi: 'error',
        indent: ['error', 4],
        'padded-blocks': ['error', { 'blocks': 'always' }],
        'space-in-parens': ['error', 'never'],
        'object-curly-spacing': ['error', 'always'],
        'padding-line-between-statements': [
            'error',
            {
                blankLine: 'always',
                prev: ['const', 'let', 'var', '*'],
                next: '*',
            },
            {
                blankLine: 'any',
                prev: ['const', 'let', 'var'],
                next: ['const', 'let', 'var'],
            },
            {
                blankLine: 'never',
                prev: '*',
                next: ['if']
            }
        ],
        'array-bracket-spacing': ['error', 'never'],
        'curly': ['error', 'all'],
        'default-case': 'error',
        'brace-style': ['error', '1tbs']
    }

enter image description here

  1. ESLint:此语句之前出现空白行。(padding-line-between-statements)
  2. ESLint:块必须用空白行填充。(papped-blocks)
  3. ESLint:此语句之前出现空白行。(padding-line-between-statements)
  4. ESLint:块必须用空白行填充。(papped-blocks)
  5. ESLint:块必须用空白行填充。(papped-blocks)

0 个答案:

没有答案