'Enforce (fix) imports to be fully on a single line

I have the following eslint config:

   "object-curly-newline": ["error", {
        "ImportDeclaration": "never",
        "ExportDeclaration": "never"
    }],

That transforms:

import { 
    something,
    somethingelse, 
} from "../here";

to

import { something,
    somethingelse, } from "../here";

but I'd like to get my import so it goes to a single line. Like so:

import { something, somethingelse, } from "../here";

Is there a way to do this within "object-curly-newline"? Or can I accomplish it via some other rule? I've tried the various other properties, but haven't had any luck.



Solution 1:[1]

I believe this might be related to the multiline setting of object-curly-newline, depending on your settings.

"multiline": true requires line breaks if there are line breaks inside properties or between properties. Otherwise, it disallows line breaks.

That is what I noticed in my situation.

enter image description here

You can see which rule applies before saving, by hovering over the red or yellow underlines. In my case these were shown underneath the curly braces.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1