When using import/newline-after-import with typescript import = require(..) I get a false positive requiring me to put a newline in the middle of the imports.
import foo from "foo";
import bar = require("bar");
import baz from "baz";
No errors
1:1 error Expected 1 empty line after import statement not followed by another import import/newline-after-import
note: import equal declaration is typescript specific syntax and its defined as TSImportEqualsDeclaration
https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
to avoid side effects, syntax like this should also be supported
(this is valid syntax when targeting common js)
export import bar = require("bar");
While that syntax is only required/useful when TS's module system is broken (ie, when synthetic imports and esModuleInterop are not both enabled), I agree that code using it should work with this plugin.
Also got into valid for typescript case:
import {API} from './some/exports';
import InnerType = API.some.comfort.namespaces.InnerType;
Should be:
VALID:
import {API} from './some/exports';
import InnerType = API.some.comfort.namespaces.InnerType;
const i = 1;
INVALID:
import {API} from './some/exports';
import InnerType = API.some.comfort.namespaces.InnerType;
const i = 1;
INVALID:
import {API} from './some/exports';
import InnerType = API.some.comfort.namespaces.InnerType;
INVALID:
import {API} from './some/exports';
import InnerType = API.some.comfort.namespaces.InnerType;
const i = 1;
More broadly, is there any option to get the plugin to always treat import X = require('Y') as though they were regular import statements?
This seems to have broader effects in other rules as well. --fix won't fix sort order for anything that comes after the first = require statement for example. This unfortunately halted our migration from tslint since it was a show stopper for us :/
It's marked as help wanted if anyone could point me in the right direction I'd be happy to give it a shot :)
(I'd still strongly recommend everyone migrate away from TS-specific syntax; import X from 'Y' is what should be used in that case, with synthetic imports and esModuleInterop enabled, as tsc --init enables)
Most helpful comment
Also got into valid for typescript case:
Should be:
VALID:
INVALID:
INVALID:
INVALID: