From 6121ef49f26c144076c2f2e799f360d9257294c7 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 24 Jul 2024 14:56:18 -0700 Subject: [PATCH] Enable import sorting (#308) --- .eslintrc | 9 +++++++++ .eslintrc.json | 6 ------ lib/src/compiler/utils.ts | 2 +- lib/src/dispatcher.ts | 2 +- lib/src/importer-registry.ts | 2 +- lib/src/legacy/importer.ts | 6 +++--- lib/src/legacy/index.ts | 6 +++--- lib/src/message-transformer.test.ts | 2 +- lib/src/packet-transformer.test.ts | 2 +- lib/src/protofier.ts | 8 ++++---- lib/src/sync-process/sync-message-port.ts | 2 +- lib/src/sync-process/worker.ts | 6 +++--- lib/src/value/argument-list.ts | 2 +- lib/src/value/calculations.ts | 2 +- lib/src/value/list.ts | 2 +- lib/src/value/number.ts | 2 +- tool/utils.ts | 2 +- 17 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 .eslintrc delete mode 100644 .eslintrc.json diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..f135f8dd --- /dev/null +++ b/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": "./node_modules/gts/", + "rules": { + "prefer-const": ["error", {"destructuring": "all"}], + // It would be nice to sort import declaration order as well, but that's not + // autofixable and it's not worth the effort of handling manually. + "sort-imports": ["error", {"ignoreDeclarationSort": true}], + } +} diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index d4323578..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./node_modules/gts/", - "rules": { - "prefer-const": ["error", {"destructuring": "all"}] - } -} diff --git a/lib/src/compiler/utils.ts b/lib/src/compiler/utils.ts index 09fa031d..80e1e0fc 100644 --- a/lib/src/compiler/utils.ts +++ b/lib/src/compiler/utils.ts @@ -4,7 +4,7 @@ import * as p from 'path'; import * as supportsColor from 'supports-color'; -import {deprecations, getDeprecationIds, Deprecation} from '../deprecations'; +import {Deprecation, deprecations, getDeprecationIds} from '../deprecations'; import {deprotofySourceSpan} from '../deprotofy-span'; import {Dispatcher, DispatcherHandlers} from '../dispatcher'; import {Exception} from '../exception'; diff --git a/lib/src/dispatcher.ts b/lib/src/dispatcher.ts index a99dee96..48cafefb 100644 --- a/lib/src/dispatcher.ts +++ b/lib/src/dispatcher.ts @@ -8,7 +8,7 @@ import {filter, map, mergeMap, takeUntil} from 'rxjs/operators'; import {OutboundResponse} from './messages'; import * as proto from './vendor/embedded_sass_pb'; import {RequestTracker} from './request-tracker'; -import {PromiseOr, compilerError, thenOr, hostError} from './utils'; +import {PromiseOr, compilerError, hostError, thenOr} from './utils'; // A callback that accepts a response or error. type ResponseCallback = ( diff --git a/lib/src/importer-registry.ts b/lib/src/importer-registry.ts index 749a912b..691b4af2 100644 --- a/lib/src/importer-registry.ts +++ b/lib/src/importer-registry.ts @@ -11,7 +11,7 @@ import {CanonicalizeContext} from './canonicalize-context'; import * as utils from './utils'; import {FileImporter, Importer, Options} from './vendor/sass'; import * as proto from './vendor/embedded_sass_pb'; -import {catchOr, thenOr, PromiseOr} from './utils'; +import {PromiseOr, catchOr, thenOr} from './utils'; const entryPointDirectoryKey = Symbol(); diff --git a/lib/src/legacy/importer.ts b/lib/src/legacy/importer.ts index 5977a3d5..68b79e11 100644 --- a/lib/src/legacy/importer.ts +++ b/lib/src/legacy/importer.ts @@ -9,11 +9,11 @@ import * as util from 'util'; import {resolvePath} from './resolve-path'; import { + PromiseOr, + SyncBoolean, fileUrlToPathCrossPlatform, isErrnoException, thenOr, - PromiseOr, - SyncBoolean, } from '../utils'; import { Importer, @@ -26,10 +26,10 @@ import { LegacySyncImporter, } from '../vendor/sass'; import { - pathToLegacyFileUrl, legacyFileUrlToPath, legacyImporterProtocol, legacyImporterProtocolPrefix, + pathToLegacyFileUrl, } from './utils'; /** diff --git a/lib/src/legacy/index.ts b/lib/src/legacy/index.ts index d5001e7b..f5467565 100644 --- a/lib/src/legacy/index.ts +++ b/lib/src/legacy/index.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import * as p from 'path'; -import {pathToFileURL, URL} from 'url'; +import {URL, pathToFileURL} from 'url'; import {NodePackageImporter} from '../importer-registry'; import {Exception} from '../exception'; @@ -15,11 +15,11 @@ import { compileStringAsync, } from '../compile'; import { + SyncBoolean, fileUrlToPathCrossPlatform, isNullOrUndefined, pathToUrlString, withoutExtension, - SyncBoolean, } from '../utils'; import { CompileResult, @@ -34,7 +34,7 @@ import { StringOptions, } from '../vendor/sass'; import {wrapFunction} from './value/wrap'; -import {endOfLoadProtocol, LegacyImporterWrapper} from './importer'; +import {LegacyImporterWrapper, endOfLoadProtocol} from './importer'; import { legacyImporterProtocol, pathToLegacyFileUrl, diff --git a/lib/src/message-transformer.test.ts b/lib/src/message-transformer.test.ts index d74f2e28..767999c9 100644 --- a/lib/src/message-transformer.test.ts +++ b/lib/src/message-transformer.test.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {Subject, Observable} from 'rxjs'; +import {Observable, Subject} from 'rxjs'; import * as varint from 'varint'; import {expectObservableToError} from '../../test/utils'; diff --git a/lib/src/packet-transformer.test.ts b/lib/src/packet-transformer.test.ts index 4533f002..603801f0 100644 --- a/lib/src/packet-transformer.test.ts +++ b/lib/src/packet-transformer.test.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {Subject, Observable} from 'rxjs'; +import {Observable, Subject} from 'rxjs'; import {PacketTransformer} from './packet-transformer'; diff --git a/lib/src/protofier.ts b/lib/src/protofier.ts index e2d7f951..00fa3c52 100644 --- a/lib/src/protofier.ts +++ b/lib/src/protofier.ts @@ -10,19 +10,19 @@ import {FunctionRegistry} from './function-registry'; import {SassArgumentList} from './value/argument-list'; import {SassColor} from './value/color'; import {SassFunction} from './value/function'; -import {SassList, ListSeparator} from './value/list'; +import {ListSeparator, SassList} from './value/list'; import {SassMap} from './value/map'; import {SassNumber} from './value/number'; import {SassString} from './value/string'; import {Value} from './value'; import {sassNull} from './value/null'; -import {sassTrue, sassFalse} from './value/boolean'; +import {sassFalse, sassTrue} from './value/boolean'; import { - CalculationValue, - SassCalculation, CalculationInterpolation, CalculationOperation, CalculationOperator, + CalculationValue, + SassCalculation, } from './value/calculations'; import {SassMixin} from './value/mixin'; diff --git a/lib/src/sync-process/sync-message-port.ts b/lib/src/sync-process/sync-message-port.ts index 6c4a8751..7c82a343 100644 --- a/lib/src/sync-process/sync-message-port.ts +++ b/lib/src/sync-process/sync-message-port.ts @@ -5,10 +5,10 @@ import {strict as assert} from 'assert'; import {EventEmitter} from 'events'; import { - receiveMessageOnPort, MessageChannel, MessagePort, TransferListItem, + receiveMessageOnPort, } from 'worker_threads'; // TODO(nex3): Make this its own package. diff --git a/lib/src/sync-process/worker.ts b/lib/src/sync-process/worker.ts index 2b6e4c13..89542961 100644 --- a/lib/src/sync-process/worker.ts +++ b/lib/src/sync-process/worker.ts @@ -3,12 +3,12 @@ // https://opensource.org/licenses/MIT. import { - parentPort, - workerData, MessagePort, TransferListItem, + parentPort, + workerData, } from 'worker_threads'; -import {spawn, SpawnOptionsWithoutStdio} from 'child_process'; +import {SpawnOptionsWithoutStdio, spawn} from 'child_process'; import {strict as assert} from 'assert'; import {SyncMessagePort} from './sync-message-port'; diff --git a/lib/src/value/argument-list.ts b/lib/src/value/argument-list.ts index b898796a..029e2658 100644 --- a/lib/src/value/argument-list.ts +++ b/lib/src/value/argument-list.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {isOrderedMap, List, OrderedMap} from 'immutable'; +import {List, OrderedMap, isOrderedMap} from 'immutable'; import {ListSeparator, SassList} from './list'; import {Value} from './index'; diff --git a/lib/src/value/calculations.ts b/lib/src/value/calculations.ts index ce32f610..ca3eebe4 100644 --- a/lib/src/value/calculations.ts +++ b/lib/src/value/calculations.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {hash, List, ValueObject} from 'immutable'; +import {List, ValueObject, hash} from 'immutable'; import {Value} from './index'; import {SassNumber} from './number'; diff --git a/lib/src/value/list.ts b/lib/src/value/list.ts index 97ec57d8..d8175bb0 100644 --- a/lib/src/value/list.ts +++ b/lib/src/value/list.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {hash, isList, List} from 'immutable'; +import {List, hash, isList} from 'immutable'; import {Value} from './index'; import {SassMap} from './map'; diff --git a/lib/src/value/number.ts b/lib/src/value/number.ts index 9bf26cc8..11d69e56 100644 --- a/lib/src/value/number.ts +++ b/lib/src/value/number.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {hash, List} from 'immutable'; +import {List, hash} from 'immutable'; import {asImmutableList, valueError} from '../utils'; import {Value} from './index'; diff --git a/tool/utils.ts b/tool/utils.ts index fe1ee82a..21f10779 100644 --- a/tool/utils.ts +++ b/tool/utils.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {promises as fs, existsSync, lstatSync} from 'fs'; +import {existsSync, promises as fs, lstatSync} from 'fs'; import * as p from 'path'; import * as shell from 'shelljs';