I'd like to use the sort-imports eslint rule for sorting imports statements, but when I hace a multiline import it breaks every imported thing into a new line.
My problem is that I want to make imports multiline, but wrapping after an specified width.
//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;
In this case with just 3 imports I dont mind if the imported things are just in one line, but my problem is when i have a lot of thing (like if I'm importing 20 ramda functions) and I dont want to break every imported function into a new line.
This is my currently eslint + prettier config:
.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
}]
}
}
.prettierrc.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
}
You should load plugin:prettier/recommended
after eslint:recommended
to stop eslint reformatting stuff that prettier takes care off
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.