From a72459fa838900c0c78b8c84160fef5e9316e917 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:40:14 -0800 Subject: [PATCH] Bump gts from 5.3.1 to 6.0.2 (#345) * Bump gts from 5.3.1 to 6.0.2 Bumps [gts](https://github.com/google/gts) from 5.3.1 to 6.0.2. - [Release notes](https://github.com/google/gts/releases) - [Changelog](https://github.com/google/gts/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gts/compare/v5.3.1...v6.0.2) --- updated-dependencies: - dependency-name: gts dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * run "npm run fix" with gts v6 Fixes needed because `gts` turned on `composite: true`: * Add package.json to tsconfig. The file is referenced by TS files. * Add a declarationDir `_types`. This directory is ignored. This is necessary because we can't omit `declarations`. --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Carlos (Goodwine) <2022649+Goodwine@users.noreply.github.com> --- .gitignore | 1 + bin/sass.ts | 2 +- lib/src/compile.ts | 8 +-- lib/src/compiler-path.ts | 12 ++-- lib/src/compiler.test.ts | 4 +- lib/src/compiler/async.ts | 22 ++++---- lib/src/compiler/sync.ts | 16 +++--- lib/src/compiler/utils.ts | 18 +++--- lib/src/deprecations.ts | 14 ++--- lib/src/dispatcher.ts | 34 +++++------ lib/src/elf.ts | 8 +-- lib/src/function-registry.ts | 18 +++--- lib/src/importer-registry.ts | 42 +++++++------- lib/src/legacy/importer.ts | 26 ++++----- lib/src/legacy/index.ts | 34 +++++------ lib/src/legacy/resolve-path.ts | 2 +- lib/src/legacy/utils.ts | 4 +- lib/src/legacy/value/color.ts | 4 +- lib/src/legacy/value/list.ts | 6 +- lib/src/legacy/value/map.ts | 14 ++--- lib/src/legacy/value/number.ts | 2 +- lib/src/legacy/value/wrap.ts | 9 ++- lib/src/message-transformer.test.ts | 10 ++-- lib/src/message-transformer.ts | 4 +- lib/src/packet-transformer.test.ts | 4 +- lib/src/packet-transformer.ts | 4 +- lib/src/protofier.ts | 54 +++++++++--------- lib/src/request-tracker.test.ts | 8 +-- lib/src/request-tracker.ts | 6 +- lib/src/sync-process/index.test.ts | 8 +-- lib/src/sync-process/index.ts | 14 ++--- .../sync-process/sync-message-port.test.ts | 10 ++-- lib/src/sync-process/sync-message-port.ts | 10 ++-- lib/src/sync-process/worker.ts | 2 +- lib/src/utils.test.ts | 6 +- lib/src/utils.ts | 12 ++-- lib/src/value/argument-list.ts | 2 +- lib/src/value/calculations.ts | 8 +-- lib/src/value/color.ts | 56 +++++++++---------- lib/src/value/function.ts | 2 +- lib/src/value/index.ts | 2 +- lib/src/value/list.ts | 8 +-- lib/src/value/map.ts | 4 +- lib/src/value/number.ts | 36 ++++++------ lib/src/value/string.ts | 4 +- lib/src/value/utils.ts | 4 +- lib/src/version.ts | 4 +- package.json | 2 +- test/dependencies.test.ts | 4 +- test/sandbox.ts | 6 +- test/utils.ts | 4 +- tool/get-embedded-compiler.ts | 2 +- tool/get-language-repo.ts | 2 +- tool/prepare-optional-release.ts | 6 +- tool/prepare-release.ts | 4 +- tool/utils.ts | 6 +- tsconfig.json | 3 +- 57 files changed, 313 insertions(+), 308 deletions(-) diff --git a/.gitignore b/.gitignore index cc631e31..1a7ad2ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +_types build dist lib/src/vendor diff --git a/bin/sass.ts b/bin/sass.ts index d25d834a..80c60125 100755 --- a/bin/sass.ts +++ b/bin/sass.ts @@ -14,7 +14,7 @@ try { { stdio: 'inherit', windowsHide: true, - } + }, ); } catch (error) { if (error.code) { diff --git a/lib/src/compile.ts b/lib/src/compile.ts index 0f249945..d6993f78 100644 --- a/lib/src/compile.ts +++ b/lib/src/compile.ts @@ -11,7 +11,7 @@ export {NodePackageImporter} from './importer-registry'; export function compile( path: string, - options?: OptionsWithLegacy<'sync'> + options?: OptionsWithLegacy<'sync'>, ): CompileResult { const compiler = initCompiler(); try { @@ -23,7 +23,7 @@ export function compile( export function compileString( source: string, - options?: StringOptionsWithLegacy<'sync'> + options?: StringOptionsWithLegacy<'sync'>, ): CompileResult { const compiler = initCompiler(); try { @@ -35,7 +35,7 @@ export function compileString( export async function compileAsync( path: string, - options?: OptionsWithLegacy<'async'> + options?: OptionsWithLegacy<'async'>, ): Promise { const compiler = await initAsyncCompiler(); try { @@ -47,7 +47,7 @@ export async function compileAsync( export async function compileStringAsync( source: string, - options?: StringOptionsWithLegacy<'async'> + options?: StringOptionsWithLegacy<'async'>, ): Promise { const compiler = await initAsyncCompiler(); try { diff --git a/lib/src/compiler-path.ts b/lib/src/compiler-path.ts index 0097ac28..b9344cf5 100644 --- a/lib/src/compiler-path.ts +++ b/lib/src/compiler-path.ts @@ -17,7 +17,7 @@ function isLinuxMusl(path: string): boolean { return p.basename(interpreter).startsWith('ld-musl-'); } catch (error) { console.warn( - `Warning: Failed to detect linux-musl, fallback to linux-gnu: ${error.message}` + `Warning: Failed to detect linux-musl, fallback to linux-gnu: ${error.message}`, ); return false; } @@ -37,7 +37,7 @@ export const compilerCommand = (() => { const executable = p.resolve( __dirname, path, - `dart-sass/sass${platform === 'win32' ? '.bat' : ''}` + `dart-sass/sass${platform === 'win32' ? '.bat' : ''}`, ); if (fs.existsSync(executable)) return [executable]; @@ -47,10 +47,10 @@ export const compilerCommand = (() => { return [ require.resolve( `sass-embedded-${platform}-${arch}/dart-sass/src/dart` + - (platform === 'win32' ? '.exe' : '') + (platform === 'win32' ? '.exe' : ''), ), require.resolve( - `sass-embedded-${platform}-${arch}/dart-sass/src/sass.snapshot` + `sass-embedded-${platform}-${arch}/dart-sass/src/sass.snapshot`, ), ]; } catch (ignored) { @@ -61,7 +61,7 @@ export const compilerCommand = (() => { return [ require.resolve( `sass-embedded-${platform}-${arch}/dart-sass/sass` + - (platform === 'win32' ? '.bat' : '') + (platform === 'win32' ? '.bat' : ''), ), ]; } catch (e: unknown) { @@ -74,6 +74,6 @@ export const compilerCommand = (() => { "Embedded Dart Sass couldn't find the embedded compiler executable. " + 'Please make sure the optional dependency ' + `sass-embedded-${platform}-${arch} is installed in ` + - 'node_modules.' + 'node_modules.', ); })(); diff --git a/lib/src/compiler.test.ts b/lib/src/compiler.test.ts index df72f27e..2da0c0b6 100644 --- a/lib/src/compiler.test.ts +++ b/lib/src/compiler.test.ts @@ -110,7 +110,7 @@ describe('asyncCompiler', () => { describe('compilation ID', () => { it('resets after concurrent compilations complete', async () => { await Promise.all( - Array.from({length: 10}, () => asyncCompiler.compileStringAsync('')) + Array.from({length: 10}, () => asyncCompiler.compileStringAsync('')), ); await asyncCompiler.compileStringAsync(''); expect(getIdHistory()).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]); @@ -118,7 +118,7 @@ describe('asyncCompiler', () => { it('keeps working after failed compilations', async () => { await expect( - asyncCompiler.compileStringAsync('invalid') + asyncCompiler.compileStringAsync('invalid'), ).rejects.toThrow(); await Promise.all([ asyncCompiler.compileStringAsync(''), diff --git a/lib/src/compiler/async.ts b/lib/src/compiler/async.ts index ad577db2..e85c1409 100644 --- a/lib/src/compiler/async.ts +++ b/lib/src/compiler/async.ts @@ -46,10 +46,10 @@ export class AsyncCompiler { cwd: path.dirname(compilerCommand[0]), // Node blocks launching .bat and .cmd without a shell due to CVE-2024-27980 shell: ['.bat', '.cmd'].includes( - path.extname(compilerCommand[0]).toLowerCase() + path.extname(compilerCommand[0]).toLowerCase(), ), windowsHide: true, - } + }, ); /** The next compilation ID. */ @@ -101,7 +101,7 @@ export class AsyncCompiler { private async compileRequestAsync( request: proto.InboundMessage_CompileRequest, importers: ImporterRegistry<'async'>, - options?: OptionsWithLegacy<'async'> & {legacy?: boolean} + options?: OptionsWithLegacy<'async'> & {legacy?: boolean}, ): Promise { const optionsKey = Symbol(); activeDeprecationOptions.set(optionsKey, options ?? {}); @@ -116,7 +116,7 @@ export class AsyncCompiler { handleFileImportRequest: request => importers.fileImport(request), handleCanonicalizeRequest: request => importers.canonicalize(request), handleFunctionCallRequest: request => functions.call(request), - } + }, ); dispatcher.logEvents$.subscribe(event => handleLogEvent(options, event)); @@ -133,7 +133,7 @@ export class AsyncCompiler { } else { resolve(response!); } - }) + }), ); this.compilations.add(compilation); @@ -148,7 +148,7 @@ export class AsyncCompiler { if (flag !== initFlag) { throw utils.compilerError( 'AsyncCompiler can not be directly constructed. ' + - 'Please use `sass.initAsyncCompiler()` instead.' + 'Please use `sass.initAsyncCompiler()` instead.', ); } this.stderr$.subscribe(data => process.stderr.write(data)); @@ -157,33 +157,33 @@ export class AsyncCompiler { }); this.messageTransformer = new MessageTransformer( packetTransformer.outboundProtobufs$, - packet => packetTransformer.writeInboundProtobuf(packet) + packet => packetTransformer.writeInboundProtobuf(packet), ); } compileAsync( path: string, - options?: OptionsWithLegacy<'async'> + options?: OptionsWithLegacy<'async'>, ): Promise { this.throwIfDisposed(); const importers = new ImporterRegistry(options); return this.compileRequestAsync( newCompilePathRequest(path, importers, options), importers, - options + options, ); } compileStringAsync( source: string, - options?: StringOptionsWithLegacy<'async'> + options?: StringOptionsWithLegacy<'async'>, ): Promise { this.throwIfDisposed(); const importers = new ImporterRegistry(options); return this.compileRequestAsync( newCompileStringRequest(source, importers, options), importers, - options + options, ); } diff --git a/lib/src/compiler/sync.ts b/lib/src/compiler/sync.ts index 936ca903..9ca992ad 100644 --- a/lib/src/compiler/sync.ts +++ b/lib/src/compiler/sync.ts @@ -46,10 +46,10 @@ export class Compiler { cwd: path.dirname(compilerCommand[0]), // Node blocks launching .bat and .cmd without a shell due to CVE-2024-27980 shell: ['.bat', '.cmd'].includes( - path.extname(compilerCommand[0]).toLowerCase() + path.extname(compilerCommand[0]).toLowerCase(), ), windowsHide: true, - } + }, ); /** The next compilation ID. */ @@ -107,7 +107,7 @@ export class Compiler { private compileRequestSync( request: proto.InboundMessage_CompileRequest, importers: ImporterRegistry<'sync'>, - options?: OptionsWithLegacy<'sync'> + options?: OptionsWithLegacy<'sync'>, ): CompileResult { const optionsKey = Symbol(); activeDeprecationOptions.set(optionsKey, options ?? {}); @@ -122,7 +122,7 @@ export class Compiler { handleFileImportRequest: request => importers.fileImport(request), handleCanonicalizeRequest: request => importers.canonicalize(request), handleFunctionCallRequest: request => functions.call(request), - } + }, ); this.dispatchers.add(dispatcher); @@ -168,7 +168,7 @@ export class Compiler { if (flag !== initFlag) { throw utils.compilerError( 'Compiler can not be directly constructed. ' + - 'Please use `sass.initAsyncCompiler()` instead.' + 'Please use `sass.initAsyncCompiler()` instead.', ); } this.stderr$.subscribe(data => process.stderr.write(data)); @@ -177,7 +177,7 @@ export class Compiler { }); this.messageTransformer = new MessageTransformer( packetTransformer.outboundProtobufs$, - packet => packetTransformer.writeInboundProtobuf(packet) + packet => packetTransformer.writeInboundProtobuf(packet), ); } @@ -187,7 +187,7 @@ export class Compiler { return this.compileRequestSync( newCompilePathRequest(path, importers, options), importers, - options + options, ); } @@ -197,7 +197,7 @@ export class Compiler { return this.compileRequestSync( newCompileStringRequest(source, importers, options), importers, - options + options, ); } diff --git a/lib/src/compiler/utils.ts b/lib/src/compiler/utils.ts index f04f03fc..7bc0fe94 100644 --- a/lib/src/compiler/utils.ts +++ b/lib/src/compiler/utils.ts @@ -51,13 +51,13 @@ export type StringOptionsWithLegacy = export function createDispatcher( compilationId: number, messageTransformer: MessageTransformer, - handlers: DispatcherHandlers + handlers: DispatcherHandlers, ): Dispatcher { return new Dispatcher( compilationId, messageTransformer.outboundMessages$, message => messageTransformer.writeInboundMessage(message), - handlers + handlers, ); } @@ -65,7 +65,7 @@ export function createDispatcher( // input-specific options. function newCompileRequest( importers: ImporterRegistry<'sync' | 'async'>, - options?: Options<'sync' | 'async'> + options?: Options<'sync' | 'async'>, ): proto.InboundMessage_CompileRequest { const request = create(proto.InboundMessage_CompileRequestSchema, { importers: importers.importers, @@ -103,7 +103,7 @@ function newCompileRequest( export function newCompilePathRequest( path: string, importers: ImporterRegistry<'sync' | 'async'>, - options?: Options<'sync' | 'async'> + options?: Options<'sync' | 'async'>, ): proto.InboundMessage_CompileRequest { const absPath = p.resolve(path); const request = newCompileRequest(importers, options); @@ -115,7 +115,7 @@ export function newCompilePathRequest( export function newCompileStringRequest( source: string, importers: ImporterRegistry<'sync' | 'async'>, - options?: StringOptions<'sync' | 'async'> + options?: StringOptions<'sync' | 'async'>, ): proto.InboundMessage_CompileRequest { const input = create(proto.InboundMessage_CompileRequest_StringInputSchema, { source, @@ -134,7 +134,7 @@ export function newCompileStringRequest( proto.InboundMessage_CompileRequest_ImporterSchema, { importer: {case: 'path', value: p.resolve('.')}, - } + }, ); } else { // When importer is not set on the host, the compiler will set a @@ -148,7 +148,7 @@ export function newCompileStringRequest( /** Type guard to check that `id` is a valid deprecation ID. */ function validDeprecationId( - id: string | number | symbol | undefined + id: string | number | symbol | undefined, ): id is keyof typeof deprecations { return !!id && id in deprecations; } @@ -156,7 +156,7 @@ function validDeprecationId( /** Handles a log event according to `options`. */ export function handleLogEvent( options: OptionsWithLegacy<'sync' | 'async'> | undefined, - event: proto.OutboundMessage_LogEvent + event: proto.OutboundMessage_LogEvent, ): void { let span = event.span ? deprotofySourceSpan(event.span) : null; if (span && options?.legacy) span = removeLegacyImporterFromSpan(span); @@ -210,7 +210,7 @@ export function handleLogEvent( * Throws a `SassException` if the compilation failed. */ export function handleCompileResponse( - response: proto.OutboundMessage_CompileResponse + response: proto.OutboundMessage_CompileResponse, ): CompileResult { if (response.result.case === 'success') { const success = response.result.value; diff --git a/lib/src/deprecations.ts b/lib/src/deprecations.ts index e284b562..6763d072 100644 --- a/lib/src/deprecations.ts +++ b/lib/src/deprecations.ts @@ -13,7 +13,7 @@ export {Deprecation, DeprecationOrId, DeprecationStatus} from './vendor/sass'; * that's ready to include in a CompileRequest. */ export function getDeprecationIds( - arr: (DeprecationOrId | Version)[] + arr: (DeprecationOrId | Version)[], ): string[] { return arr.map(item => { if (item instanceof Version) { @@ -52,7 +52,7 @@ export type DeprecationOptions = Pick< export function warnForHostSideDeprecation( message: string, deprecation: Deprecation, - options?: DeprecationOptions + options?: DeprecationOptions, ): void { if ( deprecation.status === 'future' && @@ -75,7 +75,7 @@ export function warnForHostSideDeprecation( */ function isSilent( deprecation: Deprecation, - options?: DeprecationOptions + options?: DeprecationOptions, ): boolean { if (!options) { for (const potentialOptions of activeDeprecationOptions.values()) { @@ -84,7 +84,7 @@ function isSilent( return false; } return getDeprecationIds(options.silenceDeprecations ?? []).includes( - deprecation.id + deprecation.id, ); } @@ -94,7 +94,7 @@ function isSilent( */ function isEnabledFuture( deprecation: Deprecation, - options?: DeprecationOptions + options?: DeprecationOptions, ): boolean { if (!options) { for (const potentialOptions of activeDeprecationOptions.values()) { @@ -103,7 +103,7 @@ function isEnabledFuture( return activeDeprecationOptions.size > 0; } return getDeprecationIds(options.futureDeprecations ?? []).includes( - deprecation.id + deprecation.id, ); } @@ -113,7 +113,7 @@ function isEnabledFuture( */ function isFatal( deprecation: Deprecation, - options?: DeprecationOptions + options?: DeprecationOptions, ): boolean { if (!options) { for (const potentialOptions of activeDeprecationOptions.values()) { diff --git a/lib/src/dispatcher.ts b/lib/src/dispatcher.ts index 00cf9bc1..784c1068 100644 --- a/lib/src/dispatcher.ts +++ b/lib/src/dispatcher.ts @@ -14,7 +14,7 @@ import {PromiseOr, compilerError, hostError, thenOr} from './utils'; // A callback that accepts a response or error. type ResponseCallback = ( err: unknown, - response: proto.OutboundMessage_CompileResponse | undefined + response: proto.OutboundMessage_CompileResponse | undefined, ) => void; /** @@ -68,7 +68,7 @@ export class Dispatcher { */ readonly logEvents$ = this.messages$.pipe( filter(message => message.message.case === 'logEvent'), - map(message => message.message.value as proto.OutboundMessage_LogEvent) + map(message => message.message.value as proto.OutboundMessage_LogEvent), ); constructor( @@ -77,9 +77,9 @@ export class Dispatcher { [number, proto.OutboundMessage] >, private readonly writeInboundMessage: ( - message: [number, proto.InboundMessage] + message: [number, proto.InboundMessage], ) => void, - private readonly outboundRequestHandlers: DispatcherHandlers + private readonly outboundRequestHandlers: DispatcherHandlers, ) { if (compilationId < 1) { throw Error(`Invalid compilation ID ${compilationId}.`); @@ -95,7 +95,7 @@ export class Dispatcher { ? result.then(() => message) : [message]; }), - takeUntil(this.unsubscribe$) + takeUntil(this.unsubscribe$), ) .subscribe({ next: message => this.messages$.next(message), @@ -118,7 +118,7 @@ export class Dispatcher { */ sendCompileRequest( request: proto.InboundMessage_CompileRequest, - callback: ResponseCallback + callback: ResponseCallback, ): void { // Call the callback but unsubscribe first const callback_: ResponseCallback = (err, response) => { @@ -134,7 +134,7 @@ export class Dispatcher { this.messages$ .pipe( filter(message => message.message.case === 'compileResponse'), - map(message => message.message.value as OutboundResponse) + map(message => message.message.value as OutboundResponse), ) .subscribe({next: response => callback_(null, response)}); @@ -173,7 +173,7 @@ export class Dispatcher { // contains a request, runs the appropriate callback to generate an inbound // response, and then sends it inbound. private handleOutboundMessage( - message: proto.OutboundMessage + message: proto.OutboundMessage, ): PromiseOr { switch (message.message.case) { case 'logEvent': @@ -194,7 +194,7 @@ export class Dispatcher { this.outboundRequestHandlers.handleImportRequest(request), response => { this.sendInboundMessage(id, {case: type, value: response}); - } + }, ); } @@ -207,7 +207,7 @@ export class Dispatcher { this.outboundRequestHandlers.handleFileImportRequest(request), response => { this.sendInboundMessage(id, {case: type, value: response}); - } + }, ); } @@ -220,7 +220,7 @@ export class Dispatcher { this.outboundRequestHandlers.handleCanonicalizeRequest(request), response => { this.sendInboundMessage(id, {case: type, value: response}); - } + }, ); } @@ -233,7 +233,7 @@ export class Dispatcher { this.outboundRequestHandlers.handleFunctionCallRequest(request), response => { this.sendInboundMessage(id, {case: type, value: response}); - } + }, ); } @@ -251,7 +251,7 @@ export class Dispatcher { message: Exclude< proto.InboundMessage['message'], {case: undefined | 'compileRequest'} - > + >, ): void { message.value.id = requestId; @@ -278,15 +278,15 @@ export class Dispatcher { */ export interface DispatcherHandlers { handleImportRequest: ( - request: proto.OutboundMessage_ImportRequest + request: proto.OutboundMessage_ImportRequest, ) => PromiseOr; handleFileImportRequest: ( - request: proto.OutboundMessage_FileImportRequest + request: proto.OutboundMessage_FileImportRequest, ) => PromiseOr; handleCanonicalizeRequest: ( - request: proto.OutboundMessage_CanonicalizeRequest + request: proto.OutboundMessage_CanonicalizeRequest, ) => PromiseOr; handleFunctionCallRequest: ( - request: proto.OutboundMessage_FunctionCallRequest + request: proto.OutboundMessage_FunctionCallRequest, ) => PromiseOr; } diff --git a/lib/src/elf.ts b/lib/src/elf.ts index 1cd396a6..91a48296 100644 --- a/lib/src/elf.ts +++ b/lib/src/elf.ts @@ -8,7 +8,7 @@ import * as fs from 'fs'; function readFileDescriptor( fd: number, position: number, - length: number + length: number, ): Buffer { const buffer = Buffer.alloc(length); let offset = 0; @@ -31,7 +31,7 @@ export function getElfInterpreter(path: string): string { const fd = fs.openSync(path, 'r'); try { const elfIdentification = new DataView( - readFileDescriptor(fd, 0, 64).buffer + readFileDescriptor(fd, 0, 64).buffer, ); if ( @@ -72,8 +72,8 @@ export function getElfInterpreter(path: string): string { readFileDescriptor( fd, programHeadersOffset, - programHeadersEntrySize * programHeadersEntryCount - ).buffer + programHeadersEntrySize * programHeadersEntryCount, + ).buffer, ); for (let i = 0; i < programHeadersEntryCount; i++) { const byteOffset = i * programHeadersEntrySize; diff --git a/lib/src/function-registry.ts b/lib/src/function-registry.ts index c9921205..8d5fe45c 100644 --- a/lib/src/function-registry.ts +++ b/lib/src/function-registry.ts @@ -50,7 +50,7 @@ export class FunctionRegistry { * Returns the function to which `request` refers and returns its response. */ call( - request: proto.OutboundMessage_FunctionCallRequest + request: proto.OutboundMessage_FunctionCallRequest, ): PromiseOr { const protofier = new Protofier(this); const fn = this.get(request); @@ -60,8 +60,8 @@ export class FunctionRegistry { return thenOr( fn( request.arguments.map( - value => protofier.deprotofy(value) as types.Value - ) + value => protofier.deprotofy(value) as types.Value, + ), ), result => { if (!(result instanceof Value)) { @@ -79,19 +79,19 @@ export class FunctionRegistry { result: {case: 'success', value: protofier.protofy(result)}, accessedArgumentLists: protofier.accessedArgumentLists, }); - } + }, ); }, error => create(proto.InboundMessage_FunctionCallResponseSchema, { result: {case: 'error', value: `${error}`}, - }) + }), ); } /** Returns the function to which `request` refers. */ private get( - request: proto.OutboundMessage_FunctionCallRequest + request: proto.OutboundMessage_FunctionCallRequest, ): CustomFunction { if (request.identifier.case === 'name') { const fn = this.functionsByName.get(request.identifier.value); @@ -99,7 +99,7 @@ export class FunctionRegistry { throw compilerError( 'Invalid OutboundMessage_FunctionCallRequest: there is no function ' + - `named "${request.identifier.value}"` + `named "${request.identifier.value}"`, ); } else if (request.identifier.case === 'functionId') { const fn = this.functionsById.get(request.identifier.value); @@ -107,12 +107,12 @@ export class FunctionRegistry { throw compilerError( 'Invalid OutboundMessage_FunctionCallRequest: there is no function ' + - `with ID "${request.identifier.value}"` + `with ID "${request.identifier.value}"`, ); } else { throw compilerError( 'Invalid OutboundMessage_FunctionCallRequest: function identifier is ' + - 'unset' + 'unset', ); } } diff --git a/lib/src/importer-registry.ts b/lib/src/importer-registry.ts index 085ca4b0..3cefef96 100644 --- a/lib/src/importer-registry.ts +++ b/lib/src/importer-registry.ts @@ -33,7 +33,7 @@ export class NodePackageImporter { throw new Error( 'The Node package importer cannot determine an entry point ' + 'because `require.main.filename` is not defined. ' + - 'Please provide an `entryPointDirectory` to the `NodePackageImporter`.' + 'Please provide an `entryPointDirectory` to the `NodePackageImporter`.', ); } this[entryPointDirectoryKey] = entryPointDirectory; @@ -61,25 +61,25 @@ export class ImporterRegistry { this.importers = (options?.importers ?? []) .map(importer => this.register( - importer as Importer | FileImporter | NodePackageImporter - ) + importer as Importer | FileImporter | NodePackageImporter, + ), ) .concat( (options?.loadPaths ?? []).map(path => create(proto.InboundMessage_CompileRequest_ImporterSchema, { importer: {case: 'path', value: p.resolve(path)}, - }) - ) + }), + ), ); } /** Converts an importer to a proto without adding it to `this.importers`. */ register( - importer: Importer | FileImporter | NodePackageImporter + importer: Importer | FileImporter | NodePackageImporter, ): proto.InboundMessage_CompileRequest_Importer { const message = create( proto.InboundMessage_CompileRequest_ImporterSchema, - {} + {}, ); if (importer instanceof NodePackageImporter) { const importerMessage = create(proto.NodePackageImporterSchema, { @@ -93,7 +93,7 @@ export class ImporterRegistry { if ('findFileUrl' in importer) { throw new Error( 'Importer may not contain both canonicalize() and findFileUrl(): ' + - inspect(importer) + inspect(importer), ); } @@ -101,7 +101,7 @@ export class ImporterRegistry { message.nonCanonicalScheme = typeof importer.nonCanonicalScheme === 'string' ? [importer.nonCanonicalScheme] - : importer.nonCanonicalScheme ?? []; + : (importer.nonCanonicalScheme ?? []); this.importersById.set(this.id, importer); } else { message.importer = {case: 'fileImporterId', value: this.id}; @@ -113,7 +113,7 @@ export class ImporterRegistry { /** Handles a canonicalization request. */ canonicalize( - request: proto.OutboundMessage_CanonicalizeRequest + request: proto.OutboundMessage_CanonicalizeRequest, ): PromiseOr { const importer = this.importersById.get(request.importerId); if (!importer) { @@ -122,7 +122,7 @@ export class ImporterRegistry { const canonicalizeContext = new CanonicalizeContext( request.containingUrl ? new URL(request.containingUrl) : null, - request.fromImport + request.fromImport, ); return catchOr( @@ -136,19 +136,19 @@ export class ImporterRegistry { ? {case: undefined} : {case: 'url', value: url.toString()}, containingUrlUnused: !canonicalizeContext.containingUrlAccessed, - }) + }), ); }, error => create(proto.InboundMessage_CanonicalizeResponseSchema, { result: {case: 'error', value: `${error}`}, - }) + }), ); } /** Handles an import request. */ import( - request: proto.OutboundMessage_ImportRequest + request: proto.OutboundMessage_ImportRequest, ): PromiseOr { const importer = this.importersById.get(request.importerId); if (!importer) { @@ -165,14 +165,14 @@ export class ImporterRegistry { throw Error( `Invalid argument (contents): must be a string but was: ${ (result.contents as {}).constructor.name - }` + }`, ); } if (result.sourceMapUrl && !result.sourceMapUrl.protocol) { throw Error( 'Invalid argument (sourceMapUrl): must be absolute but was: ' + - result.sourceMapUrl + result.sourceMapUrl, ); } @@ -191,13 +191,13 @@ export class ImporterRegistry { error => create(proto.InboundMessage_ImportResponseSchema, { result: {case: 'error', value: `${error}`}, - }) + }), ); } /** Handles a file import request. */ fileImport( - request: proto.OutboundMessage_FileImportRequest + request: proto.OutboundMessage_FileImportRequest, ): PromiseOr { const importer = this.fileImportersById.get(request.importerId); if (!importer) { @@ -206,7 +206,7 @@ export class ImporterRegistry { const canonicalizeContext = new CanonicalizeContext( request.containingUrl ? new URL(request.containingUrl) : null, - request.fromImport + request.fromImport, ); return catchOr( @@ -229,13 +229,13 @@ export class ImporterRegistry { result: {case: 'fileUrl', value: url.toString()}, containingUrlUnused: !canonicalizeContext.containingUrlAccessed, }); - } + }, ); }, error => create(proto.InboundMessage_FileImportResponseSchema, { result: {case: 'error', value: `${error}`}, - }) + }), ); } } diff --git a/lib/src/legacy/importer.ts b/lib/src/legacy/importer.ts index 4cc5903e..a88b7171 100644 --- a/lib/src/legacy/importer.ts +++ b/lib/src/legacy/importer.ts @@ -85,7 +85,7 @@ export class LegacyImporterWrapper private readonly callbacks: Array>, private readonly loadPaths: string[], initialPrev: string, - private readonly sync: SyncBoolean + private readonly sync: SyncBoolean, ) { const path = initialPrev !== 'stdin'; this.prev.push({url: path ? p.resolve(initialPrev) : 'stdin', path}); @@ -93,7 +93,7 @@ export class LegacyImporterWrapper canonicalize( url: string, - options: {fromImport: boolean; containingUrl: URL | null} + options: {fromImport: boolean; containingUrl: URL | null}, ): PromiseOr { if (url.startsWith(endOfLoadProtocol)) return new URL(url); @@ -131,7 +131,7 @@ export class LegacyImporterWrapper // specifically we want to resolve them on the filesystem to ensure // locality. const urlWithoutPrefix = url.substring( - legacyImporterProtocolPrefix.length + legacyImporterProtocolPrefix.length, ); if (urlWithoutPrefix.startsWith('file:')) { let resolved: string | null = null; @@ -185,7 +185,7 @@ export class LegacyImporterWrapper if ('file' in result) { return new URL( legacyImporterProtocol + - encodeURI((result as {file: string}).file) + encodeURI((result as {file: string}).file), ); } else if (/^[A-Za-z+.-]+:/.test(url)) { return new URL(`${legacyImporterProtocolPrefix}${url}`); @@ -204,7 +204,7 @@ export class LegacyImporterWrapper for (const prefix of prefixes) { const resolved = resolvePath( p.join(prefix, result.file), - options.fromImport + options.fromImport, ); if (resolved !== null) return pathToLegacyFileUrl(resolved); } @@ -223,13 +223,13 @@ export class LegacyImporterWrapper for (const loadPath of this.loadPaths) { const resolved = resolvePath( p.join(loadPath, url), - options.fromImport + options.fromImport, ); if (resolved !== null) return pathToLegacyFileUrl(resolved); } return null; } - } + }, ); } @@ -279,7 +279,7 @@ export class LegacyImporterWrapper private invokeCallbacks( url: string, prev: string, - {fromImport}: {fromImport: boolean} + {fromImport}: {fromImport: boolean}, ): PromiseOr { assert(this.callbacks.length > 0); @@ -287,7 +287,7 @@ export class LegacyImporterWrapper self.options = {...self.options, context: self}; const invokeNthCallback = ( - n: number + n: number, ): PromiseOr => thenOr( this.invokeCallback(this.callbacks[n], self, url, prev), @@ -304,11 +304,11 @@ export class LegacyImporterWrapper throw new Error( `Invalid argument (contents): must be a string but was: ${ (result.contents as {}).constructor.name - }` + }`, ); } return result; - } + }, ); return invokeNthCallback(0); @@ -319,7 +319,7 @@ export class LegacyImporterWrapper callback: LegacyImporter, self: LegacyImporterThis, url: string, - prev: string + prev: string, ): PromiseOr { if (this.sync) { return (callback as LegacySyncImporter).call(self, url, prev); @@ -331,7 +331,7 @@ export class LegacyImporterWrapper self, url, prev, - resolve + resolve, ); if (syncResult !== undefined) resolve(syncResult); diff --git a/lib/src/legacy/index.ts b/lib/src/legacy/index.ts index 1093b1e8..a669dca9 100644 --- a/lib/src/legacy/index.ts +++ b/lib/src/legacy/index.ts @@ -45,7 +45,7 @@ import { export function render( options: LegacyOptions<'async'>, - callback: (error?: LegacyException, result?: LegacyResult) => void + callback: (error?: LegacyException, result?: LegacyResult) => void, ): void { try { options = adjustOptions(options); @@ -56,7 +56,7 @@ export function render( 'Dart Sass 2.0.0.\n\n' + 'More info: https://sass-lang.com/d/legacy-js-api', deprecations['legacy-js-api'], - options + options, ); const compileSass = isStringOptions(options) ? compileStringAsync(options.data, convertStringOptions(options, false)) @@ -64,7 +64,7 @@ export function render( compileSass.then( result => callback(undefined, newLegacyResult(options, start, result)), - error => callback(newLegacyException(error)) + error => callback(newLegacyException(error)), ); } catch (error) { if (error instanceof Error) callback(newLegacyException(error)); @@ -81,7 +81,7 @@ export function renderSync(options: LegacyOptions<'sync'>): LegacyResult { 'Dart Sass 2.0.0.\n\n' + 'More info: https://sass-lang.com/d/legacy-js-api', deprecations['legacy-js-api'], - options + options, ); const result = isStringOptions(options) ? compileString(options.data, convertStringOptions(options, true)) @@ -95,7 +95,7 @@ export function renderSync(options: LegacyOptions<'sync'>): LegacyResult { // Does some initial adjustments of `options` to make it easier to pass to the // new API. function adjustOptions( - options: LegacyOptions + options: LegacyOptions, ): LegacyOptions { if (!('file' in options && options.file) && !('data' in options)) { throw new Error('Either options.data or options.file must be set.'); @@ -128,7 +128,7 @@ function adjustOptions( // Returns whether `options` is a `LegacyStringOptions`. function isStringOptions( - options: LegacyOptions + options: LegacyOptions, ): options is LegacyStringOptions { return 'data' in options; } @@ -136,7 +136,7 @@ function isStringOptions( // Converts `LegacyOptions` into new API `Options`. function convertOptions( options: LegacyOptions, - sync: SyncBoolean + sync: SyncBoolean, ): Options & {legacy: true} { if ( 'outputStyle' in options && @@ -167,7 +167,7 @@ function convertOptions( : [options.importer], options.includePaths ?? [], options.file ?? 'stdin', - sync + sync, ), ] : undefined; @@ -196,14 +196,14 @@ function convertOptions( // Converts `LegacyStringOptions` into new API `StringOptions`. function convertStringOptions( options: LegacyStringOptions, - sync: SyncBoolean + sync: SyncBoolean, ): StringOptions & {legacy: true} { const modernOptions = convertOptions(options, sync); // Use a no-op base importer, because the LegacyImporterWrapper will emulate // the base importer by itself in order to mark containingUrl as accessed. const importer = modernOptions.importers?.some( - importer => importer instanceof LegacyImporterWrapper + importer => importer instanceof LegacyImporterWrapper, ) ? { canonicalize() { @@ -229,7 +229,7 @@ function convertStringOptions( // Determines whether a sourceMap was requested by the call to `render()`. function wasSourceMapRequested( - options: LegacySharedOptions<'sync' | 'async'> + options: LegacySharedOptions<'sync' | 'async'>, ): boolean { return ( typeof options.sourceMap === 'string' || @@ -239,7 +239,7 @@ function wasSourceMapRequested( // Creates the `this` value that's used for callbacks. function pluginThis( - options: LegacyOptions<'sync' | 'async'> + options: LegacyOptions<'sync' | 'async'>, ): LegacyPluginThis { const pluginThis: LegacyPluginThis = { options: { @@ -269,7 +269,7 @@ function pluginThis( function newLegacyResult( options: LegacyOptions<'sync' | 'async'>, start: number, - result: CompileResult + result: CompileResult, ): LegacyResult { const end = Date.now(); @@ -287,7 +287,7 @@ function newLegacyResult( if (options.outFile) { sourceMap.file = pathToUrlString( - p.relative(sourceMapDir, options.outFile) + p.relative(sourceMapDir, options.outFile), ); } else if (options.file) { sourceMap.file = pathToUrlString(withoutExtension(options.file) + '.css'); @@ -301,7 +301,7 @@ function newLegacyResult( source = removeLegacyImporter(source); if (source.startsWith('file://')) { return pathToUrlString( - p.relative(sourceMapDir, fileUrlToPathCrossPlatform(source)) + p.relative(sourceMapDir, fileUrlToPathCrossPlatform(source)), ); } else if (source.startsWith('data:')) { return 'stdin'; @@ -316,11 +316,11 @@ function newLegacyResult( let url; if (options.sourceMapEmbed) { url = `data:application/json;base64,${sourceMapBytes.toString( - 'base64' + 'base64', )}`; } else if (options.outFile) { url = pathToUrlString( - p.relative(p.dirname(options.outFile), sourceMapPath) + p.relative(p.dirname(options.outFile), sourceMapPath), ); } else { url = pathToUrlString(sourceMapPath); diff --git a/lib/src/legacy/resolve-path.ts b/lib/src/legacy/resolve-path.ts index 365c69db..12994e7d 100644 --- a/lib/src/legacy/resolve-path.ts +++ b/lib/src/legacy/resolve-path.ts @@ -64,7 +64,7 @@ function exactlyOne(paths: string[]): string | null { throw new Error( "It's not clear which file to import. Found:\n" + - paths.map(path => ' ' + path).join('\n') + paths.map(path => ' ' + path).join('\n'), ); } diff --git a/lib/src/legacy/utils.ts b/lib/src/legacy/utils.ts index 4e379e2f..b2850861 100644 --- a/lib/src/legacy/utils.ts +++ b/lib/src/legacy/utils.ts @@ -26,7 +26,7 @@ export const legacyImporterProtocolPrefix = 'legacy-importer-'; // should be removed from human-readable messages. const removeLegacyImporterRegExp = new RegExp( `${legacyImporterProtocol}|${legacyImporterProtocolPrefix}`, - 'g' + 'g', ); // Returns `string` with all instances of legacy importer syntax removed. @@ -42,7 +42,7 @@ export function removeLegacyImporterFromSpan(span: SourceSpan): SourceSpan { ...span, url: new URL( removeLegacyImporter(span.url.toString()), - pathToFileURL(process.cwd()) + pathToFileURL(process.cwd()), ), }; } diff --git a/lib/src/legacy/value/color.ts b/lib/src/legacy/value/color.ts index 94581b7f..b0f2d9d6 100644 --- a/lib/src/legacy/value/color.ts +++ b/lib/src/legacy/value/color.ts @@ -14,7 +14,7 @@ export class LegacyColor extends LegacyValueBase { redOrArgb: number | SassColor, green?: number, blue?: number, - alpha?: number + alpha?: number, ) { if (redOrArgb instanceof SassColor) { super(redOrArgb); @@ -38,7 +38,7 @@ export class LegacyColor extends LegacyValueBase { green: clamp(green as number, 0, 255), blue: clamp(blue as number, 0, 255), alpha: alpha ? clamp(alpha, 0, 1) : 1, - }) + }), ); } diff --git a/lib/src/legacy/value/list.ts b/lib/src/legacy/value/list.ts index 8ce130e2..238f96e6 100644 --- a/lib/src/legacy/value/list.ts +++ b/lib/src/legacy/value/list.ts @@ -21,7 +21,7 @@ export class LegacyList extends LegacyValueBase { super( new SassList(new Array(lengthOrInner).fill(sassNull), { separator: commaSeparator === false ? ' ' : ',', - }) + }), ); } @@ -29,7 +29,7 @@ export class LegacyList extends LegacyValueBase { const length = this.inner.asList.size; if (index < 0 || index >= length) { throw new Error( - `Invalid index ${index}, must be between 0 and ${length}` + `Invalid index ${index}, must be between 0 and ${length}`, ); } const value = this.inner.get(index); @@ -42,7 +42,7 @@ export class LegacyList extends LegacyValueBase { { separator: this.inner.separator, brackets: this.inner.hasBrackets, - } + }, ); } diff --git a/lib/src/legacy/value/map.ts b/lib/src/legacy/value/map.ts index 05ed23cc..48a15851 100644 --- a/lib/src/legacy/value/map.ts +++ b/lib/src/legacy/value/map.ts @@ -25,9 +25,9 @@ export class LegacyMap extends LegacyValueBase { Array.from({length: lengthOrInner}, (_, i) => [ new SassNumber(i), sassNull, - ]) - ) - ) + ]), + ), + ), ); } @@ -36,7 +36,7 @@ export class LegacyMap extends LegacyValueBase { if (index < 0 || !value) { throw new Error( `Invalid index ${index}, must be between 0 and ` + - this.inner.contents.size + this.inner.contents.size, ); } @@ -45,7 +45,7 @@ export class LegacyMap extends LegacyValueBase { setValue(index: number, value: LegacyValue): void { this.inner = new SassMap( - this.inner.contents.set(this.getUnwrappedKey(index), unwrapValue(value)) + this.inner.contents.set(this.getUnwrappedKey(index), unwrapValue(value)), ); } @@ -59,7 +59,7 @@ export class LegacyMap extends LegacyValueBase { if (index >= 0 && key) return key; throw new Error( `Invalid index ${index}, must be between 0 and ` + - this.inner.contents.size + this.inner.contents.size, ); } @@ -67,7 +67,7 @@ export class LegacyMap extends LegacyValueBase { const oldMap = this.inner.contents; if (index < 0 || index >= oldMap.size) { throw new Error( - `Invalid index ${index}, must be between 0 and ${oldMap.size}` + `Invalid index ${index}, must be between 0 and ${oldMap.size}`, ); } diff --git a/lib/src/legacy/value/number.ts b/lib/src/legacy/value/number.ts index c8c60cff..4a7849a6 100644 --- a/lib/src/legacy/value/number.ts +++ b/lib/src/legacy/value/number.ts @@ -10,7 +10,7 @@ export class LegacyNumber extends LegacyValueBase { super( valueOrInner instanceof SassNumber ? valueOrInner - : parseNumber(valueOrInner, unit) + : parseNumber(valueOrInner, unit), ); } diff --git a/lib/src/legacy/value/wrap.ts b/lib/src/legacy/value/wrap.ts index 7da2e1cd..952fec86 100644 --- a/lib/src/legacy/value/wrap.ts +++ b/lib/src/legacy/value/wrap.ts @@ -32,12 +32,15 @@ import * as types from '../../vendor/sass'; export function wrapFunction( thisArg: LegacyPluginThis, callback: LegacyFunction, - sync: SyncBoolean + sync: SyncBoolean, ): CustomFunction { if (sync) { return args => unwrapTypedValue( - (callback as LegacyFunction<'sync'>).apply(thisArg, args.map(wrapValue)) + (callback as LegacyFunction<'sync'>).apply( + thisArg, + args.map(wrapValue), + ), ); } else { return args => @@ -57,7 +60,7 @@ export function wrapFunction( // The cast here is necesary to work around microsoft/TypeScript#33815. const syncResult = (callback as (...args: unknown[]) => unknown).apply( thisArg, - [...args.map(wrapValue), done] + [...args.map(wrapValue), done], ); if (syncResult !== undefined) resolve(unwrapTypedValue(syncResult)); diff --git a/lib/src/message-transformer.test.ts b/lib/src/message-transformer.test.ts index 7053139b..d6b84fc8 100644 --- a/lib/src/message-transformer.test.ts +++ b/lib/src/message-transformer.test.ts @@ -35,7 +35,7 @@ describe('message transformer', () => { beforeEach(() => { encodedProtobufs = []; messages = new MessageTransformer(new Observable(), buffer => - encodedProtobufs.push(buffer) + encodedProtobufs.push(buffer), ); }); @@ -76,7 +76,7 @@ describe('message transformer', () => { ( response.result .value as proto.OutboundMessage_CompileResponse_CompileSuccess - ).css + ).css, ).toBe('a {b: c}'); done(); }, @@ -87,9 +87,9 @@ describe('message transformer', () => { ...varint.encode(1234), ...toBinary( proto.InboundMessageSchema, - validInboundMessage('a {b: c}') + validInboundMessage('a {b: c}'), ), - ]) + ]), ); protobufs$.complete(); }); @@ -100,7 +100,7 @@ describe('message transformer', () => { messages.outboundMessages$, 'Compiler caused error: Invalid compilation ID varint: RangeError: ' + 'Could not decode varint.', - done + done, ); protobufs$.next(Buffer.from([-1])); diff --git a/lib/src/message-transformer.ts b/lib/src/message-transformer.ts index dd508396..a33af0bd 100644 --- a/lib/src/message-transformer.ts +++ b/lib/src/message-transformer.ts @@ -34,7 +34,7 @@ export class MessageTransformer { constructor( private readonly outboundProtobufs$: Observable, - private readonly writeInboundProtobuf: (buffer: Uint8Array) => void + private readonly writeInboundProtobuf: (buffer: Uint8Array) => void, ) { this.outboundProtobufs$ .pipe(map(decode)) @@ -79,7 +79,7 @@ function decode(buffer: Uint8Array): [number, OutboundMessage] { compilationId, fromBinary( OutboundMessageSchema, - new Uint8Array(buffer.buffer, varint.decode.bytes) + new Uint8Array(buffer.buffer, varint.decode.bytes), ), ]; } catch (error) { diff --git a/lib/src/packet-transformer.test.ts b/lib/src/packet-transformer.test.ts index 78297883..59e8b102 100644 --- a/lib/src/packet-transformer.test.ts +++ b/lib/src/packet-transformer.test.ts @@ -15,7 +15,7 @@ describe('packet transformer', () => { beforeEach(() => { encodedBuffers = []; packets = new PacketTransformer(new Observable(), buffer => - encodedBuffers.push(buffer) + encodedBuffers.push(buffer), ); }); @@ -133,7 +133,7 @@ describe('packet transformer', () => { it('decodes a single chunk', done => { expectDecoding( [Buffer.from([1, 2, 3, 4]), Buffer.from([101, 102])], - done + done, ); rawBuffers$.next(Buffer.from([4, 1, 2, 3, 4, 2, 101, 102])); diff --git a/lib/src/packet-transformer.ts b/lib/src/packet-transformer.ts index 0322216b..2ef57f26 100644 --- a/lib/src/packet-transformer.ts +++ b/lib/src/packet-transformer.ts @@ -36,7 +36,7 @@ export class PacketTransformer { constructor( private readonly outboundBuffers$: Observable, - private readonly writeInboundBuffer: (buffer: Buffer) => void + private readonly writeInboundBuffer: (buffer: Buffer) => void, ) { this.outboundBuffers$ .pipe(mergeMap(buffer => this.decode(buffer))) @@ -175,7 +175,7 @@ class Packet { // the current message is split across multiple chunks). const bytesToWrite = Math.min( this.payload.length - this.payloadOffset, - source.length - i + source.length - i, ); this.payload.set(source.subarray(i, i + bytesToWrite), this.payloadOffset); this.payloadOffset += bytesToWrite; diff --git a/lib/src/protofier.ts b/lib/src/protofier.ts index 9b53e56e..95be0868 100644 --- a/lib/src/protofier.ts +++ b/lib/src/protofier.ts @@ -53,7 +53,7 @@ export class Protofier { * This is used to register first-class functions so that the compiler may * invoke them. */ - private readonly functions: FunctionRegistry<'sync' | 'async'> + private readonly functions: FunctionRegistry<'sync' | 'async'>, ) {} /** Converts `value` to its protocol buffer representation. */ @@ -160,7 +160,7 @@ export class Protofier { /** Converts `calculation` to its protocol buffer representation. */ private protofyCalculation( - calculation: SassCalculation + calculation: SassCalculation, ): proto.Value_Calculation { return create(proto.Value_CalculationSchema, { name: calculation.name, @@ -173,7 +173,7 @@ export class Protofier { /** Converts a CalculationValue that appears within a `SassCalculation` to * its protocol buffer representation. */ private protofyCalculationValue( - value: Object + value: Object, ): proto.Value_Calculation_CalculationValue { const result = create(proto.Value_Calculation_CalculationValueSchema, {}); if (value instanceof SassCalculation) { @@ -204,7 +204,7 @@ export class Protofier { /** Converts `operator` to its protocol buffer representation. */ private protofyCalculationOperator( - operator: CalculationOperator + operator: CalculationOperator, ): proto.CalculationOperator { switch (operator) { case '+': @@ -318,13 +318,13 @@ export class Protofier { if (separator === null && list.contents.length > 1) { throw utils.compilerError( `Value.List ${list} can't have an undecided separator because it ` + - `has ${list.contents.length} elements` + `has ${list.contents.length} elements`, ); } return new SassList( list.contents.map(element => this.deprotofy(element)), - {separator, brackets: list.hasBrackets} + {separator, brackets: list.hasBrackets}, ); } @@ -335,7 +335,7 @@ export class Protofier { if (separator === null && list.contents.length > 1) { throw utils.compilerError( `Value.List ${list} can't have an undecided separator because it ` + - `has ${list.contents.length} elements` + `has ${list.contents.length} elements`, ); } @@ -345,10 +345,10 @@ export class Protofier { Object.entries(list.keywords).map(([key, value]) => [ key, this.deprotofy(value), - ]) + ]), ), separator, - list.id + list.id, ); this.argumentLists.push(result); return result; @@ -364,8 +364,8 @@ export class Protofier { if (!value) throw utils.mandatoryError('Value.Map.Entry.value'); return [this.deprotofy(key), this.deprotofy(value)]; - }) - ) + }), + ), ); case 'compilerFunction': @@ -373,7 +373,7 @@ export class Protofier { case 'hostFunction': throw utils.compilerError( - 'The compiler may not send Value.host_function.' + 'The compiler may not send Value.host_function.', ); case 'compilerMixin': @@ -424,17 +424,17 @@ export class Protofier { /** Converts `calculation` to its Sass representation. */ private deprotofyCalculation( - calculation: proto.Value_Calculation + calculation: proto.Value_Calculation, ): SassCalculation { switch (calculation.name) { case 'calc': if (calculation.arguments.length !== 1) { throw utils.compilerError( - 'Value.Calculation.arguments must have exactly one argument for calc().' + 'Value.Calculation.arguments must have exactly one argument for calc().', ); } return SassCalculation.calc( - this.deprotofyCalculationValue(calculation.arguments[0]) + this.deprotofyCalculationValue(calculation.arguments[0]), ); case 'clamp': if ( @@ -442,7 +442,7 @@ export class Protofier { calculation.arguments.length > 3 ) { throw utils.compilerError( - 'Value.Calculation.arguments must have 1 to 3 arguments for clamp().' + 'Value.Calculation.arguments must have 1 to 3 arguments for clamp().', ); } return SassCalculation.clamp( @@ -452,36 +452,36 @@ export class Protofier { : undefined, calculation.arguments.length > 2 ? this.deprotofyCalculationValue(calculation.arguments[2]) - : undefined + : undefined, ); case 'min': if (calculation.arguments.length === 0) { throw utils.compilerError( - 'Value.Calculation.arguments must have at least 1 argument for min().' + 'Value.Calculation.arguments must have at least 1 argument for min().', ); } return SassCalculation.min( - calculation.arguments.map(this.deprotofyCalculationValue) + calculation.arguments.map(this.deprotofyCalculationValue), ); case 'max': if (calculation.arguments.length === 0) { throw utils.compilerError( - 'Value.Calculation.arguments must have at least 1 argument for max().' + 'Value.Calculation.arguments must have at least 1 argument for max().', ); } return SassCalculation.max( - calculation.arguments.map(this.deprotofyCalculationValue) + calculation.arguments.map(this.deprotofyCalculationValue), ); default: throw utils.compilerError( - `Value.Calculation.name "${calculation.name}" is not a recognized calculation type.` + `Value.Calculation.name "${calculation.name}" is not a recognized calculation type.`, ); } } /** Converts `value` to its Sass representation. */ private deprotofyCalculationValue( - value: proto.Value_Calculation_CalculationValue + value: proto.Value_Calculation_CalculationValue, ): CalculationValue { switch (value.value.case) { case 'number': @@ -494,11 +494,11 @@ export class Protofier { return new CalculationOperation( this.deprotofyCalculationOperator(value.value.value.operator), this.deprotofyCalculationValue( - value.value.value.left as proto.Value_Calculation_CalculationValue + value.value.value.left as proto.Value_Calculation_CalculationValue, ), this.deprotofyCalculationValue( - value.value.value.right as proto.Value_Calculation_CalculationValue - ) + value.value.value.right as proto.Value_Calculation_CalculationValue, + ), ); case 'interpolation': return new CalculationInterpolation(value.value.value); @@ -509,7 +509,7 @@ export class Protofier { /** Converts `operator` to its Sass representation. */ private deprotofyCalculationOperator( - operator: proto.CalculationOperator + operator: proto.CalculationOperator, ): CalculationOperator { switch (operator) { case proto.CalculationOperator.PLUS: diff --git a/lib/src/request-tracker.test.ts b/lib/src/request-tracker.test.ts index dd90cba3..052f5282 100644 --- a/lib/src/request-tracker.test.ts +++ b/lib/src/request-tracker.test.ts @@ -37,14 +37,14 @@ describe('request tracker', () => { it('errors if the request ID is invalid', () => { expect(() => tracker.add(-1, 'compileResponse')).toThrowError( - 'Invalid request ID -1.' + 'Invalid request ID -1.', ); }); it('errors if the request ID overlaps that of an existing in-flight request', () => { tracker.add(0, 'compileResponse'); expect(() => tracker.add(0, 'compileResponse')).toThrowError( - 'Request ID 0 is already in use by an in-flight request.' + 'Request ID 0 is already in use by an in-flight request.', ); }); }); @@ -75,7 +75,7 @@ describe('request tracker', () => { it('errors if the response ID does not match any existing request IDs', () => { expect(() => tracker.resolve(0, 'compileResponse')).toThrowError( - 'Response ID 0 does not match any pending requests.' + 'Response ID 0 does not match any pending requests.', ); }); @@ -83,7 +83,7 @@ describe('request tracker', () => { tracker.add(0, 'importResponse'); expect(() => tracker.resolve(0, 'fileImportResponse')).toThrowError( "Response with ID 0 does not match pending request's type. Expected " + - 'importResponse but received fileImportResponse.' + 'importResponse but received fileImportResponse.', ); }); }); diff --git a/lib/src/request-tracker.ts b/lib/src/request-tracker.ts index 200f51c1..9d976a64 100644 --- a/lib/src/request-tracker.ts +++ b/lib/src/request-tracker.ts @@ -31,13 +31,13 @@ export class RequestTracker { */ add( id: number, - expectedResponseType: InboundResponseType | OutboundResponseType + expectedResponseType: InboundResponseType | OutboundResponseType, ): void { if (id < 0) { throw Error(`Invalid request ID ${id}.`); } else if (this.requests[id]) { throw Error( - `Request ID ${id} is already in use by an in-flight request.` + `Request ID ${id} is already in use by an in-flight request.`, ); } this.requests[id] = expectedResponseType; @@ -52,7 +52,7 @@ export class RequestTracker { throw Error(`Response ID ${id} does not match any pending requests.`); } else if (this.requests[id] !== type) { throw Error( - `Response with ID ${id} does not match pending request's type. Expected ${this.requests[id]} but received ${type}.` + `Response with ID ${id} does not match pending request's type. Expected ${this.requests[id]} but received ${type}.`, ); } this.requests[id] = null; diff --git a/lib/src/sync-process/index.test.ts b/lib/src/sync-process/index.test.ts index b538b93c..99a2996f 100644 --- a/lib/src/sync-process/index.test.ts +++ b/lib/src/sync-process/index.test.ts @@ -30,7 +30,7 @@ describe('SyncProcess', () => { expectStdout(node.yield(), 'hi there!\n'); node.stdin.write('fblthp\n'); expectStdout(node.yield(), 'fblthp\n'); - } + }, ); }); @@ -43,7 +43,7 @@ describe('SyncProcess', () => { node => { node.stdin.end(); expectStdout(node.yield(), 'closed!\n'); - } + }, ); }); }); @@ -114,7 +114,7 @@ function expectExit(event: Event, codeOrSignal: number | NodeJS.Signals): void { expect(event).toEqual( typeof codeOrSignal === 'number' ? {type: 'exit', code: codeOrSignal} - : {type: 'exit', signal: codeOrSignal} + : {type: 'exit', signal: codeOrSignal}, ); } @@ -124,7 +124,7 @@ function expectExit(event: Event, codeOrSignal: number | NodeJS.Signals): void { */ function withJSProcess( contents: string, - callback: (process: SyncProcess) => void + callback: (process: SyncProcess) => void, ): void { return withJSFile(contents, file => { const node = new SyncProcess(process.argv0, [file]); diff --git a/lib/src/sync-process/index.ts b/lib/src/sync-process/index.ts index 426dbb1c..37f0d26d 100644 --- a/lib/src/sync-process/index.ts +++ b/lib/src/sync-process/index.ts @@ -35,7 +35,7 @@ export class SyncProcess { constructor( command: string, argsOrOptions?: string[] | Options, - options?: Options + options?: Options, ) { let args: string[]; if (Array.isArray(argsOrOptions)) { @@ -63,7 +63,7 @@ export class SyncProcess { type: 'stdin', data: chunk as Buffer, }, - [chunk.buffer] + [chunk.buffer], ); callback(); }, @@ -76,7 +76,7 @@ export class SyncProcess { const oldEnd = this.stdin.end.bind(this.stdin) as ( a1?: unknown, a2?: unknown, - a3?: unknown + a3?: unknown, ) => void; this.stdin.end = ((a1?: unknown, a2?: unknown, a3?: unknown) => { oldEnd(a1, a2, a3); @@ -84,7 +84,7 @@ export class SyncProcess { }) as typeof this.stdin.end; const oldDestroy = this.stdin.destroy.bind(this.stdin) as ( - a1?: unknown + a1?: unknown, ) => void; this.stdin.destroy = ((a1?: unknown) => { oldDestroy(a1); @@ -102,7 +102,7 @@ export class SyncProcess { yield(): Event { if (this.stdin.destroyed) { throw new Error( - "Can't call SyncProcess.yield() after the process has exited." + "Can't call SyncProcess.yield() after the process has exited.", ); } @@ -152,7 +152,7 @@ export class SyncProcess { */ function spawnWorker( fileWithoutExtension: string, - options: WorkerOptions + options: WorkerOptions, ): Worker { // The released version always spawns the JS worker. The TS worker is only // used for development. @@ -166,7 +166,7 @@ function spawnWorker( require('ts-node').register(); require(${JSON.stringify(tsFile)}); `, - {...options, eval: true} + {...options, eval: true}, ); } diff --git a/lib/src/sync-process/sync-message-port.test.ts b/lib/src/sync-process/sync-message-port.test.ts index 4c1e1674..29fd08b1 100644 --- a/lib/src/sync-process/sync-message-port.test.ts +++ b/lib/src/sync-process/sync-message-port.test.ts @@ -32,7 +32,7 @@ describe('SyncMessagePort', () => { port.close(); }, 100); `, - channel.port2 + channel.port2, ); expect(port.receiveMessage()).toEqual('done!'); @@ -64,7 +64,7 @@ describe('SyncMessagePort', () => { port.postMessage('done!'); port.close(); `, - channel.port2 + channel.port2, ); expect(port.receiveMessage()).toEqual('message1'); @@ -152,14 +152,14 @@ function spawnWorker(source: string, port: MessagePort): Worker { file, ` const {SyncMessagePort} = require(${JSON.stringify( - p.join(p.dirname(__filename), 'sync-message-port') + p.join(p.dirname(__filename), 'sync-message-port'), )}); const {workerData} = require('worker_threads'); const port = new SyncMessagePort(workerData); ${source} - ` + `, ); const worker = new Worker( @@ -167,7 +167,7 @@ function spawnWorker(source: string, port: MessagePort): Worker { require('ts-node').register(); require(${JSON.stringify(p.resolve(file.substring(0, file.length - 3)))}); `, - {eval: true, workerData: port, transferList: [port]} + {eval: true, workerData: port, transferList: [port]}, ); worker.on('error', error => { diff --git a/lib/src/sync-process/sync-message-port.ts b/lib/src/sync-process/sync-message-port.ts index 7970244e..efb5c40e 100644 --- a/lib/src/sync-process/sync-message-port.ts +++ b/lib/src/sync-process/sync-message-port.ts @@ -80,7 +80,7 @@ export class SyncMessagePort extends EventEmitter { if (!buffer) { throw new Error( 'new SyncMessagePort() must be passed a port from ' + - 'SyncMessagePort.createChannel().' + 'SyncMessagePort.createChannel().', ); } this.buffer = new Int32Array(buffer as SharedArrayBuffer); @@ -89,7 +89,7 @@ export class SyncMessagePort extends EventEmitter { this.port.on(event, listener); }); this.on('removeListener', (event, listener) => - this.port.removeListener(event, listener) + this.port.removeListener(event, listener), ); } @@ -105,7 +105,7 @@ export class SyncMessagePort extends EventEmitter { this.buffer, 0, BufferState.AwaitingMessage, - BufferState.MessageSent + BufferState.MessageSent, ) === BufferState.AwaitingMessage ) { Atomics.notify(this.buffer, 0); @@ -129,7 +129,7 @@ export class SyncMessagePort extends EventEmitter { if (this.listenerCount('message')) { throw new Error( 'SyncMessageChannel.receiveMessage() may not be called while there ' + - 'are message listeners.' + 'are message listeners.', ); } @@ -143,7 +143,7 @@ export class SyncMessagePort extends EventEmitter { this.buffer, 0, BufferState.MessageSent, - BufferState.AwaitingMessage + BufferState.AwaitingMessage, ) === BufferState.Closed ) { throw new Error("The SyncMessagePort's channel is closed."); diff --git a/lib/src/sync-process/worker.ts b/lib/src/sync-process/worker.ts index 89542961..d141d554 100644 --- a/lib/src/sync-process/worker.ts +++ b/lib/src/sync-process/worker.ts @@ -24,7 +24,7 @@ function emit(event: InternalEvent, transferList?: TransferListItem[]): void { const process = spawn( workerData.command as string, workerData.args as string[], - workerData.options as SpawnOptionsWithoutStdio | undefined + workerData.options as SpawnOptionsWithoutStdio | undefined, ); port.on('message', message => { diff --git a/lib/src/utils.test.ts b/lib/src/utils.test.ts index 35565fe5..cf8ae2d2 100644 --- a/lib/src/utils.test.ts +++ b/lib/src/utils.test.ts @@ -13,7 +13,7 @@ describe('utils', () => { expect(pathToUrlString(filename)).toEqual( pathToFileURL(filename) .toString() - .slice(baseURL.length + 1) + .slice(baseURL.length + 1), ); } }); @@ -25,13 +25,13 @@ describe('utils', () => { expect(pathToUrlString(lowercase)).toEqual( pathToFileURL(lowercase) .toString() - .slice(baseURL.length + 1) + .slice(baseURL.length + 1), ); const uppercase = lowercase.toUpperCase(); expect(pathToUrlString(uppercase)).toEqual( pathToFileURL(uppercase) .toString() - .slice(baseURL.length + 1) + .slice(baseURL.length + 1), ); } }); diff --git a/lib/src/utils.ts b/lib/src/utils.ts index e3888cea..055df546 100644 --- a/lib/src/utils.ts +++ b/lib/src/utils.ts @@ -26,7 +26,7 @@ export type SyncBoolean = sync extends 'async' */ export function thenOr( promiseOrValue: PromiseOr, - callback: (value: T) => PromiseOr + callback: (value: T) => PromiseOr, ): PromiseOr { return promiseOrValue instanceof Promise ? (promiseOrValue.then(callback) as PromiseOr) @@ -39,7 +39,7 @@ export function thenOr( */ export function catchOr( promiseOrValueCallback: () => PromiseOr, - callback: (error: unknown) => PromiseOr + callback: (error: unknown) => PromiseOr, ): PromiseOr { try { const result = promiseOrValueCallback(); @@ -53,7 +53,7 @@ export function catchOr( /** Checks for null or undefined. */ export function isNullOrUndefined( - object: T | null | undefined + object: T | null | undefined, ): object is null | undefined { return object === null || object === undefined; } @@ -95,7 +95,7 @@ export function pathToUrlString(path: string): string { .replace(/[#?]/g, encodeURIComponent) .replace( process.platform === 'win32' ? /%(5B|5C|5D|5E|7C)/g : /%(5B|5D|5E|7C)/g, - decodeURIComponent + decodeURIComponent, ) .replace(/\\/g, '/'); } @@ -139,7 +139,7 @@ export function protofySyntax(syntax: Syntax): proto.Syntax { /** Returns whether `error` is a NodeJS-style exception with an error code. */ export function isErrnoException( - error: unknown + error: unknown, ): error is NodeJS.ErrnoException { return error instanceof Error && ('errno' in error || 'code' in error); } @@ -151,7 +151,7 @@ export function isErrnoException( export function putIfAbsent( map: Map, key: K, - provider: () => V + provider: () => V, ): V { const val = map.get(key); if (val !== undefined) { diff --git a/lib/src/value/argument-list.ts b/lib/src/value/argument-list.ts index 029e2658..ea1ae188 100644 --- a/lib/src/value/argument-list.ts +++ b/lib/src/value/argument-list.ts @@ -53,7 +53,7 @@ export class SassArgumentList extends SassList { contents: Value[] | List, keywords: Record | OrderedMap, separator?: ListSeparator, - id?: number + id?: number, ) { super(contents, {separator}); this.keywordsInternal = isOrderedMap(keywords) diff --git a/lib/src/value/calculations.ts b/lib/src/value/calculations.ts index 7f4c2a4e..f65b1759 100644 --- a/lib/src/value/calculations.ts +++ b/lib/src/value/calculations.ts @@ -36,7 +36,7 @@ export class SassCalculation extends Value { private constructor( readonly name: string, - args: CalculationValueIterable + args: CalculationValueIterable, ) { super(); this.arguments = List(args); @@ -60,14 +60,14 @@ export class SassCalculation extends Value { static clamp( min: CalculationValue, value?: CalculationValue, - max?: CalculationValue + max?: CalculationValue, ): SassCalculation { if ( (value === undefined && !isValidClampArg(min)) || (max === undefined && ![min, value].some(x => x && isValidClampArg(x))) ) { throw new Error( - 'Argument must be an unquoted SassString or CalculationInterpolation.' + 'Argument must be an unquoted SassString or CalculationInterpolation.', ); } const args = [min]; @@ -105,7 +105,7 @@ export class CalculationOperation implements ValueObject { constructor( readonly operator: CalculationOperator, readonly left: CalculationValue, - readonly right: CalculationValue + readonly right: CalculationValue, ) { if (!operators.includes(operator)) { throw new Error(`Invalid operator: ${operator}`); diff --git a/lib/src/value/color.ts b/lib/src/value/color.ts index 9cb6344a..34b2a3f7 100644 --- a/lib/src/value/color.ts +++ b/lib/src/value/color.ts @@ -207,7 +207,7 @@ function encodeChannelForColorJs(channel: ChannelName): string { */ function validateChannelInSpace( channel: ChannelName, - space: KnownColorSpace + space: KnownColorSpace, ): void { if (channel === 'alpha') return; let valid = false; @@ -243,7 +243,7 @@ function validateChannelInSpace( } if (!valid) { throw valueError( - `Unknown channel name "${channel}" for color space "${space}".` + `Unknown channel name "${channel}" for color space "${space}".`, ); } } @@ -269,7 +269,7 @@ function isPolarColorSpace(space: KnownColorSpace): space is PolarColorSpace { */ function decodeCoordsFromColorJs( coords: [number, number, number], // ColorJS coordinates - isRgb = false // Whether this color is in the `rgb` color space + isRgb = false, // Whether this color is in the `rgb` color space ): [number | null, number | null, number | null] { let newCoords = coords; // If this color is in the `rgb` space, convert channel values to `0-255` @@ -295,7 +295,7 @@ function checkChangeDeprecations( options: { [key in ChannelName]?: number | null; }, - channels: ChannelName[] + channels: ChannelName[], ): void { if (options.alpha === null) emitNullAlphaDeprecation(); for (const channel of channels) { @@ -309,7 +309,7 @@ function emitColor4ApiGetterDeprecation(name: string): void { `\`${name}\` is deprecated, use \`channel\` instead.` + '\n' + 'More info: https://sass-lang.com/d/color-4-api', - deprecations['color-4-api'] + deprecations['color-4-api'], ); } @@ -323,7 +323,7 @@ function emitColor4ApiChangeSpaceDeprecation(): void { 'specifying the `space` option is deprecated.' + '\n' + 'More info: https://sass-lang.com/d/color-4-api', - deprecations['color-4-api'] + deprecations['color-4-api'], ); } @@ -333,7 +333,7 @@ function emitColor4ApiChangeNullDeprecation(channel: string): void { `Passing \`${channel}: null\` without setting \`space\` is deprecated.` + '\n' + 'More info: https://sass-lang.com/d/color-4-api', - deprecations['color-4-api'] + deprecations['color-4-api'], ); } @@ -343,7 +343,7 @@ function emitNullAlphaDeprecation(): void { 'Passing `alpha: null` without setting `space` is deprecated.' + '\n' + 'More info: https://sass-lang.com/d/null-alpha', - deprecations['null-alpha'] + deprecations['null-alpha'], ); } @@ -352,7 +352,7 @@ function emitNullAlphaDeprecation(): void { * ColorJS color object. */ function optionsHaveColor( - opts: OptionsWithColor | ConstructorOptions + opts: OptionsWithColor | ConstructorOptions, ): opts is OptionsWithColor { return (opts as OptionsWithColor).color instanceof Color; } @@ -794,7 +794,7 @@ export class SassColor extends Value { this.color.get({ space: this.color.spaceId, coordId: encodeChannelForColorJs(channel), - }) + }), ); } @@ -808,31 +808,31 @@ export class SassColor extends Value { */ isChannelPowerless( channel: ChannelNameHsl, - options?: {space: ColorSpaceHsl} + options?: {space: ColorSpaceHsl}, ): boolean; isChannelPowerless( channel: ChannelNameHwb, - options?: {space: ColorSpaceHwb} + options?: {space: ColorSpaceHwb}, ): boolean; isChannelPowerless( channel: ChannelNameLab, - options?: {space: ColorSpaceLab} + options?: {space: ColorSpaceLab}, ): boolean; isChannelPowerless( channel: ChannelNameLch, - options?: {space: ColorSpaceLch} + options?: {space: ColorSpaceLch}, ): boolean; isChannelPowerless( channel: ChannelNameRgb, - options?: {space: ColorSpaceRgb} + options?: {space: ColorSpaceRgb}, ): boolean; isChannelPowerless( channel: ChannelNameXyz, - options?: {space: ColorSpaceXyz} + options?: {space: ColorSpaceXyz}, ): boolean; isChannelPowerless( channel: ChannelName, - options?: {space: KnownColorSpace} + options?: {space: KnownColorSpace}, ): boolean { if (channel === 'alpha') return false; const color = options?.space ? this.toSpace(options.space) : this; @@ -873,7 +873,7 @@ export class SassColor extends Value { options?: { weight?: number; method?: HueInterpolationMethod; - } + }, ): SassColor { const hueInterpolationMethod = options?.method ?? @@ -885,7 +885,7 @@ export class SassColor extends Value { if (weight < 0 || weight > 1) { throw valueError( - `Expected \`weight\` between \`0\` and \`1\`, received \`${weight}\`.` + `Expected \`weight\` between \`0\` and \`1\`, received \`${weight}\`.`, ); } @@ -938,7 +938,7 @@ export class SassColor extends Value { private getChangedColor( options: ConstructorOptions, space: KnownColorSpace, - spaceSetExplicitly: boolean + spaceSetExplicitly: boolean, ): SassColor { const color = this.toSpace(space); function getChangedValue(channel: ChannelName): number | null { @@ -1063,42 +1063,42 @@ export class SassColor extends Value { [key in ChannelNameHsl]?: number | null; } & { space?: ColorSpaceHsl; - } + }, ): SassColor; change( options: { [key in ChannelNameHwb]?: number | null; } & { space?: ColorSpaceHwb; - } + }, ): SassColor; change( options: { [key in ChannelNameLab]?: number | null; } & { space?: ColorSpaceLab; - } + }, ): SassColor; change( options: { [key in ChannelNameLch]?: number | null; } & { space?: ColorSpaceLch; - } + }, ): SassColor; change( options: { [key in ChannelNameRgb]?: number | null; } & { space?: ColorSpaceRgb; - } + }, ): SassColor; change( options: { [key in ChannelNameXyz]?: number | null; } & { space?: ColorSpaceXyz; - } + }, ): SassColor; change(options: ConstructorOptions): SassColor { const spaceSetExplicitly = !!options.space; @@ -1109,7 +1109,7 @@ export class SassColor extends Value { // Validate channel values const keys = Object.keys(options).filter( - key => key !== 'space' + key => key !== 'space', ) as ChannelName[]; for (const channel of keys) { validateChannelInSpace(channel, space); @@ -1119,7 +1119,7 @@ export class SassColor extends Value { } return this.getChangedColor(options, space, spaceSetExplicitly).toSpace( - this.space + this.space, ); } diff --git a/lib/src/value/function.ts b/lib/src/value/function.ts index 730ef2ac..68f52307 100644 --- a/lib/src/value/function.ts +++ b/lib/src/value/function.ts @@ -43,7 +43,7 @@ export class SassFunction extends Value { constructor(signature: string, callback: CustomFunction<'sync'>); constructor( idOrSignature: number | string, - callback?: CustomFunction<'sync'> + callback?: CustomFunction<'sync'>, ) { super(); diff --git a/lib/src/value/index.ts b/lib/src/value/index.ts index 6e5129fe..b77c3395 100644 --- a/lib/src/value/index.ts +++ b/lib/src/value/index.ts @@ -87,7 +87,7 @@ export abstract class Value implements ValueObject { if (Math.abs(index) > this.lengthAsList) { throw valueError( `Invalid index ${sassIndex} for a list with ${this.lengthAsList} elements.`, - name + name, ); } return index < 0 ? this.lengthAsList + index : index - 1; diff --git a/lib/src/value/list.ts b/lib/src/value/list.ts index d8175bb0..82c4fd25 100644 --- a/lib/src/value/list.ts +++ b/lib/src/value/list.ts @@ -36,12 +36,12 @@ export class SassList extends Value { options?: { separator?: ListSeparator; brackets?: boolean; - } + }, ); constructor(options?: ConstructorOptions); constructor( contentsOrOptions?: Value[] | List | ConstructorOptions, - options?: ConstructorOptions + options?: ConstructorOptions, ) { super(); @@ -54,7 +54,7 @@ export class SassList extends Value { if (this.contentsInternal.size > 1 && options?.separator === null) { throw Error( - 'Non-null separator required for SassList with more than one element.' + 'Non-null separator required for SassList with more than one element.', ); } this.separatorInternal = @@ -136,7 +136,7 @@ export class SassList extends Value { string += `${this.contentsInternal.join( this.separator === ' ' || this.separator === null ? ' ' - : `${this.separator} ` + : `${this.separator} `, )}`; if (this.hasBrackets) string += ']'; return string; diff --git a/lib/src/value/map.ts b/lib/src/value/map.ts index d7ae3b97..9e173b80 100644 --- a/lib/src/value/map.ts +++ b/lib/src/value/map.ts @@ -97,7 +97,7 @@ export class SassMap extends Value { this.contents.reduce( (accumulator, value, key) => accumulator ^ value.hashCode() ^ key.hashCode(), - 0 + 0, ); } @@ -105,7 +105,7 @@ export class SassMap extends Value { let string = '('; string += Array.from( this.contents.entries(), - ([key, value]) => `${key}: ${value}` + ([key, value]) => `${key}: ${value}`, ).join(', '); string += ')'; return string; diff --git a/lib/src/value/number.ts b/lib/src/value/number.ts index 11d69e56..52397e57 100644 --- a/lib/src/value/number.ts +++ b/lib/src/value/number.ts @@ -170,7 +170,7 @@ export class SassNumber extends Value { | { numeratorUnits?: string[] | List; denominatorUnits?: string[] | List; - } + }, ) { super(); @@ -339,11 +339,11 @@ export class SassNumber extends Value { convert( newNumerators: string[] | List, newDenominators: string[] | List, - name?: string + name?: string, ): SassNumber { return new SassNumber( this.convertValue(newNumerators, newDenominators, name), - {numeratorUnits: newNumerators, denominatorUnits: newDenominators} + {numeratorUnits: newNumerators, denominatorUnits: newDenominators}, ); } @@ -361,7 +361,7 @@ export class SassNumber extends Value { convertValue( newNumerators: string[] | List, newDenominators: string[] | List, - name?: string + name?: string, ): number { return this.convertOrCoerce({ coerceUnitless: false, @@ -384,7 +384,7 @@ export class SassNumber extends Value { convertToMatch( other: SassNumber, name?: string, - otherName?: string + otherName?: string, ): SassNumber { return new SassNumber(this.convertValueToMatch(other, name, otherName), { numeratorUnits: other.numeratorUnits, @@ -405,7 +405,7 @@ export class SassNumber extends Value { convertValueToMatch( other: SassNumber, name?: string, - otherName?: string + otherName?: string, ): number { return this.convertOrCoerce({ coerceUnitless: false, @@ -433,11 +433,11 @@ export class SassNumber extends Value { coerce( newNumerators: string[] | List, newDenominators: string[] | List, - name?: string + name?: string, ): SassNumber { return new SassNumber( this.coerceValue(newNumerators, newDenominators, name), - {numeratorUnits: newNumerators, denominatorUnits: newDenominators} + {numeratorUnits: newNumerators, denominatorUnits: newDenominators}, ); } @@ -459,7 +459,7 @@ export class SassNumber extends Value { coerceValue( newNumerators: string[] | List, newDenominators: string[] | List, - name?: string + name?: string, ): number { return this.convertOrCoerce({ coerceUnitless: true, @@ -485,7 +485,7 @@ export class SassNumber extends Value { coerceToMatch( other: SassNumber, name?: string, - otherName?: string + otherName?: string, ): SassNumber { return new SassNumber(this.coerceValueToMatch(other, name, otherName), { numeratorUnits: other.numeratorUnits, @@ -509,7 +509,7 @@ export class SassNumber extends Value { coerceValueToMatch( other: SassNumber, name?: string, - otherName?: string + otherName?: string, ): number { return this.convertOrCoerce({ coerceUnitless: true, @@ -533,7 +533,7 @@ export class SassNumber extends Value { const canonicalDenominators = canonicalizeUnits(this.denominatorUnits); const canonicalValue = this.convertValue( canonicalNumerators, - canonicalDenominators + canonicalDenominators, ); return ( fuzzyHashCode(canonicalValue) ^ @@ -545,7 +545,7 @@ export class SassNumber extends Value { toString(): string { return `${this.value}${unitString( this.numeratorUnits, - this.denominatorUnits + this.denominatorUnits, )}`; } @@ -571,7 +571,7 @@ export class SassNumber extends Value { other: SassNumber; otherName?: string; } - ) + ), ): number { const newNumerators = 'other' in params @@ -608,7 +608,7 @@ export class SassNumber extends Value { `Expected ${this} to have a single ${type} unit (${unitsByType[ type ].join(', ')}).`, - params.name + params.name, ); } } @@ -620,10 +620,10 @@ export class SassNumber extends Value { ? 'no units' : `unit${unitSize > 1 ? 's' : ''} ${unitString( newNumerators, - newDenominators + newDenominators, )}` }.`, - params.name + params.name, ); }; @@ -687,7 +687,7 @@ function conversionFactor(fromUnit: string, toUnit: string): number | null { // `denominators`. function unitString( numerators: List, - denominators: List + denominators: List, ): string { if (numerators.isEmpty() && denominators.isEmpty()) { return ''; diff --git a/lib/src/value/string.ts b/lib/src/value/string.ts index 1581a2a7..082280e6 100644 --- a/lib/src/value/string.ts +++ b/lib/src/value/string.ts @@ -17,7 +17,7 @@ export class SassString extends Value { constructor(options?: {quotes?: boolean}); constructor( textOrOptions?: string | {quotes?: boolean}, - options?: {quotes?: boolean} + options?: {quotes?: boolean}, ) { super(); @@ -102,7 +102,7 @@ export class SassString extends Value { if (Math.abs(sassIdx) > sassLength) { throw valueError( `Invalid index ${sassIdx} for a string with ${sassLength} characters`, - name + name, ); } if (sassIdx < 0) sassIdx += sassLength + 1; diff --git a/lib/src/value/utils.ts b/lib/src/value/utils.ts index d40ed98c..7844c810 100644 --- a/lib/src/value/utils.ts +++ b/lib/src/value/utils.ts @@ -88,7 +88,7 @@ export function fuzzyRound(num: number): number { export function fuzzyInRange( num: number, min: number, - max: number + max: number, ): number | null { if (fuzzyEquals(num, min)) return min; if (fuzzyEquals(num, max)) return max; @@ -107,7 +107,7 @@ export function fuzzyAssertInRange( num: number, min: number, max: number, - name?: string + name?: string, ): number { if (fuzzyEquals(num, min)) return min; if (fuzzyEquals(num, max)) return max; diff --git a/lib/src/version.ts b/lib/src/version.ts index 79f61371..70b4ccd7 100644 --- a/lib/src/version.ts +++ b/lib/src/version.ts @@ -8,7 +8,7 @@ export class Version implements api.Version { constructor( readonly major: number, readonly minor: number, - readonly patch: number + readonly patch: number, ) {} static parse(version: string): Version { const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/); @@ -18,7 +18,7 @@ export class Version implements api.Version { return new Version( parseInt(match[1]), parseInt(match[2]), - parseInt(match[3]) + parseInt(match[3]), ); } toString(): string { diff --git a/package.json b/package.json index e317f46e..f26c2ded 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@types/yargs": "^17.0.4", "del": "^6.0.0", "extract-zip": "^2.0.1", - "gts": "^5.0.0", + "gts": "^6.0.2", "jest": "^29.4.1", "minipass": "7.1.2", "npm-run-all": "^4.1.5", diff --git a/test/dependencies.test.ts b/test/dependencies.test.ts index e29f547a..c5a60bc4 100644 --- a/test/dependencies.test.ts +++ b/test/dependencies.test.ts @@ -17,8 +17,8 @@ it('declares a compatible dependency on the embedded protocol', () => { fs .readFileSync( p.join(__dirname, '../build/sass/spec/EMBEDDED_PROTOCOL_VERSION'), - 'utf-8' + 'utf-8', ) - .trim() + .trim(), ).toBe(pkg['protocol-version']); }); diff --git a/test/sandbox.ts b/test/sandbox.ts index 2175e532..b1281b16 100644 --- a/test/sandbox.ts +++ b/test/sandbox.ts @@ -21,17 +21,17 @@ export async function run( options?: { // Directories to put in the SASS_PATH env variable before running test. sassPathDirs?: string[]; - } + }, ): Promise { const testDir = p.join( p.dirname(__filename), 'sandbox', - `${Math.random()}`.slice(2) + `${Math.random()}`.slice(2), ); fs.mkdirSync(testDir, {recursive: true}); if (options?.sassPathDirs) { process.env.SASS_PATH = options.sassPathDirs.join( - process.platform === 'win32' ? ';' : ':' + process.platform === 'win32' ? ';' : ':', ); } try { diff --git a/test/utils.ts b/test/utils.ts index c071d481..5a4e947d 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -12,7 +12,7 @@ import {Value} from '../lib/src/value'; export function expectObservableToError( observable: Observable, errorMessage: string, - done: () => void + done: () => void, ): void { observable.subscribe({ next: () => { @@ -46,7 +46,7 @@ export function expectEqualPaths(actual: string, expected: string): void { */ export function expectEqualIgnoringWhitespace( string1: string, - string2: string + string2: string, ): void { function strip(str: string): string { return str.replace(/\s+/g, ''); diff --git a/tool/get-embedded-compiler.ts b/tool/get-embedded-compiler.ts index cb8b7245..828c22b8 100644 --- a/tool/get-embedded-compiler.ts +++ b/tool/get-embedded-compiler.ts @@ -15,7 +15,7 @@ import * as utils from './utils'; */ export async function getEmbeddedCompiler( outPath: string, - options?: {ref: string} | {path: string} + options?: {ref: string} | {path: string}, ): Promise { const repo = 'dart-sass'; diff --git a/tool/get-language-repo.ts b/tool/get-language-repo.ts index cd8da97c..11893e64 100644 --- a/tool/get-language-repo.ts +++ b/tool/get-language-repo.ts @@ -16,7 +16,7 @@ import * as utils from './utils'; */ export async function getLanguageRepo( outPath: string, - options?: {ref: string} | {path: string} + options?: {ref: string} | {path: string}, ): Promise { if (!options || 'ref' in options) { utils.fetchRepo({ diff --git a/tool/prepare-optional-release.ts b/tool/prepare-optional-release.ts index 29f488e8..94bf8b4d 100644 --- a/tool/prepare-optional-release.ts +++ b/tool/prepare-optional-release.ts @@ -22,7 +22,7 @@ const argv = yargs(process.argv.slice(2)) 'Directory name under `npm` directory that contains optional dependencies.', demandOption: true, choices: Object.keys(pkg.optionalDependencies).map( - name => name.split('sass-embedded-')[1] + name => name.split('sass-embedded-')[1], ), }) .parseSync(); @@ -86,7 +86,7 @@ async function downloadRelease(options: { }); if (!response.ok) { throw Error( - `Failed to download ${options.repo} release asset: ${response.statusText}` + `Failed to download ${options.repo} release asset: ${response.statusText}`, ); } const releaseAsset = Buffer.from(await response.arrayBuffer()); @@ -119,7 +119,7 @@ void (async () => { const version = pkg['compiler-version'] as string; if (version.endsWith('-dev')) { throw Error( - "Can't release optional packages for a -dev compiler version." + "Can't release optional packages for a -dev compiler version.", ); } diff --git a/tool/prepare-release.ts b/tool/prepare-release.ts index 4065ffcf..f99237b4 100644 --- a/tool/prepare-release.ts +++ b/tool/prepare-release.ts @@ -42,14 +42,14 @@ async function sanityCheckBeforeRelease(): Promise { const ref = process.env['GITHUB_REF']; if (ref !== `refs/tags/${releaseVersion}`) { throw Error( - `GITHUB_REF ${ref} is different than the package.json version ${releaseVersion}.` + `GITHUB_REF ${ref} is different than the package.json version ${releaseVersion}.`, ); } for (const [dep, version] of Object.entries(pkg.optionalDependencies)) { if (version !== releaseVersion) { throw Error( - `optional dependency ${dep}'s version doesn't match ${releaseVersion}.` + `optional dependency ${dep}'s version doesn't match ${releaseVersion}.`, ); } } diff --git a/tool/utils.ts b/tool/utils.ts index c68d3012..96fd2c9e 100644 --- a/tool/utils.ts +++ b/tool/utils.ts @@ -31,7 +31,7 @@ export function fetchRepo(options: { `git clone \ --depth=1 \ https://github.com/sass/${options.repo} \ - ${path}` + ${path}`, ); } @@ -40,7 +40,7 @@ export function fetchRepo(options: { console.log(`Fetching ${version} for ${options.repo}.`); shell.exec( `git fetch --depth=1 origin ${options.ref} && git reset --hard FETCH_HEAD`, - {cwd: path} + {cwd: path}, ); } @@ -71,7 +71,7 @@ export async function cleanDir(dir: string): Promise { // Returns whether [path1] and [path2] are symlinks that refer to the same file. export async function sameTarget( path1: string, - path2: string + path2: string, ): Promise { const realpath1 = await tryRealpath(path1); if (realpath1 === null) return false; diff --git a/tsconfig.json b/tsconfig.json index d83f95cd..91520088 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,10 +6,11 @@ "resolveJsonModule": true, "rootDir": ".", "useUnknownInCatchVariables": false, - "declaration": false, + "declarationDir": "_types", "lib": ["DOM"] }, "include": [ + "package.json", "*.ts", "bin/*.ts", "lib/**/*.ts",