Skip to content

Commit fa404ff

Browse files
committed
ESLint: enforce import formatting
Mainly to reduce merge conflict noise - Order by origin & alphabetically - Imports should be at the top of the file - Newline between imports & the rest of the file - Disallow duplicate imports - Enforce single-line when only importing one object - Enforce multi-line when importing two or more
1 parent 917c36d commit fa404ff

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.eslintrc.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"unused-imports",
1010
"eslint-plugin-lodash",
1111
"eslint-plugin-jsonc",
12-
"eslint-plugin-rxjs"
12+
"eslint-plugin-rxjs",
13+
"eslint-plugin-simple-import-sort",
14+
"eslint-plugin-import-newlines"
1315
],
1416
"overrides": [
1517
{
@@ -210,9 +212,23 @@
210212

211213
"deprecation/deprecation": "warn",
212214

215+
"simple-import-sort/imports": "error",
216+
"simple-import-sort/exports": "error",
213217
"import/order": "off",
218+
"import/first": "error",
219+
"import/newline-after-import": "error",
220+
"import/no-duplicates": "error",
214221
"import/no-deprecated": "warn",
215222
"import/no-namespace": "error",
223+
"import-newlines/enforce": [
224+
"error",
225+
{
226+
"items": 1,
227+
"semi": true,
228+
"forceSingleLine": true
229+
}
230+
],
231+
216232
"unused-imports/no-unused-imports": "error",
217233
"lodash/import-scope": [
218234
"error",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,12 @@
169169
"eslint": "^8.39.0",
170170
"eslint-plugin-deprecation": "^1.4.1",
171171
"eslint-plugin-import": "^2.27.5",
172+
"eslint-plugin-import-newlines": "^1.3.1",
172173
"eslint-plugin-jsdoc": "^39.6.4",
173174
"eslint-plugin-jsonc": "^2.6.0",
174175
"eslint-plugin-lodash": "^7.4.0",
175176
"eslint-plugin-rxjs": "^5.0.3",
177+
"eslint-plugin-simple-import-sort": "^10.0.0",
176178
"eslint-plugin-unused-imports": "^2.0.0",
177179
"express-static-gzip": "^2.1.7",
178180
"jasmine-core": "^3.8.0",

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5296,6 +5296,11 @@ eslint-plugin-deprecation@^1.4.1:
52965296
tslib "^2.3.1"
52975297
tsutils "^3.21.0"
52985298

5299+
eslint-plugin-import-newlines@^1.3.1:
5300+
version "1.3.1"
5301+
resolved "https://registry.yarnpkg.com/eslint-plugin-import-newlines/-/eslint-plugin-import-newlines-1.3.1.tgz#e21705667778e8134382b50079fbb2c8d3a2fcde"
5302+
integrity sha512-7vyhwliGm+CTwteRw2ym+IO9OaksGYmSt63elPPBM0QJ3zwRwMKtgHOSHVtdHlrSERRTVCsWtMO8dDdAdmHMXg==
5303+
52995304
eslint-plugin-import@^2.27.5:
53005305
version "2.27.5"
53015306
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65"
@@ -5361,6 +5366,11 @@ eslint-plugin-rxjs@^5.0.3:
53615366
tsutils "^3.0.0"
53625367
tsutils-etc "^1.4.1"
53635368

5369+
eslint-plugin-simple-import-sort@^10.0.0:
5370+
version "10.0.0"
5371+
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-10.0.0.tgz#cc4ceaa81ba73252427062705b64321946f61351"
5372+
integrity sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==
5373+
53645374
eslint-plugin-unused-imports@^2.0.0:
53655375
version "2.0.0"
53665376
resolved "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz"

0 commit comments

Comments
 (0)