ESLint排序导入多行换行



我想使用排序导入esint规则对导入语句进行排序,但当我进行多行导入时,它会将每个导入的东西都分解成一行。

我的问题是,我想使导入多行,但在指定的宽度后换行。

//My use case
import { a, b, c, z, x, h } from x;
//How is linting
import {
a
, b
, c
, h
, x
, z
} from x;
//How I want to works
import {
a, b, c
, h, x, z
} from x;

在这种只有3个导入的情况下,我不介意导入的东西只是在一行中,但我的问题是,当我有很多东西(比如导入20个ramda函数(时,我不想把每个导入的函数都分解成一行。

这是我目前的eslint+更漂亮的配置:

.eslintrc.json

{
"root": true,
"extends": [
"plugin:vue/essential",
"plugin:prettier/recommended",
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"env": {
"es6": true
},
"rules": {
"indent": ["error", 2],
"arrow-parens": ["error", "always"],
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true
}
],
"comma-style": ["error", "first"],
"comma-spacing" :["error", {
"after": true
}]
}
}

.petterrc.json

{
"arrowParens": "always",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": true,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}

您应该在eslint:recommended之后加载plugin:prettier/recommended,以停止esint重新格式化那些更漂亮的东西,从而减少

最新更新