Skip to content

Commit

Permalink
feat: adopt eslint-plugin-simple-import-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jul 18, 2024
1 parent c976ff2 commit f74757c
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 16 deletions.
10 changes: 9 additions & 1 deletion cfg/eslint-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,16 @@ module.exports = {
'undefined',
],
'id-match': 2,
'import/order': [
'simple-import-sort/imports': [
2,
{
// This is what "removes any newlines between imports":
groups: [['^\\u0000', '^node:', '^@?\\w', '^', '^\\.']],
},
],
'simple-import-sort/exports': 2,
'import/order': [
0, // disabled in favor of `simple-import-sort`
{
alphabetize: {
order: 'asc',
Expand Down
1 change: 1 addition & 0 deletions cfg/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = {
plugins: [
'jsdoc',
'import',
'simple-import-sort',
'@typescript-eslint',
// https://github.com/sweepline/eslint-plugin-unused-imports
'unused-imports',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^28.0.0",
"eslint-plugin-jsdoc": "^48.0.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unicorn": "^54.0.0",
"eslint-plugin-unused-imports": "^4.0.0",
"eslint-plugin-vue": "^9.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/lint-all.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import fs from 'node:fs'
import { _since, _truncate } from '@naturalcycles/js-lib'
import {
boldGrey,
dimGrey,
commitMessageToTitleMessage,
dimGrey,
execVoidCommandSync,
getLastGitCommitMsg,
gitCommitAll,
gitHasUncommittedChanges,
gitPull,
gitPush,
execVoidCommandSync,
} from '@naturalcycles/nodejs-lib'
import yargs from 'yargs'
import { runPrettier } from '../util/prettier.util'
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tsc-prod.command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { _since } from '@naturalcycles/js-lib'
import { execVoidCommandSync, boldGrey, dimGrey } from '@naturalcycles/nodejs-lib'
import { boldGrey, dimGrey, execVoidCommandSync } from '@naturalcycles/nodejs-lib'

export function tscProdCommand(): void {
// You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
Expand Down
28 changes: 21 additions & 7 deletions src/test/cfg/eslint.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"jest",
"unused-imports",
"@typescript-eslint",
"simple-import-sort",
"import",
"jsdoc"
],
Expand Down Expand Up @@ -656,15 +657,11 @@
2
],
"import/order": [
2,
0,
{
"alphabetize": {
"caseInsensitive": false,
"order": "asc",
"orderImportKind": "ignore"
},
"distinctGroup": true,
"warnOnUnassignedImports": false
"order": "asc"
}
}
],
"indent": [
Expand Down Expand Up @@ -1207,6 +1204,23 @@
"semi-style": [
"off"
],
"simple-import-sort/exports": [
2
],
"simple-import-sort/imports": [
2,
{
"groups": [
[
"^\\u0000",
"^node:",
"^@?\\w",
"^",
"^\\."
]
]
}
],
"space-after-function-name": [
"off"
],
Expand Down
2 changes: 1 addition & 1 deletion src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export * from './expect.util'
export * from './mockAllKindsOfThings'
export * from './testing.util'
export * from './time.util'
export { timekeeper, expectTypeOf }
export { expectTypeOf, timekeeper }
2 changes: 1 addition & 1 deletion src/testing/time.util.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mockTime, mockTimeMillis, MOCK_TS_2018_06_21, resetTime } from './time.util'
import { MOCK_TS_2018_06_21, mockTime, mockTimeMillis, resetTime } from './time.util'

const now = Date.now()

Expand Down
2 changes: 1 addition & 1 deletion src/util/jest.util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs'
import os from 'node:os'
import { _range, _uniq } from '@naturalcycles/js-lib'
import { execVoidCommandSync, dimGrey, white } from '@naturalcycles/nodejs-lib'
import { dimGrey, execVoidCommandSync, white } from '@naturalcycles/nodejs-lib'
import { cfgDir } from '../cnst/paths.cnst'
import { nodeModuleExists } from './test.util'

Expand Down
4 changes: 2 additions & 2 deletions src/util/tsc.util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'node:fs'
import { _isTruthy, _since } from '@naturalcycles/js-lib'
import {
execVoidCommand,
execVoidCommandSync,
boldGrey,
dimGrey,
execVoidCommand,
execVoidCommandSync,
kpySync,
} from '@naturalcycles/nodejs-lib'
import { cfgDir } from '../cnst/paths.cnst'
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,11 @@ eslint-plugin-jsdoc@^48.0.1:
spdx-expression-parse "^4.0.0"
synckit "^0.9.0"

eslint-plugin-simple-import-sort@^12.1.1:
version "12.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.1.1.tgz#e64bfdaf91c5b98a298619aa634a9f7aa43b709e"
integrity sha512-6nuzu4xwQtE3332Uz0to+TxDQYRLTKRESSc2hefVT48Zc8JthmN23Gx9lnYhu0FtkRSL1oxny3kJ2aveVhmOVA==

eslint-plugin-unicorn@^54.0.0:
version "54.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-54.0.0.tgz#ce3ea853e8fd7ca2bda2fd6065bf065adb5d8b6d"
Expand Down

0 comments on commit f74757c

Please sign in to comment.