From a382859fb24c80d3cd30e5041ac7cb0fc410382f Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 24 Oct 2024 18:18:56 -0700 Subject: [PATCH 1/5] Add sass-parser support for the `@while` rule --- pkg/sass-parser/lib/index.ts | 1 + pkg/sass-parser/lib/src/sass-internal.ts | 6 + .../__snapshots__/while-rule.test.ts.snap | 21 ++ pkg/sass-parser/lib/src/statement/index.ts | 13 +- .../lib/src/statement/while-rule.test.ts | 240 ++++++++++++++++++ .../lib/src/statement/while-rule.ts | 140 ++++++++++ pkg/sass-parser/lib/src/stringifier.ts | 11 +- 7 files changed, 426 insertions(+), 6 deletions(-) create mode 100644 pkg/sass-parser/lib/src/statement/__snapshots__/while-rule.test.ts.snap create mode 100644 pkg/sass-parser/lib/src/statement/while-rule.test.ts create mode 100644 pkg/sass-parser/lib/src/statement/while-rule.ts diff --git a/pkg/sass-parser/lib/index.ts b/pkg/sass-parser/lib/index.ts index 3a890ffa9..9309d4ce2 100644 --- a/pkg/sass-parser/lib/index.ts +++ b/pkg/sass-parser/lib/index.ts @@ -102,6 +102,7 @@ export { VariableDeclarationRaws, } from './src/statement/variable-declaration'; export {WarnRule, WarnRuleProps, WarnRuleRaws} from './src/statement/warn-rule'; +export {WhileRule, WhileRuleProps, WhileRuleRaws} from './src/statement/while-rule'; /** Options that can be passed to the Sass parsers to control their behavior. */ export type SassParserOptions = Pick; diff --git a/pkg/sass-parser/lib/src/sass-internal.ts b/pkg/sass-parser/lib/src/sass-internal.ts index 055e9ca0a..1f9594c8c 100644 --- a/pkg/sass-parser/lib/src/sass-internal.ts +++ b/pkg/sass-parser/lib/src/sass-internal.ts @@ -192,6 +192,10 @@ declare namespace SassInternal { readonly expression: Expression; } + class WhileRule extends ParentStatement { + readonly condition: Expression; + } + class ConfiguredVariable extends SassNode { readonly name: string; readonly expression: Expression; @@ -252,6 +256,7 @@ export type SupportsRule = SassInternal.SupportsRule; export type UseRule = SassInternal.UseRule; export type VariableDeclaration = SassInternal.VariableDeclaration; export type WarnRule = SassInternal.WarnRule; +export type WhileRule = SassInternal.WhileRule; export type ConfiguredVariable = SassInternal.ConfiguredVariable; export type Interpolation = SassInternal.Interpolation; export type Expression = SassInternal.Expression; @@ -276,6 +281,7 @@ export interface StatementVisitorObject { visitUseRule(node: UseRule): T; visitVariableDeclaration(node: VariableDeclaration): T; visitWarnRule(node: WarnRule): T; + visitWhileRule(node: WhileRule): T; } export interface ExpressionVisitorObject { diff --git a/pkg/sass-parser/lib/src/statement/__snapshots__/while-rule.test.ts.snap b/pkg/sass-parser/lib/src/statement/__snapshots__/while-rule.test.ts.snap new file mode 100644 index 000000000..792686aa3 --- /dev/null +++ b/pkg/sass-parser/lib/src/statement/__snapshots__/while-rule.test.ts.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`a @while rule toJSON 1`] = ` +{ + "inputs": [ + { + "css": "@while foo {}", + "hasBOM": false, + "id": "", + }, + ], + "name": "while", + "nodes": [], + "params": "foo", + "raws": {}, + "sassType": "while-rule", + "source": <1:1-1:14 in 0>, + "type": "atrule", + "whileCondition": , +} +`; diff --git a/pkg/sass-parser/lib/src/statement/index.ts b/pkg/sass-parser/lib/src/statement/index.ts index da018916a..2635cc470 100644 --- a/pkg/sass-parser/lib/src/statement/index.ts +++ b/pkg/sass-parser/lib/src/statement/index.ts @@ -23,6 +23,7 @@ import { VariableDeclarationProps, } from './variable-declaration'; import {WarnRule, WarnRuleProps} from './warn-rule'; +import {WhileRule, WhileRuleProps} from './while-rule'; // TODO: Replace this with the corresponding Sass types once they're // implemented. @@ -56,7 +57,8 @@ export type StatementType = | 'use-rule' | 'sass-comment' | 'variable-declaration' - | 'warn-rule'; + | 'warn-rule' + | 'while-rule'; /** * All Sass statements that are also at-rules. @@ -70,7 +72,8 @@ export type AtRule = | ForRule | GenericAtRule | UseRule - | WarnRule; + | WarnRule + | WhileRule; /** * All Sass statements that are comments. @@ -107,7 +110,8 @@ export type ChildProps = | SassCommentChildProps | UseRuleProps | VariableDeclarationProps - | WarnRuleProps; + | WarnRuleProps + | WhileRuleProps; /** * The Sass eqivalent of PostCSS's `ContainerProps`. @@ -197,6 +201,7 @@ const visitor = sassInternal.createStatementVisitor({ visitUseRule: inner => new UseRule(undefined, inner), visitVariableDeclaration: inner => new VariableDeclaration(undefined, inner), visitWarnRule: inner => new WarnRule(undefined, inner), + visitWhileRule: inner => new WhileRule(undefined, inner), }); /** Appends parsed versions of `internal`'s children to `container`. */ @@ -317,6 +322,8 @@ export function normalize( result.push(new VariableDeclaration(node)); } else if ('warnExpression' in node) { result.push(new WarnRule(node)); + } else if ('whileCondition' in node) { + result.push(new WhileRule(node)); } else { result.push(...postcssNormalizeAndConvertToSass(self, node, sample)); } diff --git a/pkg/sass-parser/lib/src/statement/while-rule.test.ts b/pkg/sass-parser/lib/src/statement/while-rule.test.ts new file mode 100644 index 000000000..05cf78ee6 --- /dev/null +++ b/pkg/sass-parser/lib/src/statement/while-rule.test.ts @@ -0,0 +1,240 @@ +// Copyright 2024 Google Inc. Use of this source code is governed by an +// MIT-style license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +import {GenericAtRule, StringExpression, WhileRule, sass, scss} from '../..'; +import * as utils from '../../../test/utils'; + +describe('a @while rule', () => { + let node: WhileRule; + describe('with empty children', () => { + function describeNode(description: string, create: () => WhileRule): void { + describe(description, () => { + beforeEach(() => void (node = create())); + + it('has a name', () => expect(node.name.toString()).toBe('while')); + + it('has an expression', () => + expect(node).toHaveStringExpression('whileCondition', 'foo')); + + it('has matching params', () => expect(node.params).toBe('foo')); + + it('has empty nodes', () => expect(node.nodes).toEqual([])); + }); + } + + describeNode( + 'parsed as SCSS', + () => scss.parse('@while foo {}').nodes[0] as WhileRule + ); + + describeNode( + 'parsed as Sass', + () => sass.parse('@while foo').nodes[0] as WhileRule + ); + + describeNode( + 'constructed manually', + () => + new WhileRule({ + whileCondition: {text: 'foo'}, + }) + ); + + describeNode('constructed from ChildProps', () => + utils.fromChildProps({ + whileCondition: {text: 'foo'}, + }) + ); + }); + + describe('with a child', () => { + function describeNode(description: string, create: () => WhileRule): void { + describe(description, () => { + beforeEach(() => void (node = create())); + + it('has a name', () => expect(node.name.toString()).toBe('while')); + + it('has an expression', () => + expect(node).toHaveStringExpression('whileCondition', 'foo')); + + it('has matching params', () => expect(node.params).toBe('foo')); + + it('has a child node', () => { + expect(node.nodes).toHaveLength(1); + expect(node.nodes[0]).toBeInstanceOf(GenericAtRule); + expect(node.nodes[0]).toHaveProperty('name', 'child'); + }); + }); + } + + describeNode( + 'parsed as SCSS', + () => scss.parse('@while foo {@child}').nodes[0] as WhileRule + ); + + describeNode( + 'parsed as Sass', + () => sass.parse('@while foo\n @child').nodes[0] as WhileRule + ); + + describeNode( + 'constructed manually', + () => + new WhileRule({ + whileCondition: {text: 'foo'}, + nodes: [{name: 'child'}], + }) + ); + + describeNode('constructed from ChildProps', () => + utils.fromChildProps({ + whileCondition: {text: 'foo'}, + nodes: [{name: 'child'}], + }) + ); + }); + + describe('throws an error when assigned a new', () => { + beforeEach( + () => + void (node = new WhileRule({whileCondition: {text: 'foo'}})) + ); + + it('name', () => expect(() => (node.name = 'bar')).toThrow()); + + it('params', () => expect(() => (node.params = 'true')).toThrow()); + }); + + describe('assigned a new expression', () => { + beforeEach(() => { + node = scss.parse('@while foo {}').nodes[0] as WhileRule; + }); + + it("removes the old expression's parent", () => { + const oldExpression = node.whileCondition; + node.whileCondition = {text: 'bar'}; + expect(oldExpression.parent).toBeUndefined(); + }); + + it("assigns the new expression's parent", () => { + const expression = new StringExpression({text: 'bar'}); + node.whileCondition = expression; + expect(expression.parent).toBe(node); + }); + + it('assigns the expression explicitly', () => { + const expression = new StringExpression({text: 'bar'}); + node.whileCondition = expression; + expect(node.whileCondition).toBe(expression); + }); + + it('assigns the expression as ExpressionProps', () => { + node.whileCondition = {text: 'bar'}; + expect(node).toHaveStringExpression('whileCondition', 'bar'); + }); + }); + + describe('stringifies', () => { + describe('to SCSS', () => { + it('with default raws', () => + expect( + new WhileRule({ + whileCondition: {text: 'foo'}, + }).toString() + ).toBe('@while foo {}')); + + it('with afterName', () => + expect( + new WhileRule({ + whileCondition: {text: 'foo'}, + raws: {afterName: '/**/'}, + }).toString() + ).toBe('@while/**/foo {}')); + + it('with between', () => + expect( + new WhileRule({ + whileCondition: {text: 'foo'}, + raws: {between: '/**/'}, + }).toString() + ).toBe('@while foo/**/{}')); + }); + }); + + describe('clone', () => { + let original: WhileRule; + beforeEach(() => { + original = scss.parse('@while foo {}').nodes[0] as WhileRule; + // TODO: remove this once raws are properly parsed + original.raws.between = ' '; + }); + + describe('with no overrides', () => { + let clone: WhileRule; + beforeEach(() => void (clone = original.clone())); + + describe('has the same properties:', () => { + it('params', () => expect(clone.params).toBe('foo')); + + it('whileCondition', () => + expect(clone).toHaveStringExpression('whileCondition', 'foo')); + + it('raws', () => expect(clone.raws).toEqual({between: ' '})); + + it('source', () => expect(clone.source).toBe(original.source)); + }); + + describe('creates a new', () => { + it('self', () => expect(clone).not.toBe(original)); + + for (const attr of ['whileCondition', 'raws'] as const) { + it(attr, () => expect(clone[attr]).not.toBe(original[attr])); + } + }); + }); + + describe('overrides', () => { + describe('raws', () => { + it('defined', () => + expect(original.clone({raws: {afterName: ' '}}).raws).toEqual({ + afterName: ' ', + })); + + it('undefined', () => + expect(original.clone({raws: undefined}).raws).toEqual({ + between: ' ', + })); + }); + + describe('whileCondition', () => { + describe('defined', () => { + let clone: WhileRule; + beforeEach(() => { + clone = original.clone({whileCondition: {text: 'bar'}}); + }); + + it('changes params', () => expect(clone.params).toBe('bar')); + + it('changes whileCondition', () => + expect(clone).toHaveStringExpression('whileCondition', 'bar')); + }); + + describe('undefined', () => { + let clone: WhileRule; + beforeEach(() => { + clone = original.clone({whileCondition: undefined}); + }); + + it('preserves params', () => expect(clone.params).toBe('foo')); + + it('preserves whileCondition', () => + expect(clone).toHaveStringExpression('whileCondition', 'foo')); + }); + }); + }); + }); + + it('toJSON', () => + expect(scss.parse('@while foo {}').nodes[0]).toMatchSnapshot()); +}); diff --git a/pkg/sass-parser/lib/src/statement/while-rule.ts b/pkg/sass-parser/lib/src/statement/while-rule.ts new file mode 100644 index 000000000..0adb4ce74 --- /dev/null +++ b/pkg/sass-parser/lib/src/statement/while-rule.ts @@ -0,0 +1,140 @@ +// Copyright 2024 Google Inc. Use of this source code is governed by an +// MIT-style license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +import * as postcss from 'postcss'; +import type {AtRuleRaws} from 'postcss/lib/at-rule'; + +import {convertExpression} from '../expression/convert'; +import {Expression, ExpressionProps} from '../expression'; +import {fromProps} from '../expression/from-props'; +import {LazySource} from '../lazy-source'; +import type * as sassInternal from '../sass-internal'; +import * as utils from '../utils'; +import { + ChildNode, + ContainerProps, + NewNode, + Statement, + StatementWithChildren, + appendInternalChildren, + normalize, +} from '.'; +import {_AtRule} from './at-rule-internal'; +import {interceptIsClean} from './intercept-is-clean'; +import * as sassParser from '../..'; + +/** + * The set of raws supported by {@link WhileRule}. + * + * @category Statement + */ +export type WhileRuleRaws = Omit; + +/** + * The initializer properties for {@link WhileRule}. + * + * @category Statement + */ +export type WhileRuleProps = ContainerProps & { + raws?: WhileRuleRaws; + whileCondition: Expression | ExpressionProps; +}; + +/** + * A `@while` rule. Extends [`postcss.AtRule`]. + * + * [`postcss.AtRule`]: https://postcss.org/api/#atrule + * + * @category Statement + */ +export class WhileRule + extends _AtRule> + implements Statement +{ + readonly sassType = 'while-rule' as const; + declare parent: StatementWithChildren | undefined; + declare raws: WhileRuleRaws; + declare nodes: ChildNode[]; + + get name(): string { + return 'while'; + } + set name(value: string) { + throw new Error("WhileRule.name can't be overwritten."); + } + + get params(): string { + return this.whileCondition.toString(); + } + set params(value: string | number | undefined) { + throw new Error("WhileRule.params can't be overwritten."); + } + + /** The expresison whose value is emitted when the while rule is executed. */ + get whileCondition(): Expression { + return this._whileCondition!; + } + set whileCondition(whileCondition: Expression | ExpressionProps) { + if (this._whileCondition) this._whileCondition.parent = undefined; + if (!('sassType' in whileCondition)) { + whileCondition = fromProps(whileCondition); + } + if (whileCondition) whileCondition.parent = this; + this._whileCondition = whileCondition; + } + private _whileCondition?: Expression; + + constructor(defaults: WhileRuleProps); + /** @hidden */ + constructor(_: undefined, inner: sassInternal.WhileRule); + constructor(defaults?: WhileRuleProps, inner?: sassInternal.WhileRule) { + super(defaults as unknown as postcss.AtRuleProps); + this.nodes ??= []; + + if (inner) { + this.source = new LazySource(inner); + this.whileCondition = convertExpression(inner.condition); + appendInternalChildren(this, inner.children); + } + } + + clone(overrides?: Partial): this { + return utils.cloneNode( + this, + overrides, + ['raws', 'whileCondition'] + ); + } + + toJSON(): object; + /** @hidden */ + toJSON(_: string, inputs: Map): object; + toJSON(_?: string, inputs?: Map): object { + return utils.toJSON( + this, + ['name', 'whileCondition', 'params', 'nodes'], + inputs + ); + } + + /** @hidden */ + toString( + stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss + .stringify + ): string { + return super.toString(stringifier); + } + + /** @hidden */ + get nonStatementChildren(): ReadonlyArray { + return [this.whileCondition]; + } + + /** @hidden */ + normalize(node: NewNode, sample?: postcss.Node): ChildNode[] { + return normalize(this, node, sample); + } +} + +interceptIsClean(WhileRule); diff --git a/pkg/sass-parser/lib/src/stringifier.ts b/pkg/sass-parser/lib/src/stringifier.ts index 9ce52a86e..0770b4a08 100644 --- a/pkg/sass-parser/lib/src/stringifier.ts +++ b/pkg/sass-parser/lib/src/stringifier.ts @@ -37,6 +37,7 @@ import {Rule} from './statement/rule'; import {SassComment} from './statement/sass-comment'; import {UseRule} from './statement/use-rule'; import {WarnRule} from './statement/warn-rule'; +import {WhileRule} from './statement/while-rule'; const PostCssStringifier = require('postcss/lib/stringifier'); @@ -165,18 +166,22 @@ export class Stringifier extends PostCssStringifier { this.sassAtRule(node, semicolon); } + private ['while-rule'](node: WhileRule): void { + this.sassAtRule(node); + } + /** Helper method for non-generic Sass at-rules. */ private sassAtRule(node: postcss.AtRule, semicolon?: boolean): void { const start = '@' + node.name + (node.raws.afterName ?? ' ') + - node.params + - (node.raws.between ?? ''); + node.params; if (node.nodes) { this.block(node, start); } else { - this.builder(start + (semicolon ? ';' : ''), node); + this.builder(start + + (node.raws.between ?? '') + (semicolon ? ';' : ''), node); } } } From c2af6f10678b6d55a85e43fd4c7a31a847db101d Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 29 Oct 2024 15:35:28 -0700 Subject: [PATCH 2/5] Reformat --- pkg/sass-parser/lib/index.ts | 6 +- .../lib/src/statement/while-rule.test.ts | 131 +++++++++--------- .../lib/src/statement/while-rule.ts | 6 +- pkg/sass-parser/lib/src/stringifier.ts | 12 +- 4 files changed, 76 insertions(+), 79 deletions(-) diff --git a/pkg/sass-parser/lib/index.ts b/pkg/sass-parser/lib/index.ts index 9309d4ce2..f93c3f11c 100644 --- a/pkg/sass-parser/lib/index.ts +++ b/pkg/sass-parser/lib/index.ts @@ -102,7 +102,11 @@ export { VariableDeclarationRaws, } from './src/statement/variable-declaration'; export {WarnRule, WarnRuleProps, WarnRuleRaws} from './src/statement/warn-rule'; -export {WhileRule, WhileRuleProps, WhileRuleRaws} from './src/statement/while-rule'; +export { + WhileRule, + WhileRuleProps, + WhileRuleRaws, +} from './src/statement/while-rule'; /** Options that can be passed to the Sass parsers to control their behavior. */ export type SassParserOptions = Pick; diff --git a/pkg/sass-parser/lib/src/statement/while-rule.test.ts b/pkg/sass-parser/lib/src/statement/while-rule.test.ts index 05cf78ee6..29adbd414 100644 --- a/pkg/sass-parser/lib/src/statement/while-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/while-rule.test.ts @@ -8,97 +8,96 @@ import * as utils from '../../../test/utils'; describe('a @while rule', () => { let node: WhileRule; describe('with empty children', () => { - function describeNode(description: string, create: () => WhileRule): void { - describe(description, () => { - beforeEach(() => void (node = create())); + function describeNode(description: string, create: () => WhileRule): void { + describe(description, () => { + beforeEach(() => void (node = create())); - it('has a name', () => expect(node.name.toString()).toBe('while')); + it('has a name', () => expect(node.name.toString()).toBe('while')); - it('has an expression', () => - expect(node).toHaveStringExpression('whileCondition', 'foo')); + it('has an expression', () => + expect(node).toHaveStringExpression('whileCondition', 'foo')); - it('has matching params', () => expect(node.params).toBe('foo')); + it('has matching params', () => expect(node.params).toBe('foo')); - it('has empty nodes', () => expect(node.nodes).toEqual([])); - }); - } - - describeNode( - 'parsed as SCSS', - () => scss.parse('@while foo {}').nodes[0] as WhileRule - ); - - describeNode( - 'parsed as Sass', - () => sass.parse('@while foo').nodes[0] as WhileRule - ); - - describeNode( - 'constructed manually', - () => - new WhileRule({ + it('has empty nodes', () => expect(node.nodes).toEqual([])); + }); + } + + describeNode( + 'parsed as SCSS', + () => scss.parse('@while foo {}').nodes[0] as WhileRule + ); + + describeNode( + 'parsed as Sass', + () => sass.parse('@while foo').nodes[0] as WhileRule + ); + + describeNode( + 'constructed manually', + () => + new WhileRule({ + whileCondition: {text: 'foo'}, + }) + ); + + describeNode('constructed from ChildProps', () => + utils.fromChildProps({ whileCondition: {text: 'foo'}, }) - ); - - describeNode('constructed from ChildProps', () => - utils.fromChildProps({ - whileCondition: {text: 'foo'}, - }) - ); + ); }); describe('with a child', () => { - function describeNode(description: string, create: () => WhileRule): void { - describe(description, () => { - beforeEach(() => void (node = create())); + function describeNode(description: string, create: () => WhileRule): void { + describe(description, () => { + beforeEach(() => void (node = create())); - it('has a name', () => expect(node.name.toString()).toBe('while')); + it('has a name', () => expect(node.name.toString()).toBe('while')); - it('has an expression', () => - expect(node).toHaveStringExpression('whileCondition', 'foo')); + it('has an expression', () => + expect(node).toHaveStringExpression('whileCondition', 'foo')); - it('has matching params', () => expect(node.params).toBe('foo')); + it('has matching params', () => expect(node.params).toBe('foo')); it('has a child node', () => { expect(node.nodes).toHaveLength(1); expect(node.nodes[0]).toBeInstanceOf(GenericAtRule); expect(node.nodes[0]).toHaveProperty('name', 'child'); }); - }); - } - - describeNode( - 'parsed as SCSS', - () => scss.parse('@while foo {@child}').nodes[0] as WhileRule - ); - - describeNode( - 'parsed as Sass', - () => sass.parse('@while foo\n @child').nodes[0] as WhileRule - ); - - describeNode( - 'constructed manually', - () => - new WhileRule({ + }); + } + + describeNode( + 'parsed as SCSS', + () => scss.parse('@while foo {@child}').nodes[0] as WhileRule + ); + + describeNode( + 'parsed as Sass', + () => sass.parse('@while foo\n @child').nodes[0] as WhileRule + ); + + describeNode( + 'constructed manually', + () => + new WhileRule({ + whileCondition: {text: 'foo'}, + nodes: [{name: 'child'}], + }) + ); + + describeNode('constructed from ChildProps', () => + utils.fromChildProps({ whileCondition: {text: 'foo'}, nodes: [{name: 'child'}], }) - ); - - describeNode('constructed from ChildProps', () => - utils.fromChildProps({ - whileCondition: {text: 'foo'}, - nodes: [{name: 'child'}], - }) - ); + ); }); describe('throws an error when assigned a new', () => { beforeEach( - () => - void (node = new WhileRule({whileCondition: {text: 'foo'}})) + () => void (node = new WhileRule({whileCondition: {text: 'foo'}})) ); it('name', () => expect(() => (node.name = 'bar')).toThrow()); diff --git a/pkg/sass-parser/lib/src/statement/while-rule.ts b/pkg/sass-parser/lib/src/statement/while-rule.ts index 0adb4ce74..0169527de 100644 --- a/pkg/sass-parser/lib/src/statement/while-rule.ts +++ b/pkg/sass-parser/lib/src/statement/while-rule.ts @@ -100,11 +100,7 @@ export class WhileRule } clone(overrides?: Partial): this { - return utils.cloneNode( - this, - overrides, - ['raws', 'whileCondition'] - ); + return utils.cloneNode(this, overrides, ['raws', 'whileCondition']); } toJSON(): object; diff --git a/pkg/sass-parser/lib/src/stringifier.ts b/pkg/sass-parser/lib/src/stringifier.ts index 0770b4a08..b83a3aa3c 100644 --- a/pkg/sass-parser/lib/src/stringifier.ts +++ b/pkg/sass-parser/lib/src/stringifier.ts @@ -172,16 +172,14 @@ export class Stringifier extends PostCssStringifier { /** Helper method for non-generic Sass at-rules. */ private sassAtRule(node: postcss.AtRule, semicolon?: boolean): void { - const start = - '@' + - node.name + - (node.raws.afterName ?? ' ') + - node.params; + const start = '@' + node.name + (node.raws.afterName ?? ' ') + node.params; if (node.nodes) { this.block(node, start); } else { - this.builder(start + - (node.raws.between ?? '') + (semicolon ? ';' : ''), node); + this.builder( + start + (node.raws.between ?? '') + (semicolon ? ';' : ''), + node + ); } } } From c1a85f509ee55030910ea1eecf04f0d5074f7fbb Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 29 Oct 2024 18:31:04 -0700 Subject: [PATCH 3/5] Reformat with GTS 6 --- pkg/sass-parser/lib/index.ts | 2 +- pkg/sass-parser/lib/src/configuration.test.ts | 45 ++++---- pkg/sass-parser/lib/src/configuration.ts | 2 +- .../lib/src/configured-variable.test.ts | 62 +++++------ .../lib/src/configured-variable.ts | 4 +- .../src/expression/binary-operation.test.ts | 14 +-- .../lib/src/expression/binary-operation.ts | 2 +- .../lib/src/expression/boolean.test.ts | 12 +- pkg/sass-parser/lib/src/expression/convert.ts | 2 +- .../lib/src/expression/number.test.ts | 18 +-- .../lib/src/expression/string.test.ts | 38 +++---- pkg/sass-parser/lib/src/expression/string.ts | 2 +- pkg/sass-parser/lib/src/interpolation.test.ts | 72 ++++++------ pkg/sass-parser/lib/src/interpolation.ts | 20 ++-- pkg/sass-parser/lib/src/lazy-source.ts | 2 +- pkg/sass-parser/lib/src/node.d.ts | 6 +- pkg/sass-parser/lib/src/sass-internal.ts | 6 +- .../lib/src/statement/at-root-rule.test.ts | 20 ++-- .../lib/src/statement/at-rule-internal.d.ts | 24 ++-- .../lib/src/statement/container.test.ts | 30 ++--- .../lib/src/statement/css-comment.test.ts | 22 ++-- .../lib/src/statement/css-comment.ts | 6 +- .../lib/src/statement/debug-rule.test.ts | 16 +-- .../lib/src/statement/debug-rule.ts | 6 +- .../src/statement/declaration-internal.d.ts | 24 ++-- .../lib/src/statement/each-rule.test.ts | 29 +++-- .../lib/src/statement/each-rule.ts | 4 +- .../lib/src/statement/error-rule.test.ts | 16 +-- .../lib/src/statement/error-rule.ts | 6 +- .../lib/src/statement/extend-rule.test.ts | 8 +- .../lib/src/statement/for-rule.test.ts | 32 +++--- pkg/sass-parser/lib/src/statement/for-rule.ts | 4 +- .../lib/src/statement/generic-at-rule.test.ts | 104 +++++++++--------- .../lib/src/statement/generic-at-rule.ts | 8 +- pkg/sass-parser/lib/src/statement/index.ts | 10 +- .../lib/src/statement/intercept-is-clean.ts | 2 +- .../lib/src/statement/media-rule.test.ts | 8 +- .../lib/src/statement/root-internal.d.ts | 24 ++-- .../lib/src/statement/root.test.ts | 6 +- pkg/sass-parser/lib/src/statement/root.ts | 2 +- .../lib/src/statement/rule-internal.d.ts | 24 ++-- .../lib/src/statement/rule.test.ts | 36 +++--- pkg/sass-parser/lib/src/statement/rule.ts | 6 +- .../lib/src/statement/sass-comment.test.ts | 34 +++--- .../lib/src/statement/sass-comment.ts | 10 +- .../lib/src/statement/supports-rule.test.ts | 34 +++--- .../lib/src/statement/use-rule.test.ts | 65 ++++++----- pkg/sass-parser/lib/src/statement/use-rule.ts | 6 +- .../statement/variable-declaration.test.ts | 84 +++++++------- .../lib/src/statement/variable-declaration.ts | 6 +- .../lib/src/statement/warn-rule.test.ts | 16 +-- .../lib/src/statement/warn-rule.ts | 6 +- pkg/sass-parser/lib/src/stringifier.ts | 10 +- pkg/sass-parser/lib/src/utils.ts | 10 +- pkg/sass-parser/test/setup.ts | 22 ++-- pkg/sass-parser/test/utils.ts | 2 +- 56 files changed, 544 insertions(+), 547 deletions(-) diff --git a/pkg/sass-parser/lib/index.ts b/pkg/sass-parser/lib/index.ts index f9acab292..f93c3f11c 100644 --- a/pkg/sass-parser/lib/index.ts +++ b/pkg/sass-parser/lib/index.ts @@ -135,7 +135,7 @@ class _Syntax implements Syntax { return new Root( undefined, - sassInternal.parse(css.toString(), this.#syntax, opts?.from), + sassInternal.parse(css.toString(), this.#syntax, opts?.from) ); } diff --git a/pkg/sass-parser/lib/src/configuration.test.ts b/pkg/sass-parser/lib/src/configuration.test.ts index e0f88aa6d..b260efef3 100644 --- a/pkg/sass-parser/lib/src/configuration.test.ts +++ b/pkg/sass-parser/lib/src/configuration.test.ts @@ -18,7 +18,7 @@ describe('a configuration map', () => { describe('empty', () => { function describeNode( description: string, - create: () => Configuration, + create: () => Configuration ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -35,12 +35,12 @@ describe('a configuration map', () => { describeNode( 'parsed as SCSS', - () => (scss.parse('@use "foo"').nodes[0] as UseRule).configuration, + () => (scss.parse('@use "foo"').nodes[0] as UseRule).configuration ); describeNode( 'parsed as Sass', - () => (sass.parse('@use "foo"').nodes[0] as UseRule).configuration, + () => (sass.parse('@use "foo"').nodes[0] as UseRule).configuration ); describe('constructed manually', () => { @@ -50,7 +50,7 @@ describe('a configuration map', () => { describeNode( 'variables record', - () => new Configuration({variables: {}}), + () => new Configuration({variables: {}}) ); }); @@ -58,14 +58,14 @@ describe('a configuration map', () => { 'constructed from props', () => new UseRule({useUrl: 'foo', configuration: {variables: []}}) - .configuration, + .configuration ); }); describe('with a variable', () => { function describeNode( description: string, - create: () => Configuration, + create: () => Configuration ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -86,14 +86,14 @@ describe('a configuration map', () => { 'parsed as SCSS', () => (scss.parse('@use "foo" with ($bar: "baz")').nodes[0] as UseRule) - .configuration, + .configuration ); describeNode( 'parsed as Sass', () => (sass.parse('@use "foo" with ($bar: "baz")').nodes[0] as UseRule) - .configuration, + .configuration ); describe('constructed manually', () => { @@ -104,13 +104,12 @@ describe('a configuration map', () => { variables: [ {variableName: 'bar', expression: {text: 'baz', quotes: true}}, ], - }), + }) ); describeNode( 'variables record', - () => - new Configuration({variables: {bar: {text: 'baz', quotes: true}}}), + () => new Configuration({variables: {bar: {text: 'baz', quotes: true}}}) ); }); @@ -120,7 +119,7 @@ describe('a configuration map', () => { new UseRule({ useUrl: 'foo', configuration: {variables: {bar: {text: 'baz', quotes: true}}}, - }).configuration, + }).configuration ); }); @@ -226,7 +225,7 @@ describe('a configuration map', () => { describe('adds a new variable', () => { function describeVariable( description: string, - create: () => Configuration, + create: () => Configuration ): void { it(description, () => { expect(create()).toBe(node); @@ -239,15 +238,15 @@ describe('a configuration map', () => { } describeVariable('with Expression', () => - node.set('baz', new StringExpression({text: 'bang', quotes: true})), + node.set('baz', new StringExpression({text: 'bang', quotes: true})) ); describeVariable('with ExpressionProps', () => - node.set('baz', {text: 'bang', quotes: true}), + node.set('baz', {text: 'bang', quotes: true}) ); describeVariable('with ConfiguredVariableObjectProps', () => - node.set('baz', {expression: {text: 'bang', quotes: true}}), + node.set('baz', {expression: {text: 'bang', quotes: true}}) ); }); @@ -270,7 +269,7 @@ describe('a configuration map', () => { foo: {text: 'bar', quotes: true}, baz: {text: 'bang', quotes: true}, }, - }).toString(), + }).toString() ).toBe('($foo: "bar", $baz: "bang")')); }); @@ -282,7 +281,7 @@ describe('a configuration map', () => { foo: {text: 'bar', quotes: true}, baz: {text: 'bang', quotes: true}, }, - }).toString(), + }).toString() ).toBe('($foo: "bar", $baz: "bang",)')); it('with comma: true and afterValue', () => @@ -296,7 +295,7 @@ describe('a configuration map', () => { raws: {afterValue: '/**/'}, }, }, - }).toString(), + }).toString() ).toBe('($foo: "bar", $baz: "bang"/**/,)')); it('with after', () => @@ -307,7 +306,7 @@ describe('a configuration map', () => { foo: {text: 'bar', quotes: true}, baz: {text: 'bang', quotes: true}, }, - }).toString(), + }).toString() ).toBe('($foo: "bar", $baz: "bang"/**/)')); it('with after and afterValue', () => @@ -321,7 +320,7 @@ describe('a configuration map', () => { raws: {afterValue: ' '}, }, }, - }).toString(), + }).toString() ).toBe('($foo: "bar", $baz: "bang" /**/)')); it('with afterValue and a guard', () => @@ -335,7 +334,7 @@ describe('a configuration map', () => { guarded: true, }, }, - }).toString(), + }).toString() ).toBe('($foo: "bar", $baz: "bang" !default/**/)')); }); }); @@ -423,6 +422,6 @@ describe('a configuration map', () => { it.skip('toJSON', () => expect( (scss.parse('@use "foo" with ($baz: "qux")').nodes[0] as UseRule) - .configuration, + .configuration ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/configuration.ts b/pkg/sass-parser/lib/src/configuration.ts index b57226a1e..ecd930fbc 100644 --- a/pkg/sass-parser/lib/src/configuration.ts +++ b/pkg/sass-parser/lib/src/configuration.ts @@ -66,7 +66,7 @@ export class Configuration extends Node { constructor(_: undefined, inner: sassInternal.ConfiguredVariable[]); constructor( defaults?: ConfigurationProps, - inner?: sassInternal.ConfiguredVariable[], + inner?: sassInternal.ConfiguredVariable[] ) { super({}); this.raws = defaults?.raws ?? {}; diff --git a/pkg/sass-parser/lib/src/configured-variable.test.ts b/pkg/sass-parser/lib/src/configured-variable.test.ts index c673670a8..33a0de857 100644 --- a/pkg/sass-parser/lib/src/configured-variable.test.ts +++ b/pkg/sass-parser/lib/src/configured-variable.test.ts @@ -11,13 +11,13 @@ describe('a configured variable', () => { void (node = new ConfiguredVariable({ variableName: 'foo', expression: {text: 'bar', quotes: true}, - })), + })) ); describe('unguarded', () => { function describeNode( description: string, - create: () => ConfiguredVariable, + create: () => ConfiguredVariable ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -39,7 +39,7 @@ describe('a configured variable', () => { () => ( scss.parse('@use "baz" with ($foo: "bar")').nodes[0] as UseRule - ).configuration.get('foo')!, + ).configuration.get('foo')! ); describeNode( @@ -47,7 +47,7 @@ describe('a configured variable', () => { () => ( sass.parse('@use "baz" with ($foo: "bar")').nodes[0] as UseRule - ).configuration.get('foo')!, + ).configuration.get('foo')! ); describe('constructed manually', () => { @@ -58,12 +58,12 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', new StringExpression({text: 'bar', quotes: true}), - ]), + ]) ); describeNode( 'with ExpressionProps', - () => new ConfiguredVariable(['foo', {text: 'bar', quotes: true}]), + () => new ConfiguredVariable(['foo', {text: 'bar', quotes: true}]) ); describe('with an object', () => { @@ -73,7 +73,7 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', {expression: new StringExpression({text: 'bar', quotes: true})}, - ]), + ]) ); describeNode( @@ -82,7 +82,7 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', {expression: {text: 'bar', quotes: true}}, - ]), + ]) ); }); }); @@ -94,7 +94,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), - }), + }) ); describeNode( @@ -103,7 +103,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'foo', expression: {text: 'bar', quotes: true}, - }), + }) ); }); }); @@ -112,7 +112,7 @@ describe('a configured variable', () => { describe('guarded', () => { function describeNode( description: string, - create: () => ConfiguredVariable, + create: () => ConfiguredVariable ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -159,7 +159,7 @@ describe('a configured variable', () => { expression: new StringExpression({text: 'bar', quotes: true}), guarded: true, }, - ]), + ]) ); describeNode( @@ -168,7 +168,7 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', {expression: {text: 'bar', quotes: true}, guarded: true}, - ]), + ]) ); }); @@ -180,7 +180,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), guarded: true, - }), + }) ); describeNode( @@ -190,7 +190,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, guarded: true, - }), + }) ); }); }); @@ -221,7 +221,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'foo', expression: {text: 'bar', quotes: true}, - }).toString(), + }).toString() ).toBe('$foo: "bar"')); it('guarded', () => @@ -230,7 +230,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, guarded: true, - }).toString(), + }).toString() ).toBe('$foo: "bar" !default')); it('with a non-identifier name', () => @@ -238,7 +238,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'f o', expression: {text: 'bar', quotes: true}, - }).toString(), + }).toString() ).toBe('$f\\20o: "bar"')); }); @@ -249,7 +249,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {before: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: "bar"')); it('with matching name', () => @@ -258,7 +258,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {variableName: {raw: 'f\\6fo', value: 'foo'}}, - }).toString(), + }).toString() ).toBe('$f\\6fo: "bar"')); it('with non-matching name', () => @@ -267,7 +267,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {variableName: {raw: 'f\\41o', value: 'fao'}}, - }).toString(), + }).toString() ).toBe('$foo: "bar"')); it('with between', () => @@ -276,7 +276,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {between: ' : '}, - }).toString(), + }).toString() ).toBe('$foo : "bar"')); it('with beforeGuard and a guard', () => @@ -286,7 +286,7 @@ describe('a configured variable', () => { expression: {text: 'bar', quotes: true}, guarded: true, raws: {beforeGuard: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: "bar"/**/!default')); it('with beforeGuard and no guard', () => @@ -295,7 +295,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {beforeGuard: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: "bar"')); // raws.before is only used as part of a Configuration @@ -306,7 +306,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {afterValue: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: "bar"')); it('with a guard', () => @@ -316,7 +316,7 @@ describe('a configured variable', () => { expression: {text: 'bar', quotes: true}, guarded: true, raws: {afterValue: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: "bar" !default')); }); }); @@ -369,24 +369,24 @@ describe('a configured variable', () => { describe('variableName', () => { it('defined', () => expect(original.clone({variableName: 'baz'}).variableName).toBe( - 'baz', + 'baz' )); it('undefined', () => expect(original.clone({variableName: undefined}).variableName).toBe( - 'foo', + 'foo' )); }); describe('expression', () => { it('defined', () => expect( - original.clone({expression: {text: 'baz', quotes: true}}), + original.clone({expression: {text: 'baz', quotes: true}}) ).toHaveStringExpression('expression', 'baz')); it('undefined', () => expect( - original.clone({expression: undefined}), + original.clone({expression: undefined}) ).toHaveStringExpression('expression', 'bar')); }); @@ -404,6 +404,6 @@ describe('a configured variable', () => { expect( ( scss.parse('@use "foo" with ($baz: "qux")').nodes[0] as UseRule - ).configuration.get('baz'), + ).configuration.get('baz') ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/configured-variable.ts b/pkg/sass-parser/lib/src/configured-variable.ts index 17dcea6f7..82f5d12aa 100644 --- a/pkg/sass-parser/lib/src/configured-variable.ts +++ b/pkg/sass-parser/lib/src/configured-variable.ts @@ -122,7 +122,7 @@ export class ConfiguredVariable extends Node { constructor(_: undefined, inner: sassInternal.ConfiguredVariable); constructor( defaults?: ConfiguredVariableProps, - inner?: sassInternal.ConfiguredVariable, + inner?: sassInternal.ConfiguredVariable ) { if (Array.isArray(defaults!)) { const [variableName, rest] = defaults; @@ -164,7 +164,7 @@ export class ConfiguredVariable extends Node { return utils.toJSON( this, ['variableName', 'expression', 'guarded'], - inputs, + inputs ); } diff --git a/pkg/sass-parser/lib/src/expression/binary-operation.test.ts b/pkg/sass-parser/lib/src/expression/binary-operation.test.ts index cd9d06d74..c03cd6c9c 100644 --- a/pkg/sass-parser/lib/src/expression/binary-operation.test.ts +++ b/pkg/sass-parser/lib/src/expression/binary-operation.test.ts @@ -9,7 +9,7 @@ describe('a binary operation', () => { let node: BinaryOperationExpression; function describeNode( description: string, - create: () => BinaryOperationExpression, + create: () => BinaryOperationExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -36,7 +36,7 @@ describe('a binary operation', () => { operator: '+', left: {text: 'foo'}, right: {text: 'bar'}, - }), + }) ); describeNode('constructed from ExpressionProps', () => @@ -44,7 +44,7 @@ describe('a binary operation', () => { operator: '+', left: {text: 'foo'}, right: {text: 'bar'}, - }), + }) ); describe('assigned new', () => { @@ -158,13 +158,13 @@ describe('a binary operation', () => { it('defined', () => expect(original.clone({left: {text: 'zip'}})).toHaveStringExpression( 'left', - 'zip', + 'zip' )); it('undefined', () => expect(original.clone({left: undefined})).toHaveStringExpression( 'left', - 'foo', + 'foo' )); }); @@ -172,13 +172,13 @@ describe('a binary operation', () => { it('defined', () => expect(original.clone({right: {text: 'zip'}})).toHaveStringExpression( 'right', - 'zip', + 'zip' )); it('undefined', () => expect(original.clone({right: undefined})).toHaveStringExpression( 'right', - 'bar', + 'bar' )); }); diff --git a/pkg/sass-parser/lib/src/expression/binary-operation.ts b/pkg/sass-parser/lib/src/expression/binary-operation.ts index e6f180521..12054630c 100644 --- a/pkg/sass-parser/lib/src/expression/binary-operation.ts +++ b/pkg/sass-parser/lib/src/expression/binary-operation.ts @@ -109,7 +109,7 @@ export class BinaryOperationExpression extends Expression { constructor(_: undefined, inner: sassInternal.BinaryOperationExpression); constructor( defaults?: object, - inner?: sassInternal.BinaryOperationExpression, + inner?: sassInternal.BinaryOperationExpression ) { super(defaults); if (inner) { diff --git a/pkg/sass-parser/lib/src/expression/boolean.test.ts b/pkg/sass-parser/lib/src/expression/boolean.test.ts index 9322e257d..ca9f64f1b 100644 --- a/pkg/sass-parser/lib/src/expression/boolean.test.ts +++ b/pkg/sass-parser/lib/src/expression/boolean.test.ts @@ -11,7 +11,7 @@ describe('a boolean expression', () => { describe('true', () => { function describeNode( description: string, - create: () => BooleanExpression, + create: () => BooleanExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -26,18 +26,18 @@ describe('a boolean expression', () => { describeNode( 'constructed manually', - () => new BooleanExpression({value: true}), + () => new BooleanExpression({value: true}) ); describeNode('constructed from ExpressionProps', () => - utils.fromExpressionProps({value: true}), + utils.fromExpressionProps({value: true}) ); }); describe('false', () => { function describeNode( description: string, - create: () => BooleanExpression, + create: () => BooleanExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -52,11 +52,11 @@ describe('a boolean expression', () => { describeNode( 'constructed manually', - () => new BooleanExpression({value: false}), + () => new BooleanExpression({value: false}) ); describeNode('constructed from ExpressionProps', () => - utils.fromExpressionProps({value: false}), + utils.fromExpressionProps({value: false}) ); }); diff --git a/pkg/sass-parser/lib/src/expression/convert.ts b/pkg/sass-parser/lib/src/expression/convert.ts index 63619898f..52cbb2363 100644 --- a/pkg/sass-parser/lib/src/expression/convert.ts +++ b/pkg/sass-parser/lib/src/expression/convert.ts @@ -21,7 +21,7 @@ const visitor = sassInternal.createExpressionVisitor({ /** Converts an internal expression AST node into an external one. */ export function convertExpression( - expression: sassInternal.Expression, + expression: sassInternal.Expression ): Expression { return expression.accept(visitor); } diff --git a/pkg/sass-parser/lib/src/expression/number.test.ts b/pkg/sass-parser/lib/src/expression/number.test.ts index 3e95a2061..7a3fe7671 100644 --- a/pkg/sass-parser/lib/src/expression/number.test.ts +++ b/pkg/sass-parser/lib/src/expression/number.test.ts @@ -11,7 +11,7 @@ describe('a number expression', () => { describe('unitless', () => { function describeNode( description: string, - create: () => NumberExpression, + create: () => NumberExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -28,18 +28,18 @@ describe('a number expression', () => { describeNode( 'constructed manually', - () => new NumberExpression({value: 123}), + () => new NumberExpression({value: 123}) ); describeNode('constructed from ExpressionProps', () => - utils.fromExpressionProps({value: 123}), + utils.fromExpressionProps({value: 123}) ); }); describe('with a unit', () => { function describeNode( description: string, - create: () => NumberExpression, + create: () => NumberExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -60,14 +60,14 @@ describe('a number expression', () => { new NumberExpression({ value: 123, unit: 'px', - }), + }) ); describeNode('constructed from ExpressionProps', () => utils.fromExpressionProps({ value: 123, unit: 'px', - }), + }) ); }); @@ -119,7 +119,7 @@ describe('a number expression', () => { new NumberExpression({ value: 123, raws: {value: {raw: 'hello', value: 123}}, - }).toString(), + }).toString() ).toBe('hello')); it('with a different raw value than the expression', () => @@ -127,7 +127,7 @@ describe('a number expression', () => { new NumberExpression({ value: 123, raws: {value: {raw: 'hello', value: 234}}, - }).toString(), + }).toString() ).toBe('123')); }); }); @@ -180,7 +180,7 @@ describe('a number expression', () => { describe('raws', () => { it('defined', () => expect( - original.clone({raws: {value: {raw: '1e3', value: 1e3}}}).raws, + original.clone({raws: {value: {raw: '1e3', value: 1e3}}}).raws ).toEqual({ value: {raw: '1e3', value: 1e3}, })); diff --git a/pkg/sass-parser/lib/src/expression/string.test.ts b/pkg/sass-parser/lib/src/expression/string.test.ts index 39dae45d8..eb5d99074 100644 --- a/pkg/sass-parser/lib/src/expression/string.test.ts +++ b/pkg/sass-parser/lib/src/expression/string.test.ts @@ -10,7 +10,7 @@ describe('a string expression', () => { describe('quoted', () => { function describeNode( description: string, - create: () => StringExpression, + create: () => StringExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -32,7 +32,7 @@ describe('a string expression', () => { new StringExpression({ quotes: true, text: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode( @@ -41,7 +41,7 @@ describe('a string expression', () => { new StringExpression({ quotes: true, text: 'foo', - }), + }) ); }); @@ -50,14 +50,14 @@ describe('a string expression', () => { utils.fromExpressionProps({ quotes: true, text: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode('with string text', () => utils.fromExpressionProps({ quotes: true, text: 'foo', - }), + }) ); }); }); @@ -65,7 +65,7 @@ describe('a string expression', () => { describe('unquoted', () => { function describeNode( description: string, - create: () => StringExpression, + create: () => StringExpression ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -86,7 +86,7 @@ describe('a string expression', () => { () => new StringExpression({ text: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode( @@ -95,7 +95,7 @@ describe('a string expression', () => { new StringExpression({ quotes: false, text: 'foo', - }), + }) ); describeNode( @@ -103,7 +103,7 @@ describe('a string expression', () => { () => new StringExpression({ text: 'foo', - }), + }) ); }); @@ -111,20 +111,20 @@ describe('a string expression', () => { describeNode('with explicit text', () => utils.fromExpressionProps({ text: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode('with explicit quotes', () => utils.fromExpressionProps({ quotes: false, text: 'foo', - }), + }) ); describeNode('with string text', () => utils.fromExpressionProps({ text: 'foo', - }), + }) ); }); }); @@ -210,17 +210,17 @@ describe('a string expression', () => { it('with internal unprintable', () => expect( - new StringExpression({quotes: true, text: '\x00'}).toString(), + new StringExpression({quotes: true, text: '\x00'}).toString() ).toBe('"\\0 "')); it('with internal newline', () => expect( - new StringExpression({quotes: true, text: '\x0A'}).toString(), + new StringExpression({quotes: true, text: '\x0A'}).toString() ).toBe('"\\a "')); it('with internal backslash', () => expect( - new StringExpression({quotes: true, text: '\\'}).toString(), + new StringExpression({quotes: true, text: '\\'}).toString() ).toBe('"\\\\"')); it('respects interpolation raws', () => @@ -231,7 +231,7 @@ describe('a string expression', () => { nodes: ['foo'], raws: {text: [{raw: 'f\\6f o', value: 'foo'}]}, }), - }).toString(), + }).toString() ).toBe('"f\\6f o"')); }); @@ -255,7 +255,7 @@ describe('a string expression', () => { nodes: ['foo'], raws: {text: [{raw: 'f\\6f o', value: 'foo'}]}, }), - }).toString(), + }).toString() ).toBe('f\\6f o')); }); }); @@ -304,13 +304,13 @@ describe('a string expression', () => { it('defined', () => expect(original.clone({text: 'zip'})).toHaveInterpolation( 'text', - 'zip', + 'zip' )); it('undefined', () => expect(original.clone({text: undefined})).toHaveInterpolation( 'text', - 'foo', + 'foo' )); }); diff --git a/pkg/sass-parser/lib/src/expression/string.ts b/pkg/sass-parser/lib/src/expression/string.ts index e1638da62..de796e807 100644 --- a/pkg/sass-parser/lib/src/expression/string.ts +++ b/pkg/sass-parser/lib/src/expression/string.ts @@ -104,7 +104,7 @@ export class StringExpression extends Expression { /** @hidden */ toString(): string { - const quote = this.quotes ? (this.raws.quotes ?? '"') : ''; + const quote = this.quotes ? this.raws.quotes ?? '"' : ''; let result = quote; const rawText = this.text.raws.text; const rawExpressions = this.text.raws.expressions; diff --git a/pkg/sass-parser/lib/src/interpolation.test.ts b/pkg/sass-parser/lib/src/interpolation.test.ts index fd0b81e29..f5ec6684d 100644 --- a/pkg/sass-parser/lib/src/interpolation.test.ts +++ b/pkg/sass-parser/lib/src/interpolation.test.ts @@ -18,7 +18,7 @@ describe('an interpolation', () => { describe('empty', () => { function describeNode( description: string, - create: () => Interpolation, + create: () => Interpolation ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -42,7 +42,7 @@ describe('an interpolation', () => { describe('with no expressions', () => { function describeNode( description: string, - create: () => Interpolation, + create: () => Interpolation ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -63,24 +63,24 @@ describe('an interpolation', () => { describeNode( 'parsed as SCSS', - () => (scss.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation, + () => (scss.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation ); describeNode( 'parsed as CSS', - () => (css.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation, + () => (css.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation ); describeNode( 'constructed manually', - () => new Interpolation({nodes: ['foo']}), + () => new Interpolation({nodes: ['foo']}) ); }); describe('with only an expression', () => { function describeNode( description: string, - create: () => Interpolation, + create: () => Interpolation ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -99,19 +99,19 @@ describe('an interpolation', () => { describeNode( 'parsed as SCSS', - () => (scss.parse('@#{foo}').nodes[0] as GenericAtRule).nameInterpolation, + () => (scss.parse('@#{foo}').nodes[0] as GenericAtRule).nameInterpolation ); describeNode( 'constructed manually', - () => new Interpolation({nodes: [{text: 'foo'}]}), + () => new Interpolation({nodes: [{text: 'foo'}]}) ); }); describe('with mixed text and expressions', () => { function describeNode( description: string, - create: () => Interpolation, + create: () => Interpolation ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -136,12 +136,12 @@ describe('an interpolation', () => { 'parsed as SCSS', () => (scss.parse('@foo#{bar}baz').nodes[0] as GenericAtRule) - .nameInterpolation, + .nameInterpolation ); describeNode( 'constructed manually', - () => new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}), + () => new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}) ); }); @@ -246,7 +246,7 @@ describe('an interpolation', () => { describe('every', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) ); it('returns true if the callback returns true for all elements', () => @@ -261,7 +261,7 @@ describe('an interpolation', () => { () => void (node = new Interpolation({ nodes: ['foo', 'bar', {text: 'baz'}, 'bar'], - })), + })) ); it('returns the first index of a given string', () => @@ -275,7 +275,7 @@ describe('an interpolation', () => { describe('insertAfter', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) ); it('inserts a node after the given element', () => { @@ -300,12 +300,12 @@ describe('an interpolation', () => { it('inserts before an iterator', () => testEachMutation(['foo', 'bar', ['baz', 5]], 1, () => - node.insertAfter(0, ['qux', 'qax', 'qix']), + node.insertAfter(0, ['qux', 'qax', 'qix']) )); it('inserts after an iterator', () => testEachMutation(['foo', 'bar', 'qux', 'qax', 'qix', 'baz'], 1, () => - node.insertAfter(1, ['qux', 'qax', 'qix']), + node.insertAfter(1, ['qux', 'qax', 'qix']) )); it('returns itself', () => @@ -314,7 +314,7 @@ describe('an interpolation', () => { describe('insertBefore', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) ); it('inserts a node before the given element', () => { @@ -339,12 +339,12 @@ describe('an interpolation', () => { it('inserts before an iterator', () => testEachMutation(['foo', 'bar', ['baz', 5]], 1, () => - node.insertBefore(1, ['qux', 'qax', 'qix']), + node.insertBefore(1, ['qux', 'qax', 'qix']) )); it('inserts after an iterator', () => testEachMutation(['foo', 'bar', 'qux', 'qax', 'qix', 'baz'], 1, () => - node.insertBefore(2, ['qux', 'qax', 'qix']), + node.insertBefore(2, ['qux', 'qax', 'qix']) )); it('returns itself', () => @@ -353,7 +353,7 @@ describe('an interpolation', () => { describe('prepend', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) ); it('inserts one node', () => { @@ -368,7 +368,7 @@ describe('an interpolation', () => { it('inserts before an iterator', () => testEachMutation(['foo', 'bar', ['baz', 5]], 1, () => - node.prepend('qux', 'qax', 'qix'), + node.prepend('qux', 'qax', 'qix') )); it('returns itself', () => expect(node.prepend('qux')).toBe(node)); @@ -391,7 +391,7 @@ describe('an interpolation', () => { describe('removeAll', () => { beforeEach( () => - void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})), + void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})) ); it('removes all nodes', () => { @@ -414,7 +414,7 @@ describe('an interpolation', () => { describe('removeChild', () => { beforeEach( () => - void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})), + void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})) ); it('removes a matching node', () => { @@ -436,7 +436,7 @@ describe('an interpolation', () => { it('removes a node before the iterator', () => testEachMutation(['foo', node.nodes[1], ['baz', 1]], 1, () => - node.removeChild(1), + node.removeChild(1) )); it('removes a node after the iterator', () => @@ -447,7 +447,7 @@ describe('an interpolation', () => { describe('some', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) ); it('returns false if the callback returns false for all elements', () => @@ -460,7 +460,7 @@ describe('an interpolation', () => { describe('first', () => { it('returns the first element', () => expect(new Interpolation({nodes: ['foo', 'bar', 'baz']}).first).toBe( - 'foo', + 'foo' )); it('returns undefined for an empty interpolation', () => @@ -470,7 +470,7 @@ describe('an interpolation', () => { describe('last', () => { it('returns the last element', () => expect(new Interpolation({nodes: ['foo', 'bar', 'baz']}).last).toBe( - 'baz', + 'baz' )); it('returns undefined for an empty interpolation', () => @@ -482,22 +482,22 @@ describe('an interpolation', () => { it('with only text', () => expect(new Interpolation({nodes: ['foo', 'bar', 'baz']}).toString()).toBe( - 'foobarbaz', + 'foobarbaz' )); it('with only expressions', () => expect( - new Interpolation({nodes: [{text: 'foo'}, {text: 'bar'}]}).toString(), + new Interpolation({nodes: [{text: 'foo'}, {text: 'bar'}]}).toString() ).toBe('#{foo}#{bar}')); it('with mixed text and expressions', () => expect( - new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}).toString(), + new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}).toString() ).toBe('foo#{bar}baz')); describe('with text', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) ); it('take precedence when the value matches', () => { @@ -516,7 +516,7 @@ describe('an interpolation', () => { () => void (node = new Interpolation({ nodes: [{text: 'foo'}, {text: 'bar'}], - })), + })) ); it('with before', () => { @@ -538,7 +538,7 @@ describe('an interpolation', () => { void (original = new Interpolation({ nodes: ['foo', {text: 'bar'}, 'baz'], raws: {expressions: [{before: ' '}]}, - })), + })) ); describe('with no overrides', () => { @@ -578,7 +578,7 @@ describe('an interpolation', () => { describe('raws', () => { it('defined', () => expect( - original.clone({raws: {expressions: [{after: ' '}]}}).raws, + original.clone({raws: {expressions: [{after: ' '}]}}).raws ).toEqual({expressions: [{after: ' '}]})); it('undefined', () => @@ -605,7 +605,7 @@ describe('an interpolation', () => { it('toJSON', () => expect( - (scss.parse('@foo#{bar}baz').nodes[0] as GenericAtRule).nameInterpolation, + (scss.parse('@foo#{bar}baz').nodes[0] as GenericAtRule).nameInterpolation ).toMatchSnapshot()); }); @@ -620,7 +620,7 @@ describe('an interpolation', () => { function testEachMutation( elements: ([string | Expression, number] | string | Expression)[], indexToModify: number, - modify: () => void, + modify: () => void ): void { const fn: EachFn = jest.fn((child, i) => { if (i === indexToModify) modify(); diff --git a/pkg/sass-parser/lib/src/interpolation.ts b/pkg/sass-parser/lib/src/interpolation.ts index c051decc8..032c564dd 100644 --- a/pkg/sass-parser/lib/src/interpolation.ts +++ b/pkg/sass-parser/lib/src/interpolation.ts @@ -132,7 +132,7 @@ export class Interpolation extends Node { this._nodes = []; for (const child of inner.contents) { this.append( - typeof child === 'string' ? child : convertExpression(child), + typeof child === 'string' ? child : convertExpression(child) ); } } @@ -176,7 +176,7 @@ export class Interpolation extends Node { * @return Returns `false` if any call to `callback` returned false */ each( - callback: (node: string | Expression, index: number) => false | void, + callback: (node: string | Expression, index: number) => false | void ): false | undefined { const iterator = {index: 0}; this.#iterators.push(iterator); @@ -201,8 +201,8 @@ export class Interpolation extends Node { condition: ( node: string | Expression, index: number, - nodes: ReadonlyArray, - ) => boolean, + nodes: ReadonlyArray + ) => boolean ): boolean { return this.nodes.every(condition); } @@ -225,7 +225,7 @@ export class Interpolation extends Node { */ insertAfter( oldNode: string | Expression | number, - newNode: NewNodeForInterpolation, + newNode: NewNodeForInterpolation ): this { // TODO - postcss/postcss#1957: Mark this as dirty const index = this.index(oldNode); @@ -248,7 +248,7 @@ export class Interpolation extends Node { */ insertBefore( oldNode: string | Expression | number, - newNode: NewNodeForInterpolation, + newNode: NewNodeForInterpolation ): this { // TODO - postcss/postcss#1957: Mark this as dirty const index = this.index(oldNode); @@ -320,8 +320,8 @@ export class Interpolation extends Node { condition: ( node: string | Expression, index: number, - nodes: ReadonlyArray, - ) => boolean, + nodes: ReadonlyArray + ) => boolean ): boolean { return this.nodes.some(condition); } @@ -401,7 +401,7 @@ export class Interpolation extends Node { /** Like {@link _normalize}, but also flattens a list of nodes. */ private _normalizeList( - nodes: ReadonlyArray, + nodes: ReadonlyArray ): (Expression | string)[] { const result: Array = []; for (const node of nodes) { @@ -413,7 +413,7 @@ export class Interpolation extends Node { /** @hidden */ get nonStatementChildren(): ReadonlyArray { return this.nodes.filter( - (node): node is Expression => typeof node !== 'string', + (node): node is Expression => typeof node !== 'string' ); } } diff --git a/pkg/sass-parser/lib/src/lazy-source.ts b/pkg/sass-parser/lib/src/lazy-source.ts index bcf93bfcd..5deeadb4f 100644 --- a/pkg/sass-parser/lib/src/lazy-source.ts +++ b/pkg/sass-parser/lib/src/lazy-source.ts @@ -54,7 +54,7 @@ export class LazySource implements postcss.Source { const spanUrl = this.#inner.span.url; sourceFile._postcssInput = new postcss.Input( sourceFile.getText(0), - spanUrl ? {from: url.fileURLToPath(spanUrl)} : undefined, + spanUrl ? {from: url.fileURLToPath(spanUrl)} : undefined ); return sourceFile._postcssInput; } diff --git a/pkg/sass-parser/lib/src/node.d.ts b/pkg/sass-parser/lib/src/node.d.ts index 11f8d9ae2..432983699 100644 --- a/pkg/sass-parser/lib/src/node.d.ts +++ b/pkg/sass-parser/lib/src/node.d.ts @@ -82,10 +82,10 @@ declare abstract class Node cleanRaws(keepBetween?: boolean): void; error( message: string, - options?: postcss.NodeErrorOptions, + options?: postcss.NodeErrorOptions ): postcss.CssSyntaxError; positionBy( - opts?: Pick, + opts?: Pick ): postcss.Position; positionInside(index: number): postcss.Position; rangeBy(opts?: Pick): { @@ -98,6 +98,6 @@ declare abstract class Node warn( result: postcss.Result, message: string, - options?: postcss.WarningOptions, + options?: postcss.WarningOptions ): postcss.Warning; } diff --git a/pkg/sass-parser/lib/src/sass-internal.ts b/pkg/sass-parser/lib/src/sass-internal.ts index e4031d367..1f9594c8c 100644 --- a/pkg/sass-parser/lib/src/sass-internal.ts +++ b/pkg/sass-parser/lib/src/sass-internal.ts @@ -32,7 +32,7 @@ declare namespace SassInternal { function parseIdentifier( identifier: string, - logger?: sass.Logger, + logger?: sass.Logger ): string | null; function toCssIdentifier(text: string): string; @@ -42,7 +42,7 @@ declare namespace SassInternal { } function createStatementVisitor( - inner: StatementVisitorObject, + inner: StatementVisitorObject ): StatementVisitor; class ExpressionVisitor { @@ -50,7 +50,7 @@ declare namespace SassInternal { } function createExpressionVisitor( - inner: ExpressionVisitorObject, + inner: ExpressionVisitorObject ): ExpressionVisitor; class SassNode { diff --git a/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts b/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts index 5f7440c3b..b5c7a17f7 100644 --- a/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts @@ -9,7 +9,7 @@ describe('an @at-root rule', () => { describe('with no params', () => { beforeEach( - () => void (node = scss.parse('@at-root {}').nodes[0] as GenericAtRule), + () => void (node = scss.parse('@at-root {}').nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -24,7 +24,7 @@ describe('an @at-root rule', () => { beforeEach( () => void (node = scss.parse('@at-root (with: rule) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -41,7 +41,7 @@ describe('an @at-root rule', () => { beforeEach( () => void (node = scss.parse('@at-root (with: #{rule}) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -60,7 +60,7 @@ describe('an @at-root rule', () => { describe('with style rule shorthand', () => { beforeEach( () => - void (node = scss.parse('@at-root .foo {}').nodes[0] as GenericAtRule), + void (node = scss.parse('@at-root .foo {}').nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -85,7 +85,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{selector: '.foo'}], raws: {atRootShorthand: false}, - }).toString(), + }).toString() ).toBe('@at-root {\n .foo {}\n}')); describe('with atRootShorthand: true', () => { @@ -95,7 +95,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{selector: '.foo'}], raws: {atRootShorthand: true}, - }).toString(), + }).toString() ).toBe('@at-root .foo {}')); it('with no params and multiple children', () => @@ -104,7 +104,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{selector: '.foo'}, {selector: '.bar'}], raws: {atRootShorthand: true}, - }).toString(), + }).toString() ).toBe('@at-root {\n .foo {}\n .bar {}\n}')); it('with no params and a non-style-rule child', () => @@ -113,7 +113,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{name: 'foo'}], raws: {atRootShorthand: true}, - }).toString(), + }).toString() ).toBe('@at-root {\n @foo\n}')); it('with params and only a style rule child', () => @@ -123,7 +123,7 @@ describe('an @at-root rule', () => { params: '(with: rule)', nodes: [{selector: '.foo'}], raws: {atRootShorthand: true}, - }).toString(), + }).toString() ).toBe('@at-root (with: rule) {\n .foo {}\n}')); it("that's not @at-root", () => @@ -132,7 +132,7 @@ describe('an @at-root rule', () => { name: 'at-wrong', nodes: [{selector: '.foo'}], raws: {atRootShorthand: true}, - }).toString(), + }).toString() ).toBe('@at-wrong {\n .foo {}\n}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts b/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts index e5395cdca..7228613f8 100644 --- a/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts @@ -27,10 +27,10 @@ export class _AtRule extends postcss.AtRule { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -40,37 +40,37 @@ export class _AtRule extends postcss.AtRule { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/container.test.ts b/pkg/sass-parser/lib/src/statement/container.test.ts index 52e736787..46ab1fad6 100644 --- a/pkg/sass-parser/lib/src/statement/container.test.ts +++ b/pkg/sass-parser/lib/src/statement/container.test.ts @@ -37,12 +37,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar', + '.bar' ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -56,7 +56,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[0].source).toBe(node.source); @@ -81,12 +81,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar', + '.bar' ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -102,12 +102,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar', + '.bar' ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -120,7 +120,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[0].parent).toBe(root); }); @@ -130,7 +130,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[0].parent).toBe(root); }); @@ -138,17 +138,17 @@ describe('a container node', () => { it('a list of properties', () => { root.append( {selectorInterpolation: '.foo'}, - {selectorInterpolation: '.bar'}, + {selectorInterpolation: '.bar'} ); expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar', + '.bar' ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -159,7 +159,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[0].parent).toBe(root); }); @@ -169,12 +169,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo', + '.foo' ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar', + '.bar' ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); diff --git a/pkg/sass-parser/lib/src/statement/css-comment.test.ts b/pkg/sass-parser/lib/src/statement/css-comment.test.ts index c8fbaff6d..ae1e5bc65 100644 --- a/pkg/sass-parser/lib/src/statement/css-comment.test.ts +++ b/pkg/sass-parser/lib/src/statement/css-comment.test.ts @@ -24,17 +24,17 @@ describe('a CSS-style comment', () => { describeNode( 'parsed as SCSS', - () => scss.parse('/* foo */').nodes[0] as CssComment, + () => scss.parse('/* foo */').nodes[0] as CssComment ); describeNode( 'parsed as CSS', - () => css.parse('/* foo */').nodes[0] as CssComment, + () => css.parse('/* foo */').nodes[0] as CssComment ); describeNode( 'parsed as Sass', - () => sass.parse('/* foo').nodes[0] as CssComment, + () => sass.parse('/* foo').nodes[0] as CssComment ); describe('constructed manually', () => { @@ -43,7 +43,7 @@ describe('a CSS-style comment', () => { () => new CssComment({ textInterpolation: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode('with a text string', () => new CssComment({text: 'foo'})); @@ -53,11 +53,11 @@ describe('a CSS-style comment', () => { describeNode('with an interpolation', () => utils.fromChildProps({ textInterpolation: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode('with a text string', () => - utils.fromChildProps({text: 'foo'}), + utils.fromChildProps({text: 'foo'}) ); }); @@ -72,7 +72,7 @@ describe('a CSS-style comment', () => { it('with whitespace before and after interpolation', () => expect( - (scss.parse('/* #{foo} */').nodes[0] as CssComment).raws, + (scss.parse('/* #{foo} */').nodes[0] as CssComment).raws ).toEqual({left: ' ', right: ' ', closed: true})); it('without whitespace before and after text', () => @@ -162,7 +162,7 @@ describe('a CSS-style comment', () => { new CssComment({ text: 'foo', raws: {left: '\n'}, - }).toString(), + }).toString() ).toBe('/*\nfoo */')); it('with right', () => @@ -170,14 +170,14 @@ describe('a CSS-style comment', () => { new CssComment({ text: 'foo', raws: {right: '\n'}, - }).toString(), + }).toString() ).toBe('/* foo\n*/')); it('with before', () => expect( new Root({ nodes: [new CssComment({text: 'foo', raws: {before: '/**/'}})], - }).toString(), + }).toString() ).toBe('/**//* foo */')); }); }); @@ -219,7 +219,7 @@ describe('a CSS-style comment', () => { describe('clone', () => { let original: CssComment; beforeEach( - () => void (original = scss.parse('/* foo */').nodes[0] as CssComment), + () => void (original = scss.parse('/* foo */').nodes[0] as CssComment) ); describe('with no overrides', () => { diff --git a/pkg/sass-parser/lib/src/statement/css-comment.ts b/pkg/sass-parser/lib/src/statement/css-comment.ts index 432520ddb..f2565caa0 100644 --- a/pkg/sass-parser/lib/src/statement/css-comment.ts +++ b/pkg/sass-parser/lib/src/statement/css-comment.ts @@ -125,7 +125,7 @@ export class CssComment this.textInterpolation = new Interpolation(); for (const child of nodes) { this.textInterpolation.append( - typeof child === 'string' ? child : convertExpression(child), + typeof child === 'string' ? child : convertExpression(child) ); } } @@ -136,7 +136,7 @@ export class CssComment this, overrides, ['raws', 'textInterpolation'], - ['text'], + ['text'] ); } @@ -150,7 +150,7 @@ export class CssComment /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/debug-rule.test.ts b/pkg/sass-parser/lib/src/statement/debug-rule.test.ts index a06b459aa..2ac421dbc 100644 --- a/pkg/sass-parser/lib/src/statement/debug-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/debug-rule.test.ts @@ -24,12 +24,12 @@ describe('a @debug rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@debug foo').nodes[0] as DebugRule, + () => scss.parse('@debug foo').nodes[0] as DebugRule ); describeNode( 'parsed as Sass', - () => sass.parse('@debug foo').nodes[0] as DebugRule, + () => sass.parse('@debug foo').nodes[0] as DebugRule ); describeNode( @@ -37,13 +37,13 @@ describe('a @debug rule', () => { () => new DebugRule({ debugExpression: {text: 'foo'}, - }), + }) ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ debugExpression: {text: 'foo'}, - }), + }) ); it('throws an error when assigned a new name', () => @@ -51,7 +51,7 @@ describe('a @debug rule', () => { () => (new DebugRule({ debugExpression: {text: 'foo'}, - }).name = 'bar'), + }).name = 'bar') ).toThrow()); describe('assigned a new expression', () => { @@ -106,7 +106,7 @@ describe('a @debug rule', () => { expect( new DebugRule({ debugExpression: {text: 'foo'}, - }).toString(), + }).toString() ).toBe('@debug foo;')); it('with afterName', () => @@ -114,7 +114,7 @@ describe('a @debug rule', () => { new DebugRule({ debugExpression: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@debug/**/foo;')); it('with between', () => @@ -122,7 +122,7 @@ describe('a @debug rule', () => { new DebugRule({ debugExpression: {text: 'foo'}, raws: {between: '/**/'}, - }).toString(), + }).toString() ).toBe('@debug foo/**/;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/debug-rule.ts b/pkg/sass-parser/lib/src/statement/debug-rule.ts index aa4154b63..d0030d81d 100644 --- a/pkg/sass-parser/lib/src/statement/debug-rule.ts +++ b/pkg/sass-parser/lib/src/statement/debug-rule.ts @@ -97,7 +97,7 @@ export class DebugRule this, overrides, ['raws', 'debugExpression'], - [{name: 'params', explicitUndefined: true}], + [{name: 'params', explicitUndefined: true}] ); } @@ -108,14 +108,14 @@ export class DebugRule return utils.toJSON( this, ['name', 'debugExpression', 'params', 'nodes'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts b/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts index 03f4e3ec8..c10d2fa6e 100644 --- a/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts @@ -27,10 +27,10 @@ export class _Declaration extends postcss.Declaration { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -40,37 +40,37 @@ export class _Declaration extends postcss.Declaration { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/each-rule.test.ts b/pkg/sass-parser/lib/src/statement/each-rule.test.ts index 433fa10fd..d70d53992 100644 --- a/pkg/sass-parser/lib/src/statement/each-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/each-rule.test.ts @@ -29,12 +29,12 @@ describe('an @each rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@each $foo, $bar in baz {}').nodes[0] as EachRule, + () => scss.parse('@each $foo, $bar in baz {}').nodes[0] as EachRule ); describeNode( 'parsed as Sass', - () => sass.parse('@each $foo, $bar in baz').nodes[0] as EachRule, + () => sass.parse('@each $foo, $bar in baz').nodes[0] as EachRule ); describeNode( @@ -43,14 +43,14 @@ describe('an @each rule', () => { new EachRule({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - }), + }) ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - }), + }) ); }); @@ -80,13 +80,12 @@ describe('an @each rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@each $foo, $bar in baz {@child}').nodes[0] as EachRule, + () => scss.parse('@each $foo, $bar in baz {@child}').nodes[0] as EachRule ); describeNode( 'parsed as Sass', - () => - sass.parse('@each $foo, $bar in baz\n @child').nodes[0] as EachRule, + () => sass.parse('@each $foo, $bar in baz\n @child').nodes[0] as EachRule ); describeNode( @@ -96,7 +95,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }), + }) ); describeNode('constructed from ChildProps', () => @@ -104,7 +103,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }), + }) ); }); @@ -114,7 +113,7 @@ describe('an @each rule', () => { void (node = new EachRule({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - })), + })) ); it('name', () => expect(() => (node.name = 'qux')).toThrow()); @@ -159,7 +158,7 @@ describe('an @each rule', () => { new EachRule({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - }).toString(), + }).toString() ).toBe('@each $foo, $bar in baz {}')); it('with afterName', () => @@ -168,7 +167,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@each/**/$foo, $bar in baz {}')); it('with afterVariables', () => @@ -177,7 +176,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, raws: {afterVariables: ['/**/,', '/* */']}, - }).toString(), + }).toString() ).toBe('@each $foo/**/,$bar/* */in baz {}')); it('with afterIn', () => @@ -186,7 +185,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, raws: {afterIn: '/**/'}, - }).toString(), + }).toString() ).toBe('@each $foo, $bar in/**/baz {}')); }); }); @@ -298,6 +297,6 @@ describe('an @each rule', () => { it('toJSON', () => expect( - scss.parse('@each $foo, $bar in baz {}').nodes[0], + scss.parse('@each $foo, $bar in baz {}').nodes[0] ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/statement/each-rule.ts b/pkg/sass-parser/lib/src/statement/each-rule.ts index ea2c812d6..e0339f961 100644 --- a/pkg/sass-parser/lib/src/statement/each-rule.ts +++ b/pkg/sass-parser/lib/src/statement/each-rule.ts @@ -139,14 +139,14 @@ export class EachRule return utils.toJSON( this, ['name', 'variables', 'eachExpression', 'params', 'nodes'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/error-rule.test.ts b/pkg/sass-parser/lib/src/statement/error-rule.test.ts index 57b33aac5..0524338bf 100644 --- a/pkg/sass-parser/lib/src/statement/error-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/error-rule.test.ts @@ -24,12 +24,12 @@ describe('a @error rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@error foo').nodes[0] as ErrorRule, + () => scss.parse('@error foo').nodes[0] as ErrorRule ); describeNode( 'parsed as Sass', - () => sass.parse('@error foo').nodes[0] as ErrorRule, + () => sass.parse('@error foo').nodes[0] as ErrorRule ); describeNode( @@ -37,13 +37,13 @@ describe('a @error rule', () => { () => new ErrorRule({ errorExpression: {text: 'foo'}, - }), + }) ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ errorExpression: {text: 'foo'}, - }), + }) ); it('throws an error when assigned a new name', () => @@ -51,7 +51,7 @@ describe('a @error rule', () => { () => (new ErrorRule({ errorExpression: {text: 'foo'}, - }).name = 'bar'), + }).name = 'bar') ).toThrow()); describe('assigned a new expression', () => { @@ -106,7 +106,7 @@ describe('a @error rule', () => { expect( new ErrorRule({ errorExpression: {text: 'foo'}, - }).toString(), + }).toString() ).toBe('@error foo;')); it('with afterName', () => @@ -114,7 +114,7 @@ describe('a @error rule', () => { new ErrorRule({ errorExpression: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@error/**/foo;')); it('with between', () => @@ -122,7 +122,7 @@ describe('a @error rule', () => { new ErrorRule({ errorExpression: {text: 'foo'}, raws: {between: '/**/'}, - }).toString(), + }).toString() ).toBe('@error foo/**/;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/error-rule.ts b/pkg/sass-parser/lib/src/statement/error-rule.ts index 3d7b369c0..7b55f4253 100644 --- a/pkg/sass-parser/lib/src/statement/error-rule.ts +++ b/pkg/sass-parser/lib/src/statement/error-rule.ts @@ -97,7 +97,7 @@ export class ErrorRule this, overrides, ['raws', 'errorExpression'], - [{name: 'params', explicitUndefined: true}], + [{name: 'params', explicitUndefined: true}] ); } @@ -108,14 +108,14 @@ export class ErrorRule return utils.toJSON( this, ['name', 'errorExpression', 'params', 'nodes'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/extend-rule.test.ts b/pkg/sass-parser/lib/src/statement/extend-rule.test.ts index 45210c90c..15485b604 100644 --- a/pkg/sass-parser/lib/src/statement/extend-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/extend-rule.test.ts @@ -11,7 +11,7 @@ describe('an @extend rule', () => { beforeEach( () => void (node = (scss.parse('.foo {@extend .bar}').nodes[0] as Rule) - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('extend')); @@ -26,7 +26,7 @@ describe('an @extend rule', () => { beforeEach( () => void (node = (scss.parse('.foo {@extend .#{bar}}').nodes[0] as Rule) - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('extend')); @@ -45,7 +45,7 @@ describe('an @extend rule', () => { () => void (node = ( scss.parse('.foo {@extend .bar !optional}').nodes[0] as Rule - ).nodes[0] as GenericAtRule), + ).nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('extend')); @@ -53,7 +53,7 @@ describe('an @extend rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '.bar !optional', + '.bar !optional' )); it('has matching params', () => expect(node.params).toBe('.bar !optional')); diff --git a/pkg/sass-parser/lib/src/statement/for-rule.test.ts b/pkg/sass-parser/lib/src/statement/for-rule.test.ts index 66becdcb4..607dd4217 100644 --- a/pkg/sass-parser/lib/src/statement/for-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/for-rule.test.ts @@ -33,12 +33,12 @@ describe('an @for rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@for $foo from bar through baz {}').nodes[0] as ForRule, + () => scss.parse('@for $foo from bar through baz {}').nodes[0] as ForRule ); describeNode( 'parsed as Sass', - () => sass.parse('@for $foo from bar through baz').nodes[0] as ForRule, + () => sass.parse('@for $foo from bar through baz').nodes[0] as ForRule ); describeNode( @@ -49,7 +49,7 @@ describe('an @for rule', () => { to: 'through', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - }), + }) ); describeNode('constructed from ChildProps', () => @@ -58,7 +58,7 @@ describe('an @for rule', () => { to: 'through', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - }), + }) ); }); @@ -94,14 +94,14 @@ describe('an @for rule', () => { 'parsed as SCSS', () => scss.parse('@for $foo from bar through baz {@child}') - .nodes[0] as ForRule, + .nodes[0] as ForRule ); describeNode( 'parsed as Sass', () => sass.parse('@for $foo from bar through baz\n @child') - .nodes[0] as ForRule, + .nodes[0] as ForRule ); describeNode( @@ -113,7 +113,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }), + }) ); describeNode('constructed from ChildProps', () => @@ -123,7 +123,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }), + }) ); }); @@ -134,7 +134,7 @@ describe('an @for rule', () => { variable: 'foo', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - })), + })) ); it('name', () => expect(() => (node.name = 'qux')).toThrow()); @@ -209,7 +209,7 @@ describe('an @for rule', () => { variable: 'foo', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - }).toString(), + }).toString() ).toBe('@for $foo from bar to baz {}')); it('with afterName', () => @@ -219,7 +219,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@for/**/$foo from bar to baz {}')); it('with afterVariable', () => @@ -229,7 +229,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterVariable: '/**/'}, - }).toString(), + }).toString() ).toBe('@for $foo/**/from bar to baz {}')); it('with afterFrom', () => @@ -239,7 +239,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterFrom: '/**/'}, - }).toString(), + }).toString() ).toBe('@for $foo from/**/bar to baz {}')); it('with afterFromExpression', () => @@ -249,7 +249,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterFromExpression: '/**/'}, - }).toString(), + }).toString() ).toBe('@for $foo from bar/**/to baz {}')); it('with afterTo', () => @@ -259,7 +259,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterTo: '/**/'}, - }).toString(), + }).toString() ).toBe('@for $foo from bar to/**/baz {}')); }); }); @@ -432,6 +432,6 @@ describe('an @for rule', () => { it('toJSON', () => expect( - scss.parse('@for $foo from bar to baz {}').nodes[0], + scss.parse('@for $foo from bar to baz {}').nodes[0] ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/statement/for-rule.ts b/pkg/sass-parser/lib/src/statement/for-rule.ts index 8147f83b0..d67fe91f6 100644 --- a/pkg/sass-parser/lib/src/statement/for-rule.ts +++ b/pkg/sass-parser/lib/src/statement/for-rule.ts @@ -174,14 +174,14 @@ export class ForRule 'params', 'nodes', ], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts b/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts index e75d06519..c40dfab62 100644 --- a/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts @@ -11,7 +11,7 @@ describe('a generic @-rule', () => { describe('with no params', () => { function describeNode( description: string, - create: () => GenericAtRule, + create: () => GenericAtRule ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -36,17 +36,17 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo').nodes[0] as GenericAtRule, + () => scss.parse('@foo').nodes[0] as GenericAtRule ); describeNode( 'parsed as CSS', - () => css.parse('@foo').nodes[0] as GenericAtRule, + () => css.parse('@foo').nodes[0] as GenericAtRule ); describeNode( 'parsed as Sass', - () => sass.parse('@foo').nodes[0] as GenericAtRule, + () => sass.parse('@foo').nodes[0] as GenericAtRule ); describe('constructed manually', () => { @@ -55,12 +55,12 @@ describe('a generic @-rule', () => { () => new GenericAtRule({ nameInterpolation: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode( 'with a name string', - () => new GenericAtRule({name: 'foo'}), + () => new GenericAtRule({name: 'foo'}) ); }); @@ -68,11 +68,11 @@ describe('a generic @-rule', () => { describeNode('with a name interpolation', () => utils.fromChildProps({ nameInterpolation: new Interpolation({nodes: ['foo']}), - }), + }) ); describeNode('with a name string', () => - utils.fromChildProps({name: 'foo'}), + utils.fromChildProps({name: 'foo'}) ); }); }); @@ -80,7 +80,7 @@ describe('a generic @-rule', () => { describe('with params', () => { function describeNode( description: string, - create: () => GenericAtRule, + create: () => GenericAtRule ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -98,17 +98,17 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo bar').nodes[0] as GenericAtRule, + () => scss.parse('@foo bar').nodes[0] as GenericAtRule ); describeNode( 'parsed as CSS', - () => css.parse('@foo bar').nodes[0] as GenericAtRule, + () => css.parse('@foo bar').nodes[0] as GenericAtRule ); describeNode( 'parsed as Sass', - () => sass.parse('@foo bar').nodes[0] as GenericAtRule, + () => sass.parse('@foo bar').nodes[0] as GenericAtRule ); describe('constructed manually', () => { @@ -118,12 +118,12 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar']}), - }), + }) ); describeNode( 'with a param string', - () => new GenericAtRule({name: 'foo', params: 'bar'}), + () => new GenericAtRule({name: 'foo', params: 'bar'}) ); }); @@ -132,11 +132,11 @@ describe('a generic @-rule', () => { utils.fromChildProps({ name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar']}), - }), + }) ); describeNode('with a param string', () => - utils.fromChildProps({name: 'foo', params: 'bar'}), + utils.fromChildProps({name: 'foo', params: 'bar'}) ); }); }); @@ -146,7 +146,7 @@ describe('a generic @-rule', () => { describe('with no params', () => { function describeNode( description: string, - create: () => GenericAtRule, + create: () => GenericAtRule ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -164,28 +164,28 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo {}').nodes[0] as GenericAtRule, + () => scss.parse('@foo {}').nodes[0] as GenericAtRule ); describeNode( 'parsed as CSS', - () => css.parse('@foo {}').nodes[0] as GenericAtRule, + () => css.parse('@foo {}').nodes[0] as GenericAtRule ); describeNode( 'constructed manually', - () => new GenericAtRule({name: 'foo', nodes: []}), + () => new GenericAtRule({name: 'foo', nodes: []}) ); describeNode('constructed from ChildProps', () => - utils.fromChildProps({name: 'foo', nodes: []}), + utils.fromChildProps({name: 'foo', nodes: []}) ); }); describe('with params', () => { function describeNode( description: string, - create: () => GenericAtRule, + create: () => GenericAtRule ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -201,12 +201,12 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo bar {}').nodes[0] as GenericAtRule, + () => scss.parse('@foo bar {}').nodes[0] as GenericAtRule ); describeNode( 'parsed as CSS', - () => css.parse('@foo bar {}').nodes[0] as GenericAtRule, + () => css.parse('@foo bar {}').nodes[0] as GenericAtRule ); describe('constructed manually', () => { @@ -217,7 +217,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar ', nodes: [], - }), + }) ); describeNode( @@ -227,7 +227,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar ']}), nodes: [], - }), + }) ); }); @@ -237,7 +237,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar ', nodes: [], - }), + }) ); describeNode('with an interpolation', () => @@ -245,7 +245,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar ']}), nodes: [], - }), + }) ); }); }); @@ -276,7 +276,7 @@ describe('a generic @-rule', () => { describe('with params', () => { function describeNode( description: string, - create: () => GenericAtRule, + create: () => GenericAtRule ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -298,7 +298,7 @@ describe('a generic @-rule', () => { describeNode( 'parsed as Sass', - () => sass.parse('@foo bar\n .baz').nodes[0] as GenericAtRule, + () => sass.parse('@foo bar\n .baz').nodes[0] as GenericAtRule ); describe('constructed manually', () => { @@ -309,7 +309,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar', nodes: [{selector: '.baz\n'}], - }), + }) ); }); @@ -319,7 +319,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar', nodes: [{selector: '.baz\n'}], - }), + }) ); }); }); @@ -422,7 +422,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo/**/;')); it('with afterName', () => @@ -430,7 +430,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo/**/;')); it('with between', () => @@ -438,7 +438,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {between: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo/**/;')); it('with afterName and between', () => @@ -446,7 +446,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {afterName: '/*afterName*/', between: '/*between*/'}, - }).toString(), + }).toString() ).toBe('@foo/*afterName*//*between*/;')); }); @@ -456,7 +456,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', paramsInterpolation: 'baz', - }).toString(), + }).toString() ).toBe('@foo baz;')); it('with afterName', () => @@ -465,7 +465,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: 'baz', raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo/**/baz;')); it('with between', () => @@ -474,20 +474,20 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: 'baz', raws: {between: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo baz/**/;')); }); it('with after', () => expect( - new GenericAtRule({name: 'foo', raws: {after: '/**/'}}).toString(), + new GenericAtRule({name: 'foo', raws: {after: '/**/'}}).toString() ).toBe('@foo;')); it('with before', () => expect( new Root({ nodes: [new GenericAtRule({name: 'foo', raws: {before: '/**/'}})], - }).toString(), + }).toString() ).toBe('/**/@foo')); }); @@ -495,7 +495,7 @@ describe('a generic @-rule', () => { describe('without params', () => { it('with default raws', () => expect(new GenericAtRule({name: 'foo', nodes: []}).toString()).toBe( - '@foo {}', + '@foo {}' )); it('with afterName', () => @@ -504,7 +504,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {afterName: '/**/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo/**/ {}')); it('with afterName', () => @@ -513,7 +513,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {afterName: '/**/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo/**/ {}')); it('with between', () => @@ -522,7 +522,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {between: '/**/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo/**/{}')); it('with afterName and between', () => @@ -531,7 +531,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {afterName: '/*afterName*/', between: '/*between*/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo/*afterName*//*between*/{}')); }); @@ -542,7 +542,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: 'baz', nodes: [], - }).toString(), + }).toString() ).toBe('@foo baz {}')); it('with afterName', () => @@ -552,7 +552,7 @@ describe('a generic @-rule', () => { paramsInterpolation: 'baz', raws: {afterName: '/**/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo/**/baz {}')); it('with between', () => @@ -562,7 +562,7 @@ describe('a generic @-rule', () => { paramsInterpolation: 'baz', raws: {between: '/**/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo baz/**/{}')); }); @@ -573,7 +573,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {after: '/**/'}, nodes: [], - }).toString(), + }).toString() ).toBe('@foo {/**/}')); it('with a child', () => @@ -582,7 +582,7 @@ describe('a generic @-rule', () => { name: 'foo', nodes: [{selector: '.bar'}], raws: {after: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo {\n .bar {}/**/}')); }); @@ -596,7 +596,7 @@ describe('a generic @-rule', () => { nodes: [], }), ], - }).toString(), + }).toString() ).toBe('/**/@foo {}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/generic-at-rule.ts b/pkg/sass-parser/lib/src/statement/generic-at-rule.ts index 0ccb6e586..97ae32e05 100644 --- a/pkg/sass-parser/lib/src/statement/generic-at-rule.ts +++ b/pkg/sass-parser/lib/src/statement/generic-at-rule.ts @@ -136,7 +136,7 @@ export class GenericAtRule return this._paramsInterpolation; } set paramsInterpolation( - paramsInterpolation: Interpolation | string | undefined, + paramsInterpolation: Interpolation | string | undefined ) { if (this._paramsInterpolation) this._paramsInterpolation.parent = undefined; if (typeof paramsInterpolation === 'string') { @@ -173,7 +173,7 @@ export class GenericAtRule 'nameInterpolation', {name: 'paramsInterpolation', explicitUndefined: true}, ], - ['name', {name: 'params', explicitUndefined: true}], + ['name', {name: 'params', explicitUndefined: true}] ); } @@ -184,14 +184,14 @@ export class GenericAtRule return utils.toJSON( this, ['name', 'nameInterpolation', 'params', 'paramsInterpolation', 'nodes'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/index.ts b/pkg/sass-parser/lib/src/statement/index.ts index 3be667fd3..2635cc470 100644 --- a/pkg/sass-parser/lib/src/statement/index.ts +++ b/pkg/sass-parser/lib/src/statement/index.ts @@ -191,7 +191,7 @@ const visitor = sassInternal.createStatementVisitor({ name: 'supports', paramsInterpolation: new Interpolation( undefined, - inner.condition.toInterpolation(), + inner.condition.toInterpolation() ), source: new LazySource(inner), }); @@ -207,7 +207,7 @@ const visitor = sassInternal.createStatementVisitor({ /** Appends parsed versions of `internal`'s children to `container`. */ export function appendInternalChildren( container: postcss.Container, - children: sassInternal.Statement[] | null, + children: sassInternal.Statement[] | null ): void { // Make sure `container` knows it has a block. if (children?.length === 0) container.append(undefined); @@ -233,7 +233,7 @@ export type NewNode = const postcssNormalize = postcss.Container.prototype['normalize'] as ( nodes: postcss.NewChild, sample: postcss.Node | undefined, - type?: 'prepend' | false, + type?: 'prepend' | false ) => postcss.ChildNode[]; /** @@ -243,7 +243,7 @@ const postcssNormalize = postcss.Container.prototype['normalize'] as ( function postcssNormalizeAndConvertToSass( self: StatementWithChildren, node: string | postcss.ChildProps | postcss.Node, - sample: postcss.Node | undefined, + sample: postcss.Node | undefined ): ChildNode[] { return postcssNormalize.call(self, node, sample).map(postcssNode => { // postcssNormalize sets the parent to the Sass node, but we don't want to @@ -278,7 +278,7 @@ function postcssNormalizeAndConvertToSass( export function normalize( self: StatementWithChildren, node: NewNode, - sample?: postcss.Node, + sample?: postcss.Node ): ChildNode[] { if (node === undefined) return []; const nodes = Array.isArray(node) ? node : [node]; diff --git a/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts b/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts index 57ebfa87c..37e7fc35a 100644 --- a/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts +++ b/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts @@ -13,7 +13,7 @@ import type {Statement} from '.'; * clean as well. */ export function interceptIsClean( - klass: utils.Constructor, + klass: utils.Constructor ): void { Object.defineProperty(klass as typeof klass & {_isClean: boolean}, isClean, { get(): boolean { diff --git a/pkg/sass-parser/lib/src/statement/media-rule.test.ts b/pkg/sass-parser/lib/src/statement/media-rule.test.ts index 8b48530f3..7a2f8d9ac 100644 --- a/pkg/sass-parser/lib/src/statement/media-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/media-rule.test.ts @@ -10,7 +10,7 @@ describe('a @media rule', () => { describe('with no interpolation', () => { beforeEach( () => - void (node = scss.parse('@media screen {}').nodes[0] as GenericAtRule), + void (node = scss.parse('@media screen {}').nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('media')); @@ -27,7 +27,7 @@ describe('a @media rule', () => { beforeEach( () => void (node = scss.parse('@media (hover: #{hover}) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('media')); @@ -40,7 +40,7 @@ describe('a @media rule', () => { expect(params.nodes[3]).toBeInstanceOf(StringExpression); expect((params.nodes[3] as StringExpression).text).toHaveStringExpression( 0, - 'hover', + 'hover' ); expect(params.nodes[4]).toBe(')'); }); @@ -55,7 +55,7 @@ describe('a @media rule', () => { it('to SCSS', () => expect( (node = scss.parse('@media #{screen} and (hover: #{hover}) {@foo}') - .nodes[0] as GenericAtRule).toString(), + .nodes[0] as GenericAtRule).toString() ).toBe('@media #{screen} and (hover: #{hover}) {\n @foo\n}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/root-internal.d.ts b/pkg/sass-parser/lib/src/statement/root-internal.d.ts index 7306eeeb2..975b19ed7 100644 --- a/pkg/sass-parser/lib/src/statement/root-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/root-internal.d.ts @@ -29,10 +29,10 @@ export class _Root extends postcss.Root { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -42,37 +42,37 @@ export class _Root extends postcss.Root { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/root.test.ts b/pkg/sass-parser/lib/src/statement/root.test.ts index a236dc874..2d8d19687 100644 --- a/pkg/sass-parser/lib/src/statement/root.test.ts +++ b/pkg/sass-parser/lib/src/statement/root.test.ts @@ -48,7 +48,7 @@ describe('a root node', () => { describeNode( 'constructed manually', - () => new Root({nodes: [{name: 'foo'}]}), + () => new Root({nodes: [{name: 'foo'}]}) ); }); @@ -70,7 +70,7 @@ describe('a root node', () => { new Root({ nodes: [{name: 'foo'}], raws: {after: '/**/'}, - }).toString(), + }).toString() ).toBe('@foo/**/')); }); @@ -83,7 +83,7 @@ describe('a root node', () => { new Root({ nodes: [{name: 'foo'}], raws: {semicolon: true}, - }).toString(), + }).toString() ).toBe('@foo;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/root.ts b/pkg/sass-parser/lib/src/statement/root.ts index 7f2dd4b80..f3b2471a7 100644 --- a/pkg/sass-parser/lib/src/statement/root.ts +++ b/pkg/sass-parser/lib/src/statement/root.ts @@ -69,7 +69,7 @@ export class Root extends _Root implements Statement { toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/rule-internal.d.ts b/pkg/sass-parser/lib/src/statement/rule-internal.d.ts index 89f4e1a00..31bef89ac 100644 --- a/pkg/sass-parser/lib/src/statement/rule-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/rule-internal.d.ts @@ -29,10 +29,10 @@ export class _Rule extends postcss.Rule { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -42,37 +42,37 @@ export class _Rule extends postcss.Rule { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void, + callback: (node: ChildNode, index: number) => false | void ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void, + callback: (atRule: AtRule, index: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void, + callback: (comment: Comment, indexed: number) => false | void ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void, + callback: (decl: Declaration, index: number) => false | void ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void, + callback: (rule: Rule, index: number) => false | void ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/rule.test.ts b/pkg/sass-parser/lib/src/statement/rule.test.ts index 708de8170..1146867cb 100644 --- a/pkg/sass-parser/lib/src/statement/rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/rule.test.ts @@ -27,7 +27,7 @@ describe('a style rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('.foo {}').nodes[0] as Rule, + () => scss.parse('.foo {}').nodes[0] as Rule ); describeNode('parsed as CSS', () => css.parse('.foo {}').nodes[0] as Rule); @@ -51,12 +51,12 @@ describe('a style rule', () => { () => new Rule({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), - }), + }) ); describeNode( 'with a selector string', - () => new Rule({selector: '.foo '}), + () => new Rule({selector: '.foo '}) ); }); @@ -64,11 +64,11 @@ describe('a style rule', () => { describeNode('with an interpolation', () => utils.fromChildProps({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), - }), + }) ); describeNode('with a selector string', () => - utils.fromChildProps({selector: '.foo '}), + utils.fromChildProps({selector: '.foo '}) ); }); }); @@ -93,12 +93,12 @@ describe('a style rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('.foo {@bar}').nodes[0] as Rule, + () => scss.parse('.foo {@bar}').nodes[0] as Rule ); describeNode( 'parsed as CSS', - () => css.parse('.foo {@bar}').nodes[0] as Rule, + () => css.parse('.foo {@bar}').nodes[0] as Rule ); describe('parsed as Sass', () => { @@ -125,12 +125,12 @@ describe('a style rule', () => { new Rule({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), nodes: [{name: 'bar'}], - }), + }) ); describeNode( 'with a selector string', - () => new Rule({selector: '.foo ', nodes: [{name: 'bar'}]}), + () => new Rule({selector: '.foo ', nodes: [{name: 'bar'}]}) ); }); @@ -139,11 +139,11 @@ describe('a style rule', () => { utils.fromChildProps({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), nodes: [{name: 'bar'}], - }), + }) ); describeNode('with a selector string', () => - utils.fromChildProps({selector: '.foo ', nodes: [{name: 'bar'}]}), + utils.fromChildProps({selector: '.foo ', nodes: [{name: 'bar'}]}) ); }); }); @@ -193,7 +193,7 @@ describe('a style rule', () => { new Rule({ selector: '.foo', nodes: [{selector: '.bar'}], - }).toString(), + }).toString() ).toBe('.foo {\n .bar {}\n}')); }); @@ -202,13 +202,13 @@ describe('a style rule', () => { new Rule({ selector: '.foo', raws: {between: '/**/'}, - }).toString(), + }).toString() ).toBe('.foo/**/{}')); describe('with after', () => { it('with no children', () => expect( - new Rule({selector: '.foo', raws: {after: '/**/'}}).toString(), + new Rule({selector: '.foo', raws: {after: '/**/'}}).toString() ).toBe('.foo {/**/}')); it('with a child', () => @@ -217,7 +217,7 @@ describe('a style rule', () => { selector: '.foo', nodes: [{selector: '.bar'}], raws: {after: '/**/'}, - }).toString(), + }).toString() ).toBe('.foo {\n .bar {}/**/}')); }); @@ -225,7 +225,7 @@ describe('a style rule', () => { expect( new Root({ nodes: [new Rule({selector: '.foo', raws: {before: '/**/'}})], - }).toString(), + }).toString() ).toBe('/**/.foo {}')); }); }); @@ -303,7 +303,7 @@ describe('a style rule', () => { it('preserves selectorInterpolation', () => expect(clone).toHaveInterpolation( 'selectorInterpolation', - '.foo ', + '.foo ' )); }); }); @@ -334,7 +334,7 @@ describe('a style rule', () => { it('preserves selectorInterpolation', () => expect(clone).toHaveInterpolation( 'selectorInterpolation', - '.foo ', + '.foo ' )); }); }); diff --git a/pkg/sass-parser/lib/src/statement/rule.ts b/pkg/sass-parser/lib/src/statement/rule.ts index b53605a09..087a99ba1 100644 --- a/pkg/sass-parser/lib/src/statement/rule.ts +++ b/pkg/sass-parser/lib/src/statement/rule.ts @@ -104,7 +104,7 @@ export class Rule extends _Rule implements Statement { this, overrides, ['nodes', 'raws', 'selectorInterpolation'], - ['selector', 'selectors'], + ['selector', 'selectors'] ); } @@ -115,14 +115,14 @@ export class Rule extends _Rule implements Statement { return utils.toJSON( this, ['selector', 'selectorInterpolation', 'nodes'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/sass-comment.test.ts b/pkg/sass-parser/lib/src/statement/sass-comment.test.ts index 3f2655eee..cbd88598b 100644 --- a/pkg/sass-parser/lib/src/statement/sass-comment.test.ts +++ b/pkg/sass-parser/lib/src/statement/sass-comment.test.ts @@ -24,21 +24,21 @@ describe('a Sass-style comment', () => { describeNode( 'parsed as SCSS', - () => scss.parse('// foo\n// bar').nodes[0] as SassComment, + () => scss.parse('// foo\n// bar').nodes[0] as SassComment ); describeNode( 'parsed as Sass', - () => sass.parse('// foo\n// bar').nodes[0] as SassComment, + () => sass.parse('// foo\n// bar').nodes[0] as SassComment ); describeNode( 'constructed manually', - () => new SassComment({text: 'foo\nbar'}), + () => new SassComment({text: 'foo\nbar'}) ); describeNode('constructed from ChildProps', () => - utils.fromChildProps({silentText: 'foo\nbar'}), + utils.fromChildProps({silentText: 'foo\nbar'}) ); describe('parses raws', () => { @@ -217,7 +217,7 @@ describe('a Sass-style comment', () => { describe('to SCSS', () => { it('with default raws', () => expect(new SassComment({text: 'foo\nbar'}).toString()).toBe( - '// foo\n// bar', + '// foo\n// bar' )); it('with left', () => @@ -225,7 +225,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\nbar', raws: {left: '\t'}, - }).toString(), + }).toString() ).toBe('//\tfoo\n//\tbar')); it('with left and an empty line', () => @@ -233,7 +233,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\n\nbar', raws: {left: '\t'}, - }).toString(), + }).toString() ).toBe('//\tfoo\n//\n//\tbar')); it('with left and a whitespace-only line', () => @@ -241,7 +241,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\n \nbar', raws: {left: '\t'}, - }).toString(), + }).toString() ).toBe('//\tfoo\n// \n//\tbar')); it('with before', () => @@ -249,7 +249,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\nbar', raws: {before: '\t'}, - }).toString(), + }).toString() ).toBe('\t// foo\n\t// bar')); it('with beforeLines', () => @@ -261,7 +261,7 @@ describe('a Sass-style comment', () => { raws: {beforeLines: [' ', '\t']}, }), ], - }).toString(), + }).toString() ).toBe(' // foo\n\t// bar')); describe('with a following sibling', () => { @@ -269,7 +269,7 @@ describe('a Sass-style comment', () => { expect( new Root({ nodes: [{silentText: 'foo\nbar'}, {name: 'baz'}], - }).toString(), + }).toString() ).toBe('// foo\n// bar\n@baz')); it('with before with newline', () => @@ -279,7 +279,7 @@ describe('a Sass-style comment', () => { {silentText: 'foo\nbar'}, {name: 'baz', raws: {before: '\n '}}, ], - }).toString(), + }).toString() ).toBe('// foo\n// bar\n @baz')); it('with before without newline', () => @@ -289,7 +289,7 @@ describe('a Sass-style comment', () => { {silentText: 'foo\nbar'}, {name: 'baz', raws: {before: ' '}}, ], - }).toString(), + }).toString() ).toBe('// foo\n// bar\n @baz')); }); @@ -299,7 +299,7 @@ describe('a Sass-style comment', () => { new Rule({ selector: '.zip', nodes: [{silentText: 'foo\nbar'}], - }).toString(), + }).toString() ).toBe('.zip {\n // foo\n// bar\n}')); it('with after with newline', () => @@ -308,7 +308,7 @@ describe('a Sass-style comment', () => { selector: '.zip', nodes: [{silentText: 'foo\nbar'}], raws: {after: '\n '}, - }).toString(), + }).toString() ).toBe('.zip {\n // foo\n// bar\n }')); it('with after without newline', () => @@ -317,7 +317,7 @@ describe('a Sass-style comment', () => { selector: '.zip', nodes: [{silentText: 'foo\nbar'}], raws: {after: ' '}, - }).toString(), + }).toString() ).toBe('.zip {\n // foo\n// bar\n }')); }); }); @@ -358,7 +358,7 @@ describe('a Sass-style comment', () => { describe('clone', () => { let original: SassComment; beforeEach( - () => void (original = scss.parse('// foo').nodes[0] as SassComment), + () => void (original = scss.parse('// foo').nodes[0] as SassComment) ); describe('with no overrides', () => { diff --git a/pkg/sass-parser/lib/src/statement/sass-comment.ts b/pkg/sass-parser/lib/src/statement/sass-comment.ts index 6aa9e4aa6..1c8bb66ec 100644 --- a/pkg/sass-parser/lib/src/statement/sass-comment.ts +++ b/pkg/sass-parser/lib/src/statement/sass-comment.ts @@ -136,17 +136,17 @@ export class SassComment } lineInfo[0].before = inner.span.file.getText( i + 1, - inner.span.start.offset, + inner.span.start.offset ); const before = (this.raws.before = utils.longestCommonInitialSubstring( - lineInfo.map(info => info.before), + lineInfo.map(info => info.before) )); this.raws.beforeLines = lineInfo.map(info => - info.before.substring(before.length), + info.before.substring(before.length) ); const left = (this.raws.left = utils.longestCommonInitialSubstring( - lineInfo.map(info => info.left).filter(left => left !== null), + lineInfo.map(info => info.left).filter(left => left !== null) )); this.text = lineInfo .map(info => (info.left?.substring(left.length) ?? '') + info.text) @@ -168,7 +168,7 @@ export class SassComment /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/supports-rule.test.ts b/pkg/sass-parser/lib/src/statement/supports-rule.test.ts index cde095733..1de844e5d 100644 --- a/pkg/sass-parser/lib/src/statement/supports-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/supports-rule.test.ts @@ -11,7 +11,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports ( foo $&#{bar} baz) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -35,7 +35,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports ( foo : bar, #abc, []) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -43,7 +43,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '( foo : bar, #abc, [])', + '( foo : bar, #abc, [])' )); it('has matching params', () => @@ -58,7 +58,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports ($foo: $bar) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -66,7 +66,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '(#{$foo}: #{$bar})', + '(#{$foo}: #{$bar})' )); it('has matching params', () => expect(node.params).toBe('($foo: $bar)')); @@ -79,7 +79,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports (#{"foo"}: #{"bar"}) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -87,7 +87,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '(#{"foo"}: #{"bar"})', + '(#{"foo"}: #{"bar"})' )); it('has matching params', () => @@ -102,7 +102,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports foo#{"bar"}(baz &*^ #{"bang"}) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -110,7 +110,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - 'foo#{"bar"}(baz &*^ #{"bang"})', + 'foo#{"bar"}(baz &*^ #{"bang"})' )); it('has matching params', () => @@ -118,7 +118,7 @@ describe('a @supports rule', () => { it('stringifies to SCSS', () => expect(node.toString()).toBe( - '@supports foo#{"bar"}(baz &*^ #{"bang"}) {}', + '@supports foo#{"bar"}(baz &*^ #{"bang"}) {}' )); }); @@ -126,7 +126,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports #{"bar"} {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -145,7 +145,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports not #{"bar"} {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -153,7 +153,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - 'not #{"bar"}', + 'not #{"bar"}' )); it('has matching params', () => expect(node.params).toBe('not #{"bar"}')); @@ -166,7 +166,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports not/**/#{"bar"} {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -174,7 +174,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - 'not/**/#{"bar"}', + 'not/**/#{"bar"}' )); it('has matching params', () => @@ -189,7 +189,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports (#{"foo"} or #{"bar"}) {}') - .nodes[0] as GenericAtRule), + .nodes[0] as GenericAtRule) ); it('has a name', () => expect(node.name).toBe('supports')); @@ -197,7 +197,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '(#{"foo"} or #{"bar"})', + '(#{"foo"} or #{"bar"})' )); it('has matching params', () => diff --git a/pkg/sass-parser/lib/src/statement/use-rule.test.ts b/pkg/sass-parser/lib/src/statement/use-rule.test.ts index cacbb4d40..27a76c5ee 100644 --- a/pkg/sass-parser/lib/src/statement/use-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/use-rule.test.ts @@ -36,12 +36,12 @@ describe('a @use rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@use "foo"').nodes[0] as UseRule, + () => scss.parse('@use "foo"').nodes[0] as UseRule ); describeNode( 'parsed as Sass', - () => sass.parse('@use "foo"').nodes[0] as UseRule, + () => sass.parse('@use "foo"').nodes[0] as UseRule ); describeNode( @@ -49,13 +49,13 @@ describe('a @use rule', () => { () => new UseRule({ useUrl: 'foo', - }), + }) ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ useUrl: 'foo', - }), + }) ); }); @@ -88,12 +88,12 @@ describe('a @use rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@use "foo" as *').nodes[0] as UseRule, + () => scss.parse('@use "foo" as *').nodes[0] as UseRule ); describeNode( 'parsed as Sass', - () => sass.parse('@use "foo" as *').nodes[0] as UseRule, + () => sass.parse('@use "foo" as *').nodes[0] as UseRule ); describeNode( @@ -102,14 +102,14 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: null, - }), + }) ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ useUrl: 'foo', namespace: null, - }), + }) ); }); @@ -147,13 +147,13 @@ describe('a @use rule', () => { describeNode( 'parsed as SCSS', () => - scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule, + scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule ); describeNode( 'parsed as Sass', () => - sass.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule, + sass.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule ); describeNode( @@ -165,7 +165,7 @@ describe('a @use rule', () => { configuration: { variables: {baz: {text: 'qux', quotes: true}}, }, - }), + }) ); describeNode('constructed from ChildProps', () => @@ -175,7 +175,7 @@ describe('a @use rule', () => { configuration: { variables: {baz: {text: 'qux', quotes: true}}, }, - }), + }) ); }); @@ -216,12 +216,12 @@ describe('a @use rule', () => { describe('is null for', () => { it('a URL without a pathname', () => expect( - new UseRule({useUrl: 'https://example.org'}).defaultNamespace, + new UseRule({useUrl: 'https://example.org'}).defaultNamespace ).toBeNull()); it('a URL with a slash pathname', () => expect( - new UseRule({useUrl: 'https://example.org/'}).defaultNamespace, + new UseRule({useUrl: 'https://example.org/'}).defaultNamespace ).toBeNull()); it('a basename that starts with .', () => @@ -239,7 +239,7 @@ describe('a @use rule', () => { it('the basename', () => expect(new UseRule({useUrl: 'foo/bar/baz'}).defaultNamespace).toBe( - 'baz', + 'baz' )); it('without an extension', () => @@ -247,18 +247,17 @@ describe('a @use rule', () => { it('the basename of an HTTP URL', () => expect( - new UseRule({useUrl: 'http://example.org/foo/bar/baz'}) - .defaultNamespace, + new UseRule({useUrl: 'http://example.org/foo/bar/baz'}).defaultNamespace ).toBe('baz')); it('the basename of a file: URL', () => expect( - new UseRule({useUrl: 'file:///foo/bar/baz'}).defaultNamespace, + new UseRule({useUrl: 'file:///foo/bar/baz'}).defaultNamespace ).toBe('baz')); it('the basename of an unknown scheme URL', () => expect(new UseRule({useUrl: 'foo:bar/bar/qux'}).defaultNamespace).toBe( - 'qux', + 'qux' )); it('a sass: URL', () => @@ -273,7 +272,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: 'bar', - }).toString(), + }).toString() ).toBe('@use "foo" as bar;')); it('with a non-identifier namespace', () => @@ -281,7 +280,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: ' ', - }).toString(), + }).toString() ).toBe('@use "foo" as \\20;')); it('with no namespace', () => @@ -289,7 +288,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: null, - }).toString(), + }).toString() ).toBe('@use "foo" as *;')); it('with configuration', () => @@ -299,7 +298,7 @@ describe('a @use rule', () => { configuration: { variables: {bar: {text: 'baz', quotes: true}}, }, - }).toString(), + }).toString() ).toBe('@use "foo" with ($bar: "baz");')); }); @@ -309,7 +308,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {url: {raw: "'foo'", value: 'foo'}}, - }).toString(), + }).toString() ).toBe("@use 'foo';")); it("that doesn't match", () => @@ -317,7 +316,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {url: {raw: "'bar'", value: 'bar'}}, - }).toString(), + }).toString() ).toBe('@use "foo";')); }); @@ -327,7 +326,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {namespace: {raw: ' as foo', value: 'foo'}}, - }).toString(), + }).toString() ).toBe('@use "foo" as foo;')); it('that matches null', () => @@ -336,7 +335,7 @@ describe('a @use rule', () => { useUrl: 'foo', namespace: null, raws: {namespace: {raw: ' as *', value: null}}, - }).toString(), + }).toString() ).toBe('@use "foo" as *;')); it("that doesn't match", () => @@ -344,7 +343,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {url: {raw: ' as bar', value: 'bar'}}, - }).toString(), + }).toString() ).toBe('@use "foo";')); }); @@ -357,7 +356,7 @@ describe('a @use rule', () => { variables: {bar: {text: 'baz', quotes: true}}, }, raws: {beforeWith: '/**/'}, - }).toString(), + }).toString() ).toBe('@use "foo"/**/with ($bar: "baz");')); it('and no configuration', () => @@ -365,7 +364,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {beforeWith: '/**/'}, - }).toString(), + }).toString() ).toBe('@use "foo";')); }); @@ -378,7 +377,7 @@ describe('a @use rule', () => { variables: {bar: {text: 'baz', quotes: true}}, }, raws: {afterWith: '/**/'}, - }).toString(), + }).toString() ).toBe('@use "foo" with/**/($bar: "baz");')); it('and no configuration', () => @@ -386,7 +385,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {afterWith: '/**/'}, - }).toString(), + }).toString() ).toBe('@use "foo";')); }); }); @@ -549,6 +548,6 @@ describe('a @use rule', () => { // Can't JSON-serialize this until we implement Configuration.source.span it.skip('toJSON', () => expect( - scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0], + scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/statement/use-rule.ts b/pkg/sass-parser/lib/src/statement/use-rule.ts index 66bfb3368..f64b3eee3 100644 --- a/pkg/sass-parser/lib/src/statement/use-rule.ts +++ b/pkg/sass-parser/lib/src/statement/use-rule.ts @@ -101,7 +101,7 @@ export class UseRule const basename = url.pathname.split('/').at(-1)!; const dot = basename.indexOf('.'); return sassInternal.parseIdentifier( - dot === -1 ? basename : basename.substring(0, dot), + dot === -1 ? basename : basename.substring(0, dot) ); } @@ -188,14 +188,14 @@ export class UseRule return utils.toJSON( this, ['useUrl', 'namespace', 'configuration', 'params'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts b/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts index 26bb44391..cfb943296 100644 --- a/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts +++ b/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts @@ -12,13 +12,13 @@ describe('a variable declaration', () => { void (node = new VariableDeclaration({ variableName: 'foo', expression: {text: 'bar'}, - })), + })) ); describe('with no namespace and no flags', () => { function describeNode( description: string, - create: () => VariableDeclaration, + create: () => VariableDeclaration ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -45,12 +45,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('$foo: bar').nodes[0] as VariableDeclaration, + () => scss.parse('$foo: bar').nodes[0] as VariableDeclaration ); describeNode( 'parsed as Sass', - () => sass.parse('$foo: bar').nodes[0] as VariableDeclaration, + () => sass.parse('$foo: bar').nodes[0] as VariableDeclaration ); describe('constructed manually', () => { @@ -60,7 +60,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', expression: new StringExpression({text: 'bar'}), - }), + }) ); describeNode( @@ -69,7 +69,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', expression: {text: 'bar'}, - }), + }) ); describeNode( @@ -78,19 +78,19 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', value: 'bar', - }), + }) ); }); describeNode('constructed from ChildProps', () => - utils.fromChildProps({variableName: 'foo', expression: {text: 'bar'}}), + utils.fromChildProps({variableName: 'foo', expression: {text: 'bar'}}) ); }); describe('with a namespace', () => { function describeNode( description: string, - create: () => VariableDeclaration, + create: () => VariableDeclaration ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -117,12 +117,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration, + () => scss.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration ); describeNode( 'parsed as Sass', - () => sass.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration, + () => sass.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration ); describeNode( @@ -132,7 +132,7 @@ describe('a variable declaration', () => { namespace: 'baz', variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), - }), + }) ); describeNode('constructed from ChildProps', () => @@ -140,14 +140,14 @@ describe('a variable declaration', () => { namespace: 'baz', variableName: 'foo', expression: {text: 'bar', quotes: true}, - }), + }) ); }); describe('guarded', () => { function describeNode( description: string, - create: () => VariableDeclaration, + create: () => VariableDeclaration ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -174,12 +174,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration, + () => scss.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration ); describeNode( 'parsed as Sass', - () => sass.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration, + () => sass.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration ); describeNode( @@ -189,7 +189,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), guarded: true, - }), + }) ); describeNode('constructed from ChildProps', () => @@ -197,14 +197,14 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, guarded: true, - }), + }) ); }); describe('global', () => { function describeNode( description: string, - create: () => VariableDeclaration, + create: () => VariableDeclaration ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -231,12 +231,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration, + () => scss.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration ); describeNode( 'parsed as Sass', - () => sass.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration, + () => sass.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration ); describeNode( @@ -246,7 +246,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), global: true, - }), + }) ); describeNode('constructed from ChildProps', () => @@ -254,7 +254,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, global: true, - }), + }) ); }); @@ -302,7 +302,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', expression: {text: 'bar'}, - }).toString(), + }).toString() ).toBe('$foo: bar')); describe('with a namespace', () => { @@ -312,7 +312,7 @@ describe('a variable declaration', () => { namespace: 'baz', variableName: 'foo', expression: {text: 'bar'}, - }).toString(), + }).toString() ).toBe('baz.$foo: bar')); it("that's not an identifier", () => @@ -321,7 +321,7 @@ describe('a variable declaration', () => { namespace: 'b z', variableName: 'foo', expression: {text: 'bar'}, - }).toString(), + }).toString() ).toBe('b\\20z.$foo: bar')); }); @@ -330,7 +330,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'f o', expression: {text: 'bar'}, - }).toString(), + }).toString() ).toBe('$f\\20o: bar')); it('global', () => @@ -339,7 +339,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, global: true, - }).toString(), + }).toString() ).toBe('$foo: bar !global')); it('guarded', () => @@ -348,7 +348,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, guarded: true, - }).toString(), + }).toString() ).toBe('$foo: bar !default')); it('with both flags', () => @@ -358,7 +358,7 @@ describe('a variable declaration', () => { expression: {text: 'bar'}, global: true, guarded: true, - }).toString(), + }).toString() ).toBe('$foo: bar !default !global')); }); @@ -370,7 +370,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {namespace: {raw: 'b\\41z', value: 'baz'}}, - }).toString(), + }).toString() ).toBe('b\\41z.$foo: bar')); it("that doesn't match", () => @@ -380,7 +380,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {namespace: {raw: 'z\\41p', value: 'zap'}}, - }).toString(), + }).toString() ).toBe('baz.$foo: bar')); }); @@ -391,7 +391,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {variableName: {raw: 'f\\f3o', value: 'foo'}}, - }).toString(), + }).toString() ).toBe('$f\\f3o: bar')); it("that doesn't match", () => @@ -400,7 +400,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {namespace: {raw: 'z\\41p', value: 'zap'}}, - }).toString(), + }).toString() ).toBe('$foo: bar')); }); @@ -410,7 +410,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {between: '/**/:'}, - }).toString(), + }).toString() ).toBe('$foo/**/:bar')); describe('with a flags raw', () => { @@ -426,7 +426,7 @@ describe('a variable declaration', () => { value: {guarded: true, global: false}, }, }, - }).toString(), + }).toString() ).toBe('$foo: bar/**/!default')); it('that matches only one', () => @@ -441,7 +441,7 @@ describe('a variable declaration', () => { value: {guarded: true, global: true}, }, }, - }).toString(), + }).toString() ).toBe('$foo: bar !default')); it('that matches neither', () => @@ -456,7 +456,7 @@ describe('a variable declaration', () => { value: {guarded: false, global: true}, }, }, - }).toString(), + }).toString() ).toBe('$foo: bar !default')); }); @@ -467,7 +467,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {afterValue: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: bar/**/')); it('with flags', () => @@ -477,7 +477,7 @@ describe('a variable declaration', () => { expression: {text: 'bar'}, global: true, raws: {afterValue: '/**/'}, - }).toString(), + }).toString() ).toBe('$foo: bar !global/**/')); }); }); @@ -587,12 +587,12 @@ describe('a variable declaration', () => { describe('expression', () => { it('defined changes expression', () => expect( - original.clone({expression: {text: 'zap'}}), + original.clone({expression: {text: 'zap'}}) ).toHaveStringExpression('expression', 'zap')); it('undefined preserves expression', () => expect( - original.clone({expression: undefined}), + original.clone({expression: undefined}) ).toHaveStringExpression('expression', 'bar')); }); diff --git a/pkg/sass-parser/lib/src/statement/variable-declaration.ts b/pkg/sass-parser/lib/src/statement/variable-declaration.ts index 50377d802..780e2a4cf 100644 --- a/pkg/sass-parser/lib/src/statement/variable-declaration.ts +++ b/pkg/sass-parser/lib/src/statement/variable-declaration.ts @@ -162,7 +162,7 @@ export class VariableDeclaration constructor(_: undefined, inner: sassInternal.VariableDeclaration); constructor( defaults?: VariableDeclarationProps, - inner?: sassInternal.VariableDeclaration, + inner?: sassInternal.VariableDeclaration ) { super(defaults as unknown as postcss.DeclarationProps); this.raws ??= {}; @@ -192,7 +192,7 @@ export class VariableDeclaration 'guarded', 'global', ], - ['value'], + ['value'] ); } @@ -203,7 +203,7 @@ export class VariableDeclaration return utils.toJSON( this, ['namespace', 'variableName', 'expression', 'guarded', 'global'], - inputs, + inputs ); } diff --git a/pkg/sass-parser/lib/src/statement/warn-rule.test.ts b/pkg/sass-parser/lib/src/statement/warn-rule.test.ts index a314ada09..0e51af5e7 100644 --- a/pkg/sass-parser/lib/src/statement/warn-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/warn-rule.test.ts @@ -24,12 +24,12 @@ describe('a @warn rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@warn foo').nodes[0] as WarnRule, + () => scss.parse('@warn foo').nodes[0] as WarnRule ); describeNode( 'parsed as Sass', - () => sass.parse('@warn foo').nodes[0] as WarnRule, + () => sass.parse('@warn foo').nodes[0] as WarnRule ); describeNode( @@ -37,13 +37,13 @@ describe('a @warn rule', () => { () => new WarnRule({ warnExpression: {text: 'foo'}, - }), + }) ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ warnExpression: {text: 'foo'}, - }), + }) ); it('throws an error when assigned a new name', () => @@ -51,7 +51,7 @@ describe('a @warn rule', () => { () => (new WarnRule({ warnExpression: {text: 'foo'}, - }).name = 'bar'), + }).name = 'bar') ).toThrow()); describe('assigned a new expression', () => { @@ -106,7 +106,7 @@ describe('a @warn rule', () => { expect( new WarnRule({ warnExpression: {text: 'foo'}, - }).toString(), + }).toString() ).toBe('@warn foo;')); it('with afterName', () => @@ -114,7 +114,7 @@ describe('a @warn rule', () => { new WarnRule({ warnExpression: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString(), + }).toString() ).toBe('@warn/**/foo;')); it('with between', () => @@ -122,7 +122,7 @@ describe('a @warn rule', () => { new WarnRule({ warnExpression: {text: 'foo'}, raws: {between: '/**/'}, - }).toString(), + }).toString() ).toBe('@warn foo/**/;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/warn-rule.ts b/pkg/sass-parser/lib/src/statement/warn-rule.ts index cc2529ece..d45eca18d 100644 --- a/pkg/sass-parser/lib/src/statement/warn-rule.ts +++ b/pkg/sass-parser/lib/src/statement/warn-rule.ts @@ -97,7 +97,7 @@ export class WarnRule this, overrides, ['raws', 'warnExpression'], - [{name: 'params', explicitUndefined: true}], + [{name: 'params', explicitUndefined: true}] ); } @@ -108,14 +108,14 @@ export class WarnRule return utils.toJSON( this, ['name', 'warnExpression', 'params', 'nodes'], - inputs, + inputs ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify, + .stringify ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/stringifier.ts b/pkg/sass-parser/lib/src/stringifier.ts index 8212ffd0c..b83a3aa3c 100644 --- a/pkg/sass-parser/lib/src/stringifier.ts +++ b/pkg/sass-parser/lib/src/stringifier.ts @@ -63,13 +63,13 @@ export class Stringifier extends PostCssStringifier { if (!this[statement.sassType]) { throw new Error( `Unknown AST node type ${statement.sassType}. ` + - 'Maybe you need to change PostCSS stringifier.', + 'Maybe you need to change PostCSS stringifier.' ); } ( this[statement.sassType] as ( node: AnyStatement, - semicolon: boolean, + semicolon: boolean ) => void )(statement, semicolon); } @@ -104,7 +104,7 @@ export class Stringifier extends PostCssStringifier { node.nodes[0], '@at-root' + (node.raws.afterName ?? ' ') + - node.nodes[0].selectorInterpolation, + node.nodes[0].selectorInterpolation ); return; } @@ -118,7 +118,7 @@ export class Stringifier extends PostCssStringifier { } else { this.builder( start + (node.raws.between ?? '') + (semicolon ? ';' : ''), - node, + node ); } } @@ -138,7 +138,7 @@ export class Stringifier extends PostCssStringifier { (node.raws.beforeLines?.[i] ?? '') + '//' + (/[^ \t]/.test(line) ? left : '') + - line, + line ) .join('\n'); diff --git a/pkg/sass-parser/lib/src/utils.ts b/pkg/sass-parser/lib/src/utils.ts index e4dafe7cc..f18f9816c 100644 --- a/pkg/sass-parser/lib/src/utils.ts +++ b/pkg/sass-parser/lib/src/utils.ts @@ -33,7 +33,7 @@ type ClonableField = Name | ExplicitClonableField; /** Makes a {@link ClonableField} explicit. */ function parseClonableField( - field: ClonableField, + field: ClonableField ): ExplicitClonableField { return typeof field === 'string' ? {name: field} : field; } @@ -50,7 +50,7 @@ export function cloneNode>( node: T, overrides: Record | undefined, constructorFields: ClonableField[], - assignedFields?: ClonableField[], + assignedFields?: ClonableField[] ): T { // We have to do these casts because the actual `...Prop` types that get // passed in and used for the constructor aren't actually subtypes of @@ -124,7 +124,7 @@ function maybeClone(value: T): T { export function toJSON( node: T, fields: (keyof T & string)[], - inputs?: Map, + inputs?: Map ): object { // Only include the inputs field at the top level. const includeInputs = !inputs; @@ -169,7 +169,7 @@ export function toJSON( function toJsonField( field: string, value: unknown, - inputs: Map, + inputs: Map ): unknown { if (typeof value !== 'object' || value === null) { return value; @@ -211,7 +211,7 @@ export function longestCommonInitialSubstring(strings: string[]): string { } candidate = candidate.substring( 0, - Math.min(candidate.length, string.length), + Math.min(candidate.length, string.length) ); } } diff --git a/pkg/sass-parser/test/setup.ts b/pkg/sass-parser/test/setup.ts index cbafd0682..66cb2f8d0 100644 --- a/pkg/sass-parser/test/setup.ts +++ b/pkg/sass-parser/test/setup.ts @@ -57,7 +57,7 @@ function toHaveInterpolation( this: MatcherContext, actual: unknown, property: unknown, - value: unknown, + value: unknown ): ExpectationResult { if (typeof property !== 'string') { throw new TypeError(`Property ${property} must be a string.`); @@ -70,7 +70,7 @@ function toHaveInterpolation( message: () => `expected ${printValue( this, - actual, + actual )} to have a property ${this.utils.printExpected(property)}`, pass: false, }; @@ -80,7 +80,7 @@ function toHaveInterpolation( const message = (): string => `expected (${printValue(this, actual)}).${property} ${printValue( this, - actualValue, + actualValue )} to be an Interpolation with value ${this.utils.printExpected(value)}`; if ( @@ -98,7 +98,7 @@ function toHaveInterpolation( message: () => `expected (${printValue(this, actual)}).${property} ${printValue( this, - actualValue, + actualValue )} to have the correct parent`, pass: false, }; @@ -113,14 +113,14 @@ function toHaveStringExpression( this: MatcherContext, actual: unknown, propertyOrIndex: unknown, - value: unknown, + value: unknown ): ExpectationResult { if ( typeof propertyOrIndex !== 'string' && typeof propertyOrIndex !== 'number' ) { throw new TypeError( - `Property ${propertyOrIndex} must be a string or number.`, + `Property ${propertyOrIndex} must be a string or number.` ); } else if (typeof value !== 'string') { throw new TypeError(`Value ${value} must be a string.`); @@ -140,7 +140,7 @@ function toHaveStringExpression( message: () => `expected ${printValue( this, - actual, + actual )} to have a property ${this.utils.printExpected(property)}`, pass: false, }; @@ -157,7 +157,7 @@ function toHaveStringExpression( message + ` ${printValue( this, - actualValue, + actualValue )} to be a StringExpression with value ${this.utils.printExpected(value)}` ); }; @@ -177,7 +177,7 @@ function toHaveStringExpression( message: () => `expected (${printValue(this, actual)}).${property} ${printValue( this, - actualValue, + actualValue )} to have the correct parent`, pass: false, }; @@ -202,7 +202,7 @@ expect.addSnapshotSerializer({ indentation: string, depth: number, refs: pretty.Refs, - printer: pretty.Printer, + printer: pretty.Printer ): string { if (depth !== 0) return `<${value}>`; @@ -285,7 +285,7 @@ function tersePosition(position: JsonPosition): string { if (position.offset !== position.column - 1) { throw new Error( 'Expected offset to be 1 less than column. Column is ' + - `${position.column} and offset is ${position.offset}.`, + `${position.column} and offset is ${position.offset}.` ); } diff --git a/pkg/sass-parser/test/utils.ts b/pkg/sass-parser/test/utils.ts index 741be6a71..1c667d62c 100644 --- a/pkg/sass-parser/test/utils.ts +++ b/pkg/sass-parser/test/utils.ts @@ -29,7 +29,7 @@ export function fromChildProps(props: ChildProps): T { /** Constructs a new expression from {@link props}. */ export function fromExpressionProps( - props: ExpressionProps, + props: ExpressionProps ): T { return new Interpolation({nodes: [props]}).nodes[0] as T; } From 6f14f108fdb7dbf743b19bcec2a8ce35ed351135 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 29 Oct 2024 18:31:20 -0700 Subject: [PATCH 4/5] Add a changelog entry --- pkg/sass-parser/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index c32ae7595..318bf6151 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.4.3-dev -* No user-visible changes. +* Add support for parsing the `@while` rule. ## 0.4.2 From d7412f05a2d4c08f3e9190ae6fc546107fbef7ab Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 30 Oct 2024 18:21:48 -0700 Subject: [PATCH 5/5] Properly reformat --- pkg/sass-parser/lib/index.ts | 2 +- pkg/sass-parser/lib/src/configuration.test.ts | 45 ++++---- pkg/sass-parser/lib/src/configuration.ts | 2 +- .../lib/src/configured-variable.test.ts | 62 +++++------ .../lib/src/configured-variable.ts | 4 +- .../src/expression/binary-operation.test.ts | 14 +-- .../lib/src/expression/binary-operation.ts | 2 +- .../lib/src/expression/boolean.test.ts | 12 +- pkg/sass-parser/lib/src/expression/convert.ts | 2 +- .../lib/src/expression/number.test.ts | 18 +-- .../lib/src/expression/string.test.ts | 38 +++---- pkg/sass-parser/lib/src/expression/string.ts | 2 +- pkg/sass-parser/lib/src/interpolation.test.ts | 72 ++++++------ pkg/sass-parser/lib/src/interpolation.ts | 20 ++-- pkg/sass-parser/lib/src/lazy-source.ts | 2 +- pkg/sass-parser/lib/src/node.d.ts | 6 +- pkg/sass-parser/lib/src/sass-internal.ts | 6 +- .../lib/src/statement/at-root-rule.test.ts | 20 ++-- .../lib/src/statement/at-rule-internal.d.ts | 24 ++-- .../lib/src/statement/container.test.ts | 30 ++--- .../lib/src/statement/css-comment.test.ts | 22 ++-- .../lib/src/statement/css-comment.ts | 6 +- .../lib/src/statement/debug-rule.test.ts | 16 +-- .../lib/src/statement/debug-rule.ts | 6 +- .../src/statement/declaration-internal.d.ts | 24 ++-- .../lib/src/statement/each-rule.test.ts | 29 ++--- .../lib/src/statement/each-rule.ts | 4 +- .../lib/src/statement/error-rule.test.ts | 16 +-- .../lib/src/statement/error-rule.ts | 6 +- .../lib/src/statement/extend-rule.test.ts | 8 +- .../lib/src/statement/for-rule.test.ts | 32 +++--- pkg/sass-parser/lib/src/statement/for-rule.ts | 4 +- .../lib/src/statement/generic-at-rule.test.ts | 104 +++++++++--------- .../lib/src/statement/generic-at-rule.ts | 8 +- pkg/sass-parser/lib/src/statement/index.ts | 10 +- .../lib/src/statement/intercept-is-clean.ts | 2 +- .../lib/src/statement/media-rule.test.ts | 8 +- .../lib/src/statement/root-internal.d.ts | 24 ++-- .../lib/src/statement/root.test.ts | 6 +- pkg/sass-parser/lib/src/statement/root.ts | 2 +- .../lib/src/statement/rule-internal.d.ts | 24 ++-- .../lib/src/statement/rule.test.ts | 36 +++--- pkg/sass-parser/lib/src/statement/rule.ts | 6 +- .../lib/src/statement/sass-comment.test.ts | 34 +++--- .../lib/src/statement/sass-comment.ts | 10 +- .../lib/src/statement/supports-rule.test.ts | 34 +++--- .../lib/src/statement/use-rule.test.ts | 65 +++++------ pkg/sass-parser/lib/src/statement/use-rule.ts | 6 +- .../statement/variable-declaration.test.ts | 84 +++++++------- .../lib/src/statement/variable-declaration.ts | 6 +- .../lib/src/statement/warn-rule.test.ts | 16 +-- .../lib/src/statement/warn-rule.ts | 6 +- .../lib/src/statement/while-rule.test.ts | 24 ++-- .../lib/src/statement/while-rule.ts | 4 +- pkg/sass-parser/lib/src/stringifier.ts | 12 +- pkg/sass-parser/lib/src/utils.ts | 10 +- pkg/sass-parser/test/setup.ts | 22 ++-- pkg/sass-parser/test/utils.ts | 2 +- 58 files changed, 562 insertions(+), 559 deletions(-) diff --git a/pkg/sass-parser/lib/index.ts b/pkg/sass-parser/lib/index.ts index f93c3f11c..f9acab292 100644 --- a/pkg/sass-parser/lib/index.ts +++ b/pkg/sass-parser/lib/index.ts @@ -135,7 +135,7 @@ class _Syntax implements Syntax { return new Root( undefined, - sassInternal.parse(css.toString(), this.#syntax, opts?.from) + sassInternal.parse(css.toString(), this.#syntax, opts?.from), ); } diff --git a/pkg/sass-parser/lib/src/configuration.test.ts b/pkg/sass-parser/lib/src/configuration.test.ts index b260efef3..e0f88aa6d 100644 --- a/pkg/sass-parser/lib/src/configuration.test.ts +++ b/pkg/sass-parser/lib/src/configuration.test.ts @@ -18,7 +18,7 @@ describe('a configuration map', () => { describe('empty', () => { function describeNode( description: string, - create: () => Configuration + create: () => Configuration, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -35,12 +35,12 @@ describe('a configuration map', () => { describeNode( 'parsed as SCSS', - () => (scss.parse('@use "foo"').nodes[0] as UseRule).configuration + () => (scss.parse('@use "foo"').nodes[0] as UseRule).configuration, ); describeNode( 'parsed as Sass', - () => (sass.parse('@use "foo"').nodes[0] as UseRule).configuration + () => (sass.parse('@use "foo"').nodes[0] as UseRule).configuration, ); describe('constructed manually', () => { @@ -50,7 +50,7 @@ describe('a configuration map', () => { describeNode( 'variables record', - () => new Configuration({variables: {}}) + () => new Configuration({variables: {}}), ); }); @@ -58,14 +58,14 @@ describe('a configuration map', () => { 'constructed from props', () => new UseRule({useUrl: 'foo', configuration: {variables: []}}) - .configuration + .configuration, ); }); describe('with a variable', () => { function describeNode( description: string, - create: () => Configuration + create: () => Configuration, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -86,14 +86,14 @@ describe('a configuration map', () => { 'parsed as SCSS', () => (scss.parse('@use "foo" with ($bar: "baz")').nodes[0] as UseRule) - .configuration + .configuration, ); describeNode( 'parsed as Sass', () => (sass.parse('@use "foo" with ($bar: "baz")').nodes[0] as UseRule) - .configuration + .configuration, ); describe('constructed manually', () => { @@ -104,12 +104,13 @@ describe('a configuration map', () => { variables: [ {variableName: 'bar', expression: {text: 'baz', quotes: true}}, ], - }) + }), ); describeNode( 'variables record', - () => new Configuration({variables: {bar: {text: 'baz', quotes: true}}}) + () => + new Configuration({variables: {bar: {text: 'baz', quotes: true}}}), ); }); @@ -119,7 +120,7 @@ describe('a configuration map', () => { new UseRule({ useUrl: 'foo', configuration: {variables: {bar: {text: 'baz', quotes: true}}}, - }).configuration + }).configuration, ); }); @@ -225,7 +226,7 @@ describe('a configuration map', () => { describe('adds a new variable', () => { function describeVariable( description: string, - create: () => Configuration + create: () => Configuration, ): void { it(description, () => { expect(create()).toBe(node); @@ -238,15 +239,15 @@ describe('a configuration map', () => { } describeVariable('with Expression', () => - node.set('baz', new StringExpression({text: 'bang', quotes: true})) + node.set('baz', new StringExpression({text: 'bang', quotes: true})), ); describeVariable('with ExpressionProps', () => - node.set('baz', {text: 'bang', quotes: true}) + node.set('baz', {text: 'bang', quotes: true}), ); describeVariable('with ConfiguredVariableObjectProps', () => - node.set('baz', {expression: {text: 'bang', quotes: true}}) + node.set('baz', {expression: {text: 'bang', quotes: true}}), ); }); @@ -269,7 +270,7 @@ describe('a configuration map', () => { foo: {text: 'bar', quotes: true}, baz: {text: 'bang', quotes: true}, }, - }).toString() + }).toString(), ).toBe('($foo: "bar", $baz: "bang")')); }); @@ -281,7 +282,7 @@ describe('a configuration map', () => { foo: {text: 'bar', quotes: true}, baz: {text: 'bang', quotes: true}, }, - }).toString() + }).toString(), ).toBe('($foo: "bar", $baz: "bang",)')); it('with comma: true and afterValue', () => @@ -295,7 +296,7 @@ describe('a configuration map', () => { raws: {afterValue: '/**/'}, }, }, - }).toString() + }).toString(), ).toBe('($foo: "bar", $baz: "bang"/**/,)')); it('with after', () => @@ -306,7 +307,7 @@ describe('a configuration map', () => { foo: {text: 'bar', quotes: true}, baz: {text: 'bang', quotes: true}, }, - }).toString() + }).toString(), ).toBe('($foo: "bar", $baz: "bang"/**/)')); it('with after and afterValue', () => @@ -320,7 +321,7 @@ describe('a configuration map', () => { raws: {afterValue: ' '}, }, }, - }).toString() + }).toString(), ).toBe('($foo: "bar", $baz: "bang" /**/)')); it('with afterValue and a guard', () => @@ -334,7 +335,7 @@ describe('a configuration map', () => { guarded: true, }, }, - }).toString() + }).toString(), ).toBe('($foo: "bar", $baz: "bang" !default/**/)')); }); }); @@ -422,6 +423,6 @@ describe('a configuration map', () => { it.skip('toJSON', () => expect( (scss.parse('@use "foo" with ($baz: "qux")').nodes[0] as UseRule) - .configuration + .configuration, ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/configuration.ts b/pkg/sass-parser/lib/src/configuration.ts index ecd930fbc..b57226a1e 100644 --- a/pkg/sass-parser/lib/src/configuration.ts +++ b/pkg/sass-parser/lib/src/configuration.ts @@ -66,7 +66,7 @@ export class Configuration extends Node { constructor(_: undefined, inner: sassInternal.ConfiguredVariable[]); constructor( defaults?: ConfigurationProps, - inner?: sassInternal.ConfiguredVariable[] + inner?: sassInternal.ConfiguredVariable[], ) { super({}); this.raws = defaults?.raws ?? {}; diff --git a/pkg/sass-parser/lib/src/configured-variable.test.ts b/pkg/sass-parser/lib/src/configured-variable.test.ts index 33a0de857..c673670a8 100644 --- a/pkg/sass-parser/lib/src/configured-variable.test.ts +++ b/pkg/sass-parser/lib/src/configured-variable.test.ts @@ -11,13 +11,13 @@ describe('a configured variable', () => { void (node = new ConfiguredVariable({ variableName: 'foo', expression: {text: 'bar', quotes: true}, - })) + })), ); describe('unguarded', () => { function describeNode( description: string, - create: () => ConfiguredVariable + create: () => ConfiguredVariable, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -39,7 +39,7 @@ describe('a configured variable', () => { () => ( scss.parse('@use "baz" with ($foo: "bar")').nodes[0] as UseRule - ).configuration.get('foo')! + ).configuration.get('foo')!, ); describeNode( @@ -47,7 +47,7 @@ describe('a configured variable', () => { () => ( sass.parse('@use "baz" with ($foo: "bar")').nodes[0] as UseRule - ).configuration.get('foo')! + ).configuration.get('foo')!, ); describe('constructed manually', () => { @@ -58,12 +58,12 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', new StringExpression({text: 'bar', quotes: true}), - ]) + ]), ); describeNode( 'with ExpressionProps', - () => new ConfiguredVariable(['foo', {text: 'bar', quotes: true}]) + () => new ConfiguredVariable(['foo', {text: 'bar', quotes: true}]), ); describe('with an object', () => { @@ -73,7 +73,7 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', {expression: new StringExpression({text: 'bar', quotes: true})}, - ]) + ]), ); describeNode( @@ -82,7 +82,7 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', {expression: {text: 'bar', quotes: true}}, - ]) + ]), ); }); }); @@ -94,7 +94,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), - }) + }), ); describeNode( @@ -103,7 +103,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'foo', expression: {text: 'bar', quotes: true}, - }) + }), ); }); }); @@ -112,7 +112,7 @@ describe('a configured variable', () => { describe('guarded', () => { function describeNode( description: string, - create: () => ConfiguredVariable + create: () => ConfiguredVariable, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -159,7 +159,7 @@ describe('a configured variable', () => { expression: new StringExpression({text: 'bar', quotes: true}), guarded: true, }, - ]) + ]), ); describeNode( @@ -168,7 +168,7 @@ describe('a configured variable', () => { new ConfiguredVariable([ 'foo', {expression: {text: 'bar', quotes: true}, guarded: true}, - ]) + ]), ); }); @@ -180,7 +180,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), guarded: true, - }) + }), ); describeNode( @@ -190,7 +190,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, guarded: true, - }) + }), ); }); }); @@ -221,7 +221,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'foo', expression: {text: 'bar', quotes: true}, - }).toString() + }).toString(), ).toBe('$foo: "bar"')); it('guarded', () => @@ -230,7 +230,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, guarded: true, - }).toString() + }).toString(), ).toBe('$foo: "bar" !default')); it('with a non-identifier name', () => @@ -238,7 +238,7 @@ describe('a configured variable', () => { new ConfiguredVariable({ variableName: 'f o', expression: {text: 'bar', quotes: true}, - }).toString() + }).toString(), ).toBe('$f\\20o: "bar"')); }); @@ -249,7 +249,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {before: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: "bar"')); it('with matching name', () => @@ -258,7 +258,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {variableName: {raw: 'f\\6fo', value: 'foo'}}, - }).toString() + }).toString(), ).toBe('$f\\6fo: "bar"')); it('with non-matching name', () => @@ -267,7 +267,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {variableName: {raw: 'f\\41o', value: 'fao'}}, - }).toString() + }).toString(), ).toBe('$foo: "bar"')); it('with between', () => @@ -276,7 +276,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {between: ' : '}, - }).toString() + }).toString(), ).toBe('$foo : "bar"')); it('with beforeGuard and a guard', () => @@ -286,7 +286,7 @@ describe('a configured variable', () => { expression: {text: 'bar', quotes: true}, guarded: true, raws: {beforeGuard: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: "bar"/**/!default')); it('with beforeGuard and no guard', () => @@ -295,7 +295,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {beforeGuard: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: "bar"')); // raws.before is only used as part of a Configuration @@ -306,7 +306,7 @@ describe('a configured variable', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, raws: {afterValue: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: "bar"')); it('with a guard', () => @@ -316,7 +316,7 @@ describe('a configured variable', () => { expression: {text: 'bar', quotes: true}, guarded: true, raws: {afterValue: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: "bar" !default')); }); }); @@ -369,24 +369,24 @@ describe('a configured variable', () => { describe('variableName', () => { it('defined', () => expect(original.clone({variableName: 'baz'}).variableName).toBe( - 'baz' + 'baz', )); it('undefined', () => expect(original.clone({variableName: undefined}).variableName).toBe( - 'foo' + 'foo', )); }); describe('expression', () => { it('defined', () => expect( - original.clone({expression: {text: 'baz', quotes: true}}) + original.clone({expression: {text: 'baz', quotes: true}}), ).toHaveStringExpression('expression', 'baz')); it('undefined', () => expect( - original.clone({expression: undefined}) + original.clone({expression: undefined}), ).toHaveStringExpression('expression', 'bar')); }); @@ -404,6 +404,6 @@ describe('a configured variable', () => { expect( ( scss.parse('@use "foo" with ($baz: "qux")').nodes[0] as UseRule - ).configuration.get('baz') + ).configuration.get('baz'), ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/configured-variable.ts b/pkg/sass-parser/lib/src/configured-variable.ts index 82f5d12aa..17dcea6f7 100644 --- a/pkg/sass-parser/lib/src/configured-variable.ts +++ b/pkg/sass-parser/lib/src/configured-variable.ts @@ -122,7 +122,7 @@ export class ConfiguredVariable extends Node { constructor(_: undefined, inner: sassInternal.ConfiguredVariable); constructor( defaults?: ConfiguredVariableProps, - inner?: sassInternal.ConfiguredVariable + inner?: sassInternal.ConfiguredVariable, ) { if (Array.isArray(defaults!)) { const [variableName, rest] = defaults; @@ -164,7 +164,7 @@ export class ConfiguredVariable extends Node { return utils.toJSON( this, ['variableName', 'expression', 'guarded'], - inputs + inputs, ); } diff --git a/pkg/sass-parser/lib/src/expression/binary-operation.test.ts b/pkg/sass-parser/lib/src/expression/binary-operation.test.ts index c03cd6c9c..cd9d06d74 100644 --- a/pkg/sass-parser/lib/src/expression/binary-operation.test.ts +++ b/pkg/sass-parser/lib/src/expression/binary-operation.test.ts @@ -9,7 +9,7 @@ describe('a binary operation', () => { let node: BinaryOperationExpression; function describeNode( description: string, - create: () => BinaryOperationExpression + create: () => BinaryOperationExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -36,7 +36,7 @@ describe('a binary operation', () => { operator: '+', left: {text: 'foo'}, right: {text: 'bar'}, - }) + }), ); describeNode('constructed from ExpressionProps', () => @@ -44,7 +44,7 @@ describe('a binary operation', () => { operator: '+', left: {text: 'foo'}, right: {text: 'bar'}, - }) + }), ); describe('assigned new', () => { @@ -158,13 +158,13 @@ describe('a binary operation', () => { it('defined', () => expect(original.clone({left: {text: 'zip'}})).toHaveStringExpression( 'left', - 'zip' + 'zip', )); it('undefined', () => expect(original.clone({left: undefined})).toHaveStringExpression( 'left', - 'foo' + 'foo', )); }); @@ -172,13 +172,13 @@ describe('a binary operation', () => { it('defined', () => expect(original.clone({right: {text: 'zip'}})).toHaveStringExpression( 'right', - 'zip' + 'zip', )); it('undefined', () => expect(original.clone({right: undefined})).toHaveStringExpression( 'right', - 'bar' + 'bar', )); }); diff --git a/pkg/sass-parser/lib/src/expression/binary-operation.ts b/pkg/sass-parser/lib/src/expression/binary-operation.ts index 12054630c..e6f180521 100644 --- a/pkg/sass-parser/lib/src/expression/binary-operation.ts +++ b/pkg/sass-parser/lib/src/expression/binary-operation.ts @@ -109,7 +109,7 @@ export class BinaryOperationExpression extends Expression { constructor(_: undefined, inner: sassInternal.BinaryOperationExpression); constructor( defaults?: object, - inner?: sassInternal.BinaryOperationExpression + inner?: sassInternal.BinaryOperationExpression, ) { super(defaults); if (inner) { diff --git a/pkg/sass-parser/lib/src/expression/boolean.test.ts b/pkg/sass-parser/lib/src/expression/boolean.test.ts index ca9f64f1b..9322e257d 100644 --- a/pkg/sass-parser/lib/src/expression/boolean.test.ts +++ b/pkg/sass-parser/lib/src/expression/boolean.test.ts @@ -11,7 +11,7 @@ describe('a boolean expression', () => { describe('true', () => { function describeNode( description: string, - create: () => BooleanExpression + create: () => BooleanExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -26,18 +26,18 @@ describe('a boolean expression', () => { describeNode( 'constructed manually', - () => new BooleanExpression({value: true}) + () => new BooleanExpression({value: true}), ); describeNode('constructed from ExpressionProps', () => - utils.fromExpressionProps({value: true}) + utils.fromExpressionProps({value: true}), ); }); describe('false', () => { function describeNode( description: string, - create: () => BooleanExpression + create: () => BooleanExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -52,11 +52,11 @@ describe('a boolean expression', () => { describeNode( 'constructed manually', - () => new BooleanExpression({value: false}) + () => new BooleanExpression({value: false}), ); describeNode('constructed from ExpressionProps', () => - utils.fromExpressionProps({value: false}) + utils.fromExpressionProps({value: false}), ); }); diff --git a/pkg/sass-parser/lib/src/expression/convert.ts b/pkg/sass-parser/lib/src/expression/convert.ts index 52cbb2363..63619898f 100644 --- a/pkg/sass-parser/lib/src/expression/convert.ts +++ b/pkg/sass-parser/lib/src/expression/convert.ts @@ -21,7 +21,7 @@ const visitor = sassInternal.createExpressionVisitor({ /** Converts an internal expression AST node into an external one. */ export function convertExpression( - expression: sassInternal.Expression + expression: sassInternal.Expression, ): Expression { return expression.accept(visitor); } diff --git a/pkg/sass-parser/lib/src/expression/number.test.ts b/pkg/sass-parser/lib/src/expression/number.test.ts index 7a3fe7671..3e95a2061 100644 --- a/pkg/sass-parser/lib/src/expression/number.test.ts +++ b/pkg/sass-parser/lib/src/expression/number.test.ts @@ -11,7 +11,7 @@ describe('a number expression', () => { describe('unitless', () => { function describeNode( description: string, - create: () => NumberExpression + create: () => NumberExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -28,18 +28,18 @@ describe('a number expression', () => { describeNode( 'constructed manually', - () => new NumberExpression({value: 123}) + () => new NumberExpression({value: 123}), ); describeNode('constructed from ExpressionProps', () => - utils.fromExpressionProps({value: 123}) + utils.fromExpressionProps({value: 123}), ); }); describe('with a unit', () => { function describeNode( description: string, - create: () => NumberExpression + create: () => NumberExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -60,14 +60,14 @@ describe('a number expression', () => { new NumberExpression({ value: 123, unit: 'px', - }) + }), ); describeNode('constructed from ExpressionProps', () => utils.fromExpressionProps({ value: 123, unit: 'px', - }) + }), ); }); @@ -119,7 +119,7 @@ describe('a number expression', () => { new NumberExpression({ value: 123, raws: {value: {raw: 'hello', value: 123}}, - }).toString() + }).toString(), ).toBe('hello')); it('with a different raw value than the expression', () => @@ -127,7 +127,7 @@ describe('a number expression', () => { new NumberExpression({ value: 123, raws: {value: {raw: 'hello', value: 234}}, - }).toString() + }).toString(), ).toBe('123')); }); }); @@ -180,7 +180,7 @@ describe('a number expression', () => { describe('raws', () => { it('defined', () => expect( - original.clone({raws: {value: {raw: '1e3', value: 1e3}}}).raws + original.clone({raws: {value: {raw: '1e3', value: 1e3}}}).raws, ).toEqual({ value: {raw: '1e3', value: 1e3}, })); diff --git a/pkg/sass-parser/lib/src/expression/string.test.ts b/pkg/sass-parser/lib/src/expression/string.test.ts index eb5d99074..39dae45d8 100644 --- a/pkg/sass-parser/lib/src/expression/string.test.ts +++ b/pkg/sass-parser/lib/src/expression/string.test.ts @@ -10,7 +10,7 @@ describe('a string expression', () => { describe('quoted', () => { function describeNode( description: string, - create: () => StringExpression + create: () => StringExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -32,7 +32,7 @@ describe('a string expression', () => { new StringExpression({ quotes: true, text: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode( @@ -41,7 +41,7 @@ describe('a string expression', () => { new StringExpression({ quotes: true, text: 'foo', - }) + }), ); }); @@ -50,14 +50,14 @@ describe('a string expression', () => { utils.fromExpressionProps({ quotes: true, text: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode('with string text', () => utils.fromExpressionProps({ quotes: true, text: 'foo', - }) + }), ); }); }); @@ -65,7 +65,7 @@ describe('a string expression', () => { describe('unquoted', () => { function describeNode( description: string, - create: () => StringExpression + create: () => StringExpression, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -86,7 +86,7 @@ describe('a string expression', () => { () => new StringExpression({ text: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode( @@ -95,7 +95,7 @@ describe('a string expression', () => { new StringExpression({ quotes: false, text: 'foo', - }) + }), ); describeNode( @@ -103,7 +103,7 @@ describe('a string expression', () => { () => new StringExpression({ text: 'foo', - }) + }), ); }); @@ -111,20 +111,20 @@ describe('a string expression', () => { describeNode('with explicit text', () => utils.fromExpressionProps({ text: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode('with explicit quotes', () => utils.fromExpressionProps({ quotes: false, text: 'foo', - }) + }), ); describeNode('with string text', () => utils.fromExpressionProps({ text: 'foo', - }) + }), ); }); }); @@ -210,17 +210,17 @@ describe('a string expression', () => { it('with internal unprintable', () => expect( - new StringExpression({quotes: true, text: '\x00'}).toString() + new StringExpression({quotes: true, text: '\x00'}).toString(), ).toBe('"\\0 "')); it('with internal newline', () => expect( - new StringExpression({quotes: true, text: '\x0A'}).toString() + new StringExpression({quotes: true, text: '\x0A'}).toString(), ).toBe('"\\a "')); it('with internal backslash', () => expect( - new StringExpression({quotes: true, text: '\\'}).toString() + new StringExpression({quotes: true, text: '\\'}).toString(), ).toBe('"\\\\"')); it('respects interpolation raws', () => @@ -231,7 +231,7 @@ describe('a string expression', () => { nodes: ['foo'], raws: {text: [{raw: 'f\\6f o', value: 'foo'}]}, }), - }).toString() + }).toString(), ).toBe('"f\\6f o"')); }); @@ -255,7 +255,7 @@ describe('a string expression', () => { nodes: ['foo'], raws: {text: [{raw: 'f\\6f o', value: 'foo'}]}, }), - }).toString() + }).toString(), ).toBe('f\\6f o')); }); }); @@ -304,13 +304,13 @@ describe('a string expression', () => { it('defined', () => expect(original.clone({text: 'zip'})).toHaveInterpolation( 'text', - 'zip' + 'zip', )); it('undefined', () => expect(original.clone({text: undefined})).toHaveInterpolation( 'text', - 'foo' + 'foo', )); }); diff --git a/pkg/sass-parser/lib/src/expression/string.ts b/pkg/sass-parser/lib/src/expression/string.ts index de796e807..e1638da62 100644 --- a/pkg/sass-parser/lib/src/expression/string.ts +++ b/pkg/sass-parser/lib/src/expression/string.ts @@ -104,7 +104,7 @@ export class StringExpression extends Expression { /** @hidden */ toString(): string { - const quote = this.quotes ? this.raws.quotes ?? '"' : ''; + const quote = this.quotes ? (this.raws.quotes ?? '"') : ''; let result = quote; const rawText = this.text.raws.text; const rawExpressions = this.text.raws.expressions; diff --git a/pkg/sass-parser/lib/src/interpolation.test.ts b/pkg/sass-parser/lib/src/interpolation.test.ts index f5ec6684d..fd0b81e29 100644 --- a/pkg/sass-parser/lib/src/interpolation.test.ts +++ b/pkg/sass-parser/lib/src/interpolation.test.ts @@ -18,7 +18,7 @@ describe('an interpolation', () => { describe('empty', () => { function describeNode( description: string, - create: () => Interpolation + create: () => Interpolation, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -42,7 +42,7 @@ describe('an interpolation', () => { describe('with no expressions', () => { function describeNode( description: string, - create: () => Interpolation + create: () => Interpolation, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -63,24 +63,24 @@ describe('an interpolation', () => { describeNode( 'parsed as SCSS', - () => (scss.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation + () => (scss.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation, ); describeNode( 'parsed as CSS', - () => (css.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation + () => (css.parse('@foo').nodes[0] as GenericAtRule).nameInterpolation, ); describeNode( 'constructed manually', - () => new Interpolation({nodes: ['foo']}) + () => new Interpolation({nodes: ['foo']}), ); }); describe('with only an expression', () => { function describeNode( description: string, - create: () => Interpolation + create: () => Interpolation, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -99,19 +99,19 @@ describe('an interpolation', () => { describeNode( 'parsed as SCSS', - () => (scss.parse('@#{foo}').nodes[0] as GenericAtRule).nameInterpolation + () => (scss.parse('@#{foo}').nodes[0] as GenericAtRule).nameInterpolation, ); describeNode( 'constructed manually', - () => new Interpolation({nodes: [{text: 'foo'}]}) + () => new Interpolation({nodes: [{text: 'foo'}]}), ); }); describe('with mixed text and expressions', () => { function describeNode( description: string, - create: () => Interpolation + create: () => Interpolation, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -136,12 +136,12 @@ describe('an interpolation', () => { 'parsed as SCSS', () => (scss.parse('@foo#{bar}baz').nodes[0] as GenericAtRule) - .nameInterpolation + .nameInterpolation, ); describeNode( 'constructed manually', - () => new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}) + () => new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}), ); }); @@ -246,7 +246,7 @@ describe('an interpolation', () => { describe('every', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), ); it('returns true if the callback returns true for all elements', () => @@ -261,7 +261,7 @@ describe('an interpolation', () => { () => void (node = new Interpolation({ nodes: ['foo', 'bar', {text: 'baz'}, 'bar'], - })) + })), ); it('returns the first index of a given string', () => @@ -275,7 +275,7 @@ describe('an interpolation', () => { describe('insertAfter', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), ); it('inserts a node after the given element', () => { @@ -300,12 +300,12 @@ describe('an interpolation', () => { it('inserts before an iterator', () => testEachMutation(['foo', 'bar', ['baz', 5]], 1, () => - node.insertAfter(0, ['qux', 'qax', 'qix']) + node.insertAfter(0, ['qux', 'qax', 'qix']), )); it('inserts after an iterator', () => testEachMutation(['foo', 'bar', 'qux', 'qax', 'qix', 'baz'], 1, () => - node.insertAfter(1, ['qux', 'qax', 'qix']) + node.insertAfter(1, ['qux', 'qax', 'qix']), )); it('returns itself', () => @@ -314,7 +314,7 @@ describe('an interpolation', () => { describe('insertBefore', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), ); it('inserts a node before the given element', () => { @@ -339,12 +339,12 @@ describe('an interpolation', () => { it('inserts before an iterator', () => testEachMutation(['foo', 'bar', ['baz', 5]], 1, () => - node.insertBefore(1, ['qux', 'qax', 'qix']) + node.insertBefore(1, ['qux', 'qax', 'qix']), )); it('inserts after an iterator', () => testEachMutation(['foo', 'bar', 'qux', 'qax', 'qix', 'baz'], 1, () => - node.insertBefore(2, ['qux', 'qax', 'qix']) + node.insertBefore(2, ['qux', 'qax', 'qix']), )); it('returns itself', () => @@ -353,7 +353,7 @@ describe('an interpolation', () => { describe('prepend', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), ); it('inserts one node', () => { @@ -368,7 +368,7 @@ describe('an interpolation', () => { it('inserts before an iterator', () => testEachMutation(['foo', 'bar', ['baz', 5]], 1, () => - node.prepend('qux', 'qax', 'qix') + node.prepend('qux', 'qax', 'qix'), )); it('returns itself', () => expect(node.prepend('qux')).toBe(node)); @@ -391,7 +391,7 @@ describe('an interpolation', () => { describe('removeAll', () => { beforeEach( () => - void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})) + void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})), ); it('removes all nodes', () => { @@ -414,7 +414,7 @@ describe('an interpolation', () => { describe('removeChild', () => { beforeEach( () => - void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})) + void (node = new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']})), ); it('removes a matching node', () => { @@ -436,7 +436,7 @@ describe('an interpolation', () => { it('removes a node before the iterator', () => testEachMutation(['foo', node.nodes[1], ['baz', 1]], 1, () => - node.removeChild(1) + node.removeChild(1), )); it('removes a node after the iterator', () => @@ -447,7 +447,7 @@ describe('an interpolation', () => { describe('some', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), ); it('returns false if the callback returns false for all elements', () => @@ -460,7 +460,7 @@ describe('an interpolation', () => { describe('first', () => { it('returns the first element', () => expect(new Interpolation({nodes: ['foo', 'bar', 'baz']}).first).toBe( - 'foo' + 'foo', )); it('returns undefined for an empty interpolation', () => @@ -470,7 +470,7 @@ describe('an interpolation', () => { describe('last', () => { it('returns the last element', () => expect(new Interpolation({nodes: ['foo', 'bar', 'baz']}).last).toBe( - 'baz' + 'baz', )); it('returns undefined for an empty interpolation', () => @@ -482,22 +482,22 @@ describe('an interpolation', () => { it('with only text', () => expect(new Interpolation({nodes: ['foo', 'bar', 'baz']}).toString()).toBe( - 'foobarbaz' + 'foobarbaz', )); it('with only expressions', () => expect( - new Interpolation({nodes: [{text: 'foo'}, {text: 'bar'}]}).toString() + new Interpolation({nodes: [{text: 'foo'}, {text: 'bar'}]}).toString(), ).toBe('#{foo}#{bar}')); it('with mixed text and expressions', () => expect( - new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}).toString() + new Interpolation({nodes: ['foo', {text: 'bar'}, 'baz']}).toString(), ).toBe('foo#{bar}baz')); describe('with text', () => { beforeEach( - () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})) + () => void (node = new Interpolation({nodes: ['foo', 'bar', 'baz']})), ); it('take precedence when the value matches', () => { @@ -516,7 +516,7 @@ describe('an interpolation', () => { () => void (node = new Interpolation({ nodes: [{text: 'foo'}, {text: 'bar'}], - })) + })), ); it('with before', () => { @@ -538,7 +538,7 @@ describe('an interpolation', () => { void (original = new Interpolation({ nodes: ['foo', {text: 'bar'}, 'baz'], raws: {expressions: [{before: ' '}]}, - })) + })), ); describe('with no overrides', () => { @@ -578,7 +578,7 @@ describe('an interpolation', () => { describe('raws', () => { it('defined', () => expect( - original.clone({raws: {expressions: [{after: ' '}]}}).raws + original.clone({raws: {expressions: [{after: ' '}]}}).raws, ).toEqual({expressions: [{after: ' '}]})); it('undefined', () => @@ -605,7 +605,7 @@ describe('an interpolation', () => { it('toJSON', () => expect( - (scss.parse('@foo#{bar}baz').nodes[0] as GenericAtRule).nameInterpolation + (scss.parse('@foo#{bar}baz').nodes[0] as GenericAtRule).nameInterpolation, ).toMatchSnapshot()); }); @@ -620,7 +620,7 @@ describe('an interpolation', () => { function testEachMutation( elements: ([string | Expression, number] | string | Expression)[], indexToModify: number, - modify: () => void + modify: () => void, ): void { const fn: EachFn = jest.fn((child, i) => { if (i === indexToModify) modify(); diff --git a/pkg/sass-parser/lib/src/interpolation.ts b/pkg/sass-parser/lib/src/interpolation.ts index 032c564dd..c051decc8 100644 --- a/pkg/sass-parser/lib/src/interpolation.ts +++ b/pkg/sass-parser/lib/src/interpolation.ts @@ -132,7 +132,7 @@ export class Interpolation extends Node { this._nodes = []; for (const child of inner.contents) { this.append( - typeof child === 'string' ? child : convertExpression(child) + typeof child === 'string' ? child : convertExpression(child), ); } } @@ -176,7 +176,7 @@ export class Interpolation extends Node { * @return Returns `false` if any call to `callback` returned false */ each( - callback: (node: string | Expression, index: number) => false | void + callback: (node: string | Expression, index: number) => false | void, ): false | undefined { const iterator = {index: 0}; this.#iterators.push(iterator); @@ -201,8 +201,8 @@ export class Interpolation extends Node { condition: ( node: string | Expression, index: number, - nodes: ReadonlyArray - ) => boolean + nodes: ReadonlyArray, + ) => boolean, ): boolean { return this.nodes.every(condition); } @@ -225,7 +225,7 @@ export class Interpolation extends Node { */ insertAfter( oldNode: string | Expression | number, - newNode: NewNodeForInterpolation + newNode: NewNodeForInterpolation, ): this { // TODO - postcss/postcss#1957: Mark this as dirty const index = this.index(oldNode); @@ -248,7 +248,7 @@ export class Interpolation extends Node { */ insertBefore( oldNode: string | Expression | number, - newNode: NewNodeForInterpolation + newNode: NewNodeForInterpolation, ): this { // TODO - postcss/postcss#1957: Mark this as dirty const index = this.index(oldNode); @@ -320,8 +320,8 @@ export class Interpolation extends Node { condition: ( node: string | Expression, index: number, - nodes: ReadonlyArray - ) => boolean + nodes: ReadonlyArray, + ) => boolean, ): boolean { return this.nodes.some(condition); } @@ -401,7 +401,7 @@ export class Interpolation extends Node { /** Like {@link _normalize}, but also flattens a list of nodes. */ private _normalizeList( - nodes: ReadonlyArray + nodes: ReadonlyArray, ): (Expression | string)[] { const result: Array = []; for (const node of nodes) { @@ -413,7 +413,7 @@ export class Interpolation extends Node { /** @hidden */ get nonStatementChildren(): ReadonlyArray { return this.nodes.filter( - (node): node is Expression => typeof node !== 'string' + (node): node is Expression => typeof node !== 'string', ); } } diff --git a/pkg/sass-parser/lib/src/lazy-source.ts b/pkg/sass-parser/lib/src/lazy-source.ts index 5deeadb4f..bcf93bfcd 100644 --- a/pkg/sass-parser/lib/src/lazy-source.ts +++ b/pkg/sass-parser/lib/src/lazy-source.ts @@ -54,7 +54,7 @@ export class LazySource implements postcss.Source { const spanUrl = this.#inner.span.url; sourceFile._postcssInput = new postcss.Input( sourceFile.getText(0), - spanUrl ? {from: url.fileURLToPath(spanUrl)} : undefined + spanUrl ? {from: url.fileURLToPath(spanUrl)} : undefined, ); return sourceFile._postcssInput; } diff --git a/pkg/sass-parser/lib/src/node.d.ts b/pkg/sass-parser/lib/src/node.d.ts index 432983699..11f8d9ae2 100644 --- a/pkg/sass-parser/lib/src/node.d.ts +++ b/pkg/sass-parser/lib/src/node.d.ts @@ -82,10 +82,10 @@ declare abstract class Node cleanRaws(keepBetween?: boolean): void; error( message: string, - options?: postcss.NodeErrorOptions + options?: postcss.NodeErrorOptions, ): postcss.CssSyntaxError; positionBy( - opts?: Pick + opts?: Pick, ): postcss.Position; positionInside(index: number): postcss.Position; rangeBy(opts?: Pick): { @@ -98,6 +98,6 @@ declare abstract class Node warn( result: postcss.Result, message: string, - options?: postcss.WarningOptions + options?: postcss.WarningOptions, ): postcss.Warning; } diff --git a/pkg/sass-parser/lib/src/sass-internal.ts b/pkg/sass-parser/lib/src/sass-internal.ts index 1f9594c8c..e4031d367 100644 --- a/pkg/sass-parser/lib/src/sass-internal.ts +++ b/pkg/sass-parser/lib/src/sass-internal.ts @@ -32,7 +32,7 @@ declare namespace SassInternal { function parseIdentifier( identifier: string, - logger?: sass.Logger + logger?: sass.Logger, ): string | null; function toCssIdentifier(text: string): string; @@ -42,7 +42,7 @@ declare namespace SassInternal { } function createStatementVisitor( - inner: StatementVisitorObject + inner: StatementVisitorObject, ): StatementVisitor; class ExpressionVisitor { @@ -50,7 +50,7 @@ declare namespace SassInternal { } function createExpressionVisitor( - inner: ExpressionVisitorObject + inner: ExpressionVisitorObject, ): ExpressionVisitor; class SassNode { diff --git a/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts b/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts index b5c7a17f7..5f7440c3b 100644 --- a/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/at-root-rule.test.ts @@ -9,7 +9,7 @@ describe('an @at-root rule', () => { describe('with no params', () => { beforeEach( - () => void (node = scss.parse('@at-root {}').nodes[0] as GenericAtRule) + () => void (node = scss.parse('@at-root {}').nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -24,7 +24,7 @@ describe('an @at-root rule', () => { beforeEach( () => void (node = scss.parse('@at-root (with: rule) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -41,7 +41,7 @@ describe('an @at-root rule', () => { beforeEach( () => void (node = scss.parse('@at-root (with: #{rule}) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -60,7 +60,7 @@ describe('an @at-root rule', () => { describe('with style rule shorthand', () => { beforeEach( () => - void (node = scss.parse('@at-root .foo {}').nodes[0] as GenericAtRule) + void (node = scss.parse('@at-root .foo {}').nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('at-root')); @@ -85,7 +85,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{selector: '.foo'}], raws: {atRootShorthand: false}, - }).toString() + }).toString(), ).toBe('@at-root {\n .foo {}\n}')); describe('with atRootShorthand: true', () => { @@ -95,7 +95,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{selector: '.foo'}], raws: {atRootShorthand: true}, - }).toString() + }).toString(), ).toBe('@at-root .foo {}')); it('with no params and multiple children', () => @@ -104,7 +104,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{selector: '.foo'}, {selector: '.bar'}], raws: {atRootShorthand: true}, - }).toString() + }).toString(), ).toBe('@at-root {\n .foo {}\n .bar {}\n}')); it('with no params and a non-style-rule child', () => @@ -113,7 +113,7 @@ describe('an @at-root rule', () => { name: 'at-root', nodes: [{name: 'foo'}], raws: {atRootShorthand: true}, - }).toString() + }).toString(), ).toBe('@at-root {\n @foo\n}')); it('with params and only a style rule child', () => @@ -123,7 +123,7 @@ describe('an @at-root rule', () => { params: '(with: rule)', nodes: [{selector: '.foo'}], raws: {atRootShorthand: true}, - }).toString() + }).toString(), ).toBe('@at-root (with: rule) {\n .foo {}\n}')); it("that's not @at-root", () => @@ -132,7 +132,7 @@ describe('an @at-root rule', () => { name: 'at-wrong', nodes: [{selector: '.foo'}], raws: {atRootShorthand: true}, - }).toString() + }).toString(), ).toBe('@at-wrong {\n .foo {}\n}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts b/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts index 7228613f8..e5395cdca 100644 --- a/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/at-rule-internal.d.ts @@ -27,10 +27,10 @@ export class _AtRule extends postcss.AtRule { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -40,37 +40,37 @@ export class _AtRule extends postcss.AtRule { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/container.test.ts b/pkg/sass-parser/lib/src/statement/container.test.ts index 46ab1fad6..52e736787 100644 --- a/pkg/sass-parser/lib/src/statement/container.test.ts +++ b/pkg/sass-parser/lib/src/statement/container.test.ts @@ -37,12 +37,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar' + '.bar', ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -56,7 +56,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[0].source).toBe(node.source); @@ -81,12 +81,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar' + '.bar', ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -102,12 +102,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar' + '.bar', ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -120,7 +120,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[0].parent).toBe(root); }); @@ -130,7 +130,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[0].parent).toBe(root); }); @@ -138,17 +138,17 @@ describe('a container node', () => { it('a list of properties', () => { root.append( {selectorInterpolation: '.foo'}, - {selectorInterpolation: '.bar'} + {selectorInterpolation: '.bar'}, ); expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar' + '.bar', ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); @@ -159,7 +159,7 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[0].parent).toBe(root); }); @@ -169,12 +169,12 @@ describe('a container node', () => { expect(root.nodes[0]).toBeInstanceOf(Rule); expect(root.nodes[0]).toHaveInterpolation( 'selectorInterpolation', - '.foo' + '.foo', ); expect(root.nodes[1]).toBeInstanceOf(Rule); expect(root.nodes[1]).toHaveInterpolation( 'selectorInterpolation', - '.bar' + '.bar', ); expect(root.nodes[0].parent).toBe(root); expect(root.nodes[1].parent).toBe(root); diff --git a/pkg/sass-parser/lib/src/statement/css-comment.test.ts b/pkg/sass-parser/lib/src/statement/css-comment.test.ts index ae1e5bc65..c8fbaff6d 100644 --- a/pkg/sass-parser/lib/src/statement/css-comment.test.ts +++ b/pkg/sass-parser/lib/src/statement/css-comment.test.ts @@ -24,17 +24,17 @@ describe('a CSS-style comment', () => { describeNode( 'parsed as SCSS', - () => scss.parse('/* foo */').nodes[0] as CssComment + () => scss.parse('/* foo */').nodes[0] as CssComment, ); describeNode( 'parsed as CSS', - () => css.parse('/* foo */').nodes[0] as CssComment + () => css.parse('/* foo */').nodes[0] as CssComment, ); describeNode( 'parsed as Sass', - () => sass.parse('/* foo').nodes[0] as CssComment + () => sass.parse('/* foo').nodes[0] as CssComment, ); describe('constructed manually', () => { @@ -43,7 +43,7 @@ describe('a CSS-style comment', () => { () => new CssComment({ textInterpolation: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode('with a text string', () => new CssComment({text: 'foo'})); @@ -53,11 +53,11 @@ describe('a CSS-style comment', () => { describeNode('with an interpolation', () => utils.fromChildProps({ textInterpolation: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode('with a text string', () => - utils.fromChildProps({text: 'foo'}) + utils.fromChildProps({text: 'foo'}), ); }); @@ -72,7 +72,7 @@ describe('a CSS-style comment', () => { it('with whitespace before and after interpolation', () => expect( - (scss.parse('/* #{foo} */').nodes[0] as CssComment).raws + (scss.parse('/* #{foo} */').nodes[0] as CssComment).raws, ).toEqual({left: ' ', right: ' ', closed: true})); it('without whitespace before and after text', () => @@ -162,7 +162,7 @@ describe('a CSS-style comment', () => { new CssComment({ text: 'foo', raws: {left: '\n'}, - }).toString() + }).toString(), ).toBe('/*\nfoo */')); it('with right', () => @@ -170,14 +170,14 @@ describe('a CSS-style comment', () => { new CssComment({ text: 'foo', raws: {right: '\n'}, - }).toString() + }).toString(), ).toBe('/* foo\n*/')); it('with before', () => expect( new Root({ nodes: [new CssComment({text: 'foo', raws: {before: '/**/'}})], - }).toString() + }).toString(), ).toBe('/**//* foo */')); }); }); @@ -219,7 +219,7 @@ describe('a CSS-style comment', () => { describe('clone', () => { let original: CssComment; beforeEach( - () => void (original = scss.parse('/* foo */').nodes[0] as CssComment) + () => void (original = scss.parse('/* foo */').nodes[0] as CssComment), ); describe('with no overrides', () => { diff --git a/pkg/sass-parser/lib/src/statement/css-comment.ts b/pkg/sass-parser/lib/src/statement/css-comment.ts index f2565caa0..432520ddb 100644 --- a/pkg/sass-parser/lib/src/statement/css-comment.ts +++ b/pkg/sass-parser/lib/src/statement/css-comment.ts @@ -125,7 +125,7 @@ export class CssComment this.textInterpolation = new Interpolation(); for (const child of nodes) { this.textInterpolation.append( - typeof child === 'string' ? child : convertExpression(child) + typeof child === 'string' ? child : convertExpression(child), ); } } @@ -136,7 +136,7 @@ export class CssComment this, overrides, ['raws', 'textInterpolation'], - ['text'] + ['text'], ); } @@ -150,7 +150,7 @@ export class CssComment /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/debug-rule.test.ts b/pkg/sass-parser/lib/src/statement/debug-rule.test.ts index 2ac421dbc..a06b459aa 100644 --- a/pkg/sass-parser/lib/src/statement/debug-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/debug-rule.test.ts @@ -24,12 +24,12 @@ describe('a @debug rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@debug foo').nodes[0] as DebugRule + () => scss.parse('@debug foo').nodes[0] as DebugRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@debug foo').nodes[0] as DebugRule + () => sass.parse('@debug foo').nodes[0] as DebugRule, ); describeNode( @@ -37,13 +37,13 @@ describe('a @debug rule', () => { () => new DebugRule({ debugExpression: {text: 'foo'}, - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ debugExpression: {text: 'foo'}, - }) + }), ); it('throws an error when assigned a new name', () => @@ -51,7 +51,7 @@ describe('a @debug rule', () => { () => (new DebugRule({ debugExpression: {text: 'foo'}, - }).name = 'bar') + }).name = 'bar'), ).toThrow()); describe('assigned a new expression', () => { @@ -106,7 +106,7 @@ describe('a @debug rule', () => { expect( new DebugRule({ debugExpression: {text: 'foo'}, - }).toString() + }).toString(), ).toBe('@debug foo;')); it('with afterName', () => @@ -114,7 +114,7 @@ describe('a @debug rule', () => { new DebugRule({ debugExpression: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@debug/**/foo;')); it('with between', () => @@ -122,7 +122,7 @@ describe('a @debug rule', () => { new DebugRule({ debugExpression: {text: 'foo'}, raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('@debug foo/**/;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/debug-rule.ts b/pkg/sass-parser/lib/src/statement/debug-rule.ts index d0030d81d..aa4154b63 100644 --- a/pkg/sass-parser/lib/src/statement/debug-rule.ts +++ b/pkg/sass-parser/lib/src/statement/debug-rule.ts @@ -97,7 +97,7 @@ export class DebugRule this, overrides, ['raws', 'debugExpression'], - [{name: 'params', explicitUndefined: true}] + [{name: 'params', explicitUndefined: true}], ); } @@ -108,14 +108,14 @@ export class DebugRule return utils.toJSON( this, ['name', 'debugExpression', 'params', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts b/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts index c10d2fa6e..03f4e3ec8 100644 --- a/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/declaration-internal.d.ts @@ -27,10 +27,10 @@ export class _Declaration extends postcss.Declaration { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -40,37 +40,37 @@ export class _Declaration extends postcss.Declaration { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/each-rule.test.ts b/pkg/sass-parser/lib/src/statement/each-rule.test.ts index d70d53992..433fa10fd 100644 --- a/pkg/sass-parser/lib/src/statement/each-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/each-rule.test.ts @@ -29,12 +29,12 @@ describe('an @each rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@each $foo, $bar in baz {}').nodes[0] as EachRule + () => scss.parse('@each $foo, $bar in baz {}').nodes[0] as EachRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@each $foo, $bar in baz').nodes[0] as EachRule + () => sass.parse('@each $foo, $bar in baz').nodes[0] as EachRule, ); describeNode( @@ -43,14 +43,14 @@ describe('an @each rule', () => { new EachRule({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - }) + }), ); }); @@ -80,12 +80,13 @@ describe('an @each rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@each $foo, $bar in baz {@child}').nodes[0] as EachRule + () => scss.parse('@each $foo, $bar in baz {@child}').nodes[0] as EachRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@each $foo, $bar in baz\n @child').nodes[0] as EachRule + () => + sass.parse('@each $foo, $bar in baz\n @child').nodes[0] as EachRule, ); describeNode( @@ -95,7 +96,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }) + }), ); describeNode('constructed from ChildProps', () => @@ -103,7 +104,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }) + }), ); }); @@ -113,7 +114,7 @@ describe('an @each rule', () => { void (node = new EachRule({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - })) + })), ); it('name', () => expect(() => (node.name = 'qux')).toThrow()); @@ -158,7 +159,7 @@ describe('an @each rule', () => { new EachRule({ variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, - }).toString() + }).toString(), ).toBe('@each $foo, $bar in baz {}')); it('with afterName', () => @@ -167,7 +168,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@each/**/$foo, $bar in baz {}')); it('with afterVariables', () => @@ -176,7 +177,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, raws: {afterVariables: ['/**/,', '/* */']}, - }).toString() + }).toString(), ).toBe('@each $foo/**/,$bar/* */in baz {}')); it('with afterIn', () => @@ -185,7 +186,7 @@ describe('an @each rule', () => { variables: ['foo', 'bar'], eachExpression: {text: 'baz'}, raws: {afterIn: '/**/'}, - }).toString() + }).toString(), ).toBe('@each $foo, $bar in/**/baz {}')); }); }); @@ -297,6 +298,6 @@ describe('an @each rule', () => { it('toJSON', () => expect( - scss.parse('@each $foo, $bar in baz {}').nodes[0] + scss.parse('@each $foo, $bar in baz {}').nodes[0], ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/statement/each-rule.ts b/pkg/sass-parser/lib/src/statement/each-rule.ts index e0339f961..ea2c812d6 100644 --- a/pkg/sass-parser/lib/src/statement/each-rule.ts +++ b/pkg/sass-parser/lib/src/statement/each-rule.ts @@ -139,14 +139,14 @@ export class EachRule return utils.toJSON( this, ['name', 'variables', 'eachExpression', 'params', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/error-rule.test.ts b/pkg/sass-parser/lib/src/statement/error-rule.test.ts index 0524338bf..57b33aac5 100644 --- a/pkg/sass-parser/lib/src/statement/error-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/error-rule.test.ts @@ -24,12 +24,12 @@ describe('a @error rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@error foo').nodes[0] as ErrorRule + () => scss.parse('@error foo').nodes[0] as ErrorRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@error foo').nodes[0] as ErrorRule + () => sass.parse('@error foo').nodes[0] as ErrorRule, ); describeNode( @@ -37,13 +37,13 @@ describe('a @error rule', () => { () => new ErrorRule({ errorExpression: {text: 'foo'}, - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ errorExpression: {text: 'foo'}, - }) + }), ); it('throws an error when assigned a new name', () => @@ -51,7 +51,7 @@ describe('a @error rule', () => { () => (new ErrorRule({ errorExpression: {text: 'foo'}, - }).name = 'bar') + }).name = 'bar'), ).toThrow()); describe('assigned a new expression', () => { @@ -106,7 +106,7 @@ describe('a @error rule', () => { expect( new ErrorRule({ errorExpression: {text: 'foo'}, - }).toString() + }).toString(), ).toBe('@error foo;')); it('with afterName', () => @@ -114,7 +114,7 @@ describe('a @error rule', () => { new ErrorRule({ errorExpression: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@error/**/foo;')); it('with between', () => @@ -122,7 +122,7 @@ describe('a @error rule', () => { new ErrorRule({ errorExpression: {text: 'foo'}, raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('@error foo/**/;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/error-rule.ts b/pkg/sass-parser/lib/src/statement/error-rule.ts index 7b55f4253..3d7b369c0 100644 --- a/pkg/sass-parser/lib/src/statement/error-rule.ts +++ b/pkg/sass-parser/lib/src/statement/error-rule.ts @@ -97,7 +97,7 @@ export class ErrorRule this, overrides, ['raws', 'errorExpression'], - [{name: 'params', explicitUndefined: true}] + [{name: 'params', explicitUndefined: true}], ); } @@ -108,14 +108,14 @@ export class ErrorRule return utils.toJSON( this, ['name', 'errorExpression', 'params', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/extend-rule.test.ts b/pkg/sass-parser/lib/src/statement/extend-rule.test.ts index 15485b604..45210c90c 100644 --- a/pkg/sass-parser/lib/src/statement/extend-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/extend-rule.test.ts @@ -11,7 +11,7 @@ describe('an @extend rule', () => { beforeEach( () => void (node = (scss.parse('.foo {@extend .bar}').nodes[0] as Rule) - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('extend')); @@ -26,7 +26,7 @@ describe('an @extend rule', () => { beforeEach( () => void (node = (scss.parse('.foo {@extend .#{bar}}').nodes[0] as Rule) - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('extend')); @@ -45,7 +45,7 @@ describe('an @extend rule', () => { () => void (node = ( scss.parse('.foo {@extend .bar !optional}').nodes[0] as Rule - ).nodes[0] as GenericAtRule) + ).nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('extend')); @@ -53,7 +53,7 @@ describe('an @extend rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '.bar !optional' + '.bar !optional', )); it('has matching params', () => expect(node.params).toBe('.bar !optional')); diff --git a/pkg/sass-parser/lib/src/statement/for-rule.test.ts b/pkg/sass-parser/lib/src/statement/for-rule.test.ts index 607dd4217..66becdcb4 100644 --- a/pkg/sass-parser/lib/src/statement/for-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/for-rule.test.ts @@ -33,12 +33,12 @@ describe('an @for rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@for $foo from bar through baz {}').nodes[0] as ForRule + () => scss.parse('@for $foo from bar through baz {}').nodes[0] as ForRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@for $foo from bar through baz').nodes[0] as ForRule + () => sass.parse('@for $foo from bar through baz').nodes[0] as ForRule, ); describeNode( @@ -49,7 +49,7 @@ describe('an @for rule', () => { to: 'through', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - }) + }), ); describeNode('constructed from ChildProps', () => @@ -58,7 +58,7 @@ describe('an @for rule', () => { to: 'through', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - }) + }), ); }); @@ -94,14 +94,14 @@ describe('an @for rule', () => { 'parsed as SCSS', () => scss.parse('@for $foo from bar through baz {@child}') - .nodes[0] as ForRule + .nodes[0] as ForRule, ); describeNode( 'parsed as Sass', () => sass.parse('@for $foo from bar through baz\n @child') - .nodes[0] as ForRule + .nodes[0] as ForRule, ); describeNode( @@ -113,7 +113,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }) + }), ); describeNode('constructed from ChildProps', () => @@ -123,7 +123,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, nodes: [{name: 'child'}], - }) + }), ); }); @@ -134,7 +134,7 @@ describe('an @for rule', () => { variable: 'foo', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - })) + })), ); it('name', () => expect(() => (node.name = 'qux')).toThrow()); @@ -209,7 +209,7 @@ describe('an @for rule', () => { variable: 'foo', fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, - }).toString() + }).toString(), ).toBe('@for $foo from bar to baz {}')); it('with afterName', () => @@ -219,7 +219,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@for/**/$foo from bar to baz {}')); it('with afterVariable', () => @@ -229,7 +229,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterVariable: '/**/'}, - }).toString() + }).toString(), ).toBe('@for $foo/**/from bar to baz {}')); it('with afterFrom', () => @@ -239,7 +239,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterFrom: '/**/'}, - }).toString() + }).toString(), ).toBe('@for $foo from/**/bar to baz {}')); it('with afterFromExpression', () => @@ -249,7 +249,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterFromExpression: '/**/'}, - }).toString() + }).toString(), ).toBe('@for $foo from bar/**/to baz {}')); it('with afterTo', () => @@ -259,7 +259,7 @@ describe('an @for rule', () => { fromExpression: {text: 'bar'}, toExpression: {text: 'baz'}, raws: {afterTo: '/**/'}, - }).toString() + }).toString(), ).toBe('@for $foo from bar to/**/baz {}')); }); }); @@ -432,6 +432,6 @@ describe('an @for rule', () => { it('toJSON', () => expect( - scss.parse('@for $foo from bar to baz {}').nodes[0] + scss.parse('@for $foo from bar to baz {}').nodes[0], ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/statement/for-rule.ts b/pkg/sass-parser/lib/src/statement/for-rule.ts index d67fe91f6..8147f83b0 100644 --- a/pkg/sass-parser/lib/src/statement/for-rule.ts +++ b/pkg/sass-parser/lib/src/statement/for-rule.ts @@ -174,14 +174,14 @@ export class ForRule 'params', 'nodes', ], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts b/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts index c40dfab62..e75d06519 100644 --- a/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/generic-at-rule.test.ts @@ -11,7 +11,7 @@ describe('a generic @-rule', () => { describe('with no params', () => { function describeNode( description: string, - create: () => GenericAtRule + create: () => GenericAtRule, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -36,17 +36,17 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo').nodes[0] as GenericAtRule + () => scss.parse('@foo').nodes[0] as GenericAtRule, ); describeNode( 'parsed as CSS', - () => css.parse('@foo').nodes[0] as GenericAtRule + () => css.parse('@foo').nodes[0] as GenericAtRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@foo').nodes[0] as GenericAtRule + () => sass.parse('@foo').nodes[0] as GenericAtRule, ); describe('constructed manually', () => { @@ -55,12 +55,12 @@ describe('a generic @-rule', () => { () => new GenericAtRule({ nameInterpolation: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode( 'with a name string', - () => new GenericAtRule({name: 'foo'}) + () => new GenericAtRule({name: 'foo'}), ); }); @@ -68,11 +68,11 @@ describe('a generic @-rule', () => { describeNode('with a name interpolation', () => utils.fromChildProps({ nameInterpolation: new Interpolation({nodes: ['foo']}), - }) + }), ); describeNode('with a name string', () => - utils.fromChildProps({name: 'foo'}) + utils.fromChildProps({name: 'foo'}), ); }); }); @@ -80,7 +80,7 @@ describe('a generic @-rule', () => { describe('with params', () => { function describeNode( description: string, - create: () => GenericAtRule + create: () => GenericAtRule, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -98,17 +98,17 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo bar').nodes[0] as GenericAtRule + () => scss.parse('@foo bar').nodes[0] as GenericAtRule, ); describeNode( 'parsed as CSS', - () => css.parse('@foo bar').nodes[0] as GenericAtRule + () => css.parse('@foo bar').nodes[0] as GenericAtRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@foo bar').nodes[0] as GenericAtRule + () => sass.parse('@foo bar').nodes[0] as GenericAtRule, ); describe('constructed manually', () => { @@ -118,12 +118,12 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar']}), - }) + }), ); describeNode( 'with a param string', - () => new GenericAtRule({name: 'foo', params: 'bar'}) + () => new GenericAtRule({name: 'foo', params: 'bar'}), ); }); @@ -132,11 +132,11 @@ describe('a generic @-rule', () => { utils.fromChildProps({ name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar']}), - }) + }), ); describeNode('with a param string', () => - utils.fromChildProps({name: 'foo', params: 'bar'}) + utils.fromChildProps({name: 'foo', params: 'bar'}), ); }); }); @@ -146,7 +146,7 @@ describe('a generic @-rule', () => { describe('with no params', () => { function describeNode( description: string, - create: () => GenericAtRule + create: () => GenericAtRule, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -164,28 +164,28 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo {}').nodes[0] as GenericAtRule + () => scss.parse('@foo {}').nodes[0] as GenericAtRule, ); describeNode( 'parsed as CSS', - () => css.parse('@foo {}').nodes[0] as GenericAtRule + () => css.parse('@foo {}').nodes[0] as GenericAtRule, ); describeNode( 'constructed manually', - () => new GenericAtRule({name: 'foo', nodes: []}) + () => new GenericAtRule({name: 'foo', nodes: []}), ); describeNode('constructed from ChildProps', () => - utils.fromChildProps({name: 'foo', nodes: []}) + utils.fromChildProps({name: 'foo', nodes: []}), ); }); describe('with params', () => { function describeNode( description: string, - create: () => GenericAtRule + create: () => GenericAtRule, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -201,12 +201,12 @@ describe('a generic @-rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@foo bar {}').nodes[0] as GenericAtRule + () => scss.parse('@foo bar {}').nodes[0] as GenericAtRule, ); describeNode( 'parsed as CSS', - () => css.parse('@foo bar {}').nodes[0] as GenericAtRule + () => css.parse('@foo bar {}').nodes[0] as GenericAtRule, ); describe('constructed manually', () => { @@ -217,7 +217,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar ', nodes: [], - }) + }), ); describeNode( @@ -227,7 +227,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar ']}), nodes: [], - }) + }), ); }); @@ -237,7 +237,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar ', nodes: [], - }) + }), ); describeNode('with an interpolation', () => @@ -245,7 +245,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: new Interpolation({nodes: ['bar ']}), nodes: [], - }) + }), ); }); }); @@ -276,7 +276,7 @@ describe('a generic @-rule', () => { describe('with params', () => { function describeNode( description: string, - create: () => GenericAtRule + create: () => GenericAtRule, ): void { describe(description, () => { beforeEach(() => void (node = create())); @@ -298,7 +298,7 @@ describe('a generic @-rule', () => { describeNode( 'parsed as Sass', - () => sass.parse('@foo bar\n .baz').nodes[0] as GenericAtRule + () => sass.parse('@foo bar\n .baz').nodes[0] as GenericAtRule, ); describe('constructed manually', () => { @@ -309,7 +309,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar', nodes: [{selector: '.baz\n'}], - }) + }), ); }); @@ -319,7 +319,7 @@ describe('a generic @-rule', () => { name: 'foo', params: 'bar', nodes: [{selector: '.baz\n'}], - }) + }), ); }); }); @@ -422,7 +422,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo/**/;')); it('with afterName', () => @@ -430,7 +430,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo/**/;')); it('with between', () => @@ -438,7 +438,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo/**/;')); it('with afterName and between', () => @@ -446,7 +446,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', raws: {afterName: '/*afterName*/', between: '/*between*/'}, - }).toString() + }).toString(), ).toBe('@foo/*afterName*//*between*/;')); }); @@ -456,7 +456,7 @@ describe('a generic @-rule', () => { new GenericAtRule({ name: 'foo', paramsInterpolation: 'baz', - }).toString() + }).toString(), ).toBe('@foo baz;')); it('with afterName', () => @@ -465,7 +465,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: 'baz', raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo/**/baz;')); it('with between', () => @@ -474,20 +474,20 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: 'baz', raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo baz/**/;')); }); it('with after', () => expect( - new GenericAtRule({name: 'foo', raws: {after: '/**/'}}).toString() + new GenericAtRule({name: 'foo', raws: {after: '/**/'}}).toString(), ).toBe('@foo;')); it('with before', () => expect( new Root({ nodes: [new GenericAtRule({name: 'foo', raws: {before: '/**/'}})], - }).toString() + }).toString(), ).toBe('/**/@foo')); }); @@ -495,7 +495,7 @@ describe('a generic @-rule', () => { describe('without params', () => { it('with default raws', () => expect(new GenericAtRule({name: 'foo', nodes: []}).toString()).toBe( - '@foo {}' + '@foo {}', )); it('with afterName', () => @@ -504,7 +504,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {afterName: '/**/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo/**/ {}')); it('with afterName', () => @@ -513,7 +513,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {afterName: '/**/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo/**/ {}')); it('with between', () => @@ -522,7 +522,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {between: '/**/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo/**/{}')); it('with afterName and between', () => @@ -531,7 +531,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {afterName: '/*afterName*/', between: '/*between*/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo/*afterName*//*between*/{}')); }); @@ -542,7 +542,7 @@ describe('a generic @-rule', () => { name: 'foo', paramsInterpolation: 'baz', nodes: [], - }).toString() + }).toString(), ).toBe('@foo baz {}')); it('with afterName', () => @@ -552,7 +552,7 @@ describe('a generic @-rule', () => { paramsInterpolation: 'baz', raws: {afterName: '/**/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo/**/baz {}')); it('with between', () => @@ -562,7 +562,7 @@ describe('a generic @-rule', () => { paramsInterpolation: 'baz', raws: {between: '/**/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo baz/**/{}')); }); @@ -573,7 +573,7 @@ describe('a generic @-rule', () => { name: 'foo', raws: {after: '/**/'}, nodes: [], - }).toString() + }).toString(), ).toBe('@foo {/**/}')); it('with a child', () => @@ -582,7 +582,7 @@ describe('a generic @-rule', () => { name: 'foo', nodes: [{selector: '.bar'}], raws: {after: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo {\n .bar {}/**/}')); }); @@ -596,7 +596,7 @@ describe('a generic @-rule', () => { nodes: [], }), ], - }).toString() + }).toString(), ).toBe('/**/@foo {}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/generic-at-rule.ts b/pkg/sass-parser/lib/src/statement/generic-at-rule.ts index 97ae32e05..0ccb6e586 100644 --- a/pkg/sass-parser/lib/src/statement/generic-at-rule.ts +++ b/pkg/sass-parser/lib/src/statement/generic-at-rule.ts @@ -136,7 +136,7 @@ export class GenericAtRule return this._paramsInterpolation; } set paramsInterpolation( - paramsInterpolation: Interpolation | string | undefined + paramsInterpolation: Interpolation | string | undefined, ) { if (this._paramsInterpolation) this._paramsInterpolation.parent = undefined; if (typeof paramsInterpolation === 'string') { @@ -173,7 +173,7 @@ export class GenericAtRule 'nameInterpolation', {name: 'paramsInterpolation', explicitUndefined: true}, ], - ['name', {name: 'params', explicitUndefined: true}] + ['name', {name: 'params', explicitUndefined: true}], ); } @@ -184,14 +184,14 @@ export class GenericAtRule return utils.toJSON( this, ['name', 'nameInterpolation', 'params', 'paramsInterpolation', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/index.ts b/pkg/sass-parser/lib/src/statement/index.ts index 2635cc470..3be667fd3 100644 --- a/pkg/sass-parser/lib/src/statement/index.ts +++ b/pkg/sass-parser/lib/src/statement/index.ts @@ -191,7 +191,7 @@ const visitor = sassInternal.createStatementVisitor({ name: 'supports', paramsInterpolation: new Interpolation( undefined, - inner.condition.toInterpolation() + inner.condition.toInterpolation(), ), source: new LazySource(inner), }); @@ -207,7 +207,7 @@ const visitor = sassInternal.createStatementVisitor({ /** Appends parsed versions of `internal`'s children to `container`. */ export function appendInternalChildren( container: postcss.Container, - children: sassInternal.Statement[] | null + children: sassInternal.Statement[] | null, ): void { // Make sure `container` knows it has a block. if (children?.length === 0) container.append(undefined); @@ -233,7 +233,7 @@ export type NewNode = const postcssNormalize = postcss.Container.prototype['normalize'] as ( nodes: postcss.NewChild, sample: postcss.Node | undefined, - type?: 'prepend' | false + type?: 'prepend' | false, ) => postcss.ChildNode[]; /** @@ -243,7 +243,7 @@ const postcssNormalize = postcss.Container.prototype['normalize'] as ( function postcssNormalizeAndConvertToSass( self: StatementWithChildren, node: string | postcss.ChildProps | postcss.Node, - sample: postcss.Node | undefined + sample: postcss.Node | undefined, ): ChildNode[] { return postcssNormalize.call(self, node, sample).map(postcssNode => { // postcssNormalize sets the parent to the Sass node, but we don't want to @@ -278,7 +278,7 @@ function postcssNormalizeAndConvertToSass( export function normalize( self: StatementWithChildren, node: NewNode, - sample?: postcss.Node + sample?: postcss.Node, ): ChildNode[] { if (node === undefined) return []; const nodes = Array.isArray(node) ? node : [node]; diff --git a/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts b/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts index 37e7fc35a..57ebfa87c 100644 --- a/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts +++ b/pkg/sass-parser/lib/src/statement/intercept-is-clean.ts @@ -13,7 +13,7 @@ import type {Statement} from '.'; * clean as well. */ export function interceptIsClean( - klass: utils.Constructor + klass: utils.Constructor, ): void { Object.defineProperty(klass as typeof klass & {_isClean: boolean}, isClean, { get(): boolean { diff --git a/pkg/sass-parser/lib/src/statement/media-rule.test.ts b/pkg/sass-parser/lib/src/statement/media-rule.test.ts index 7a2f8d9ac..8b48530f3 100644 --- a/pkg/sass-parser/lib/src/statement/media-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/media-rule.test.ts @@ -10,7 +10,7 @@ describe('a @media rule', () => { describe('with no interpolation', () => { beforeEach( () => - void (node = scss.parse('@media screen {}').nodes[0] as GenericAtRule) + void (node = scss.parse('@media screen {}').nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('media')); @@ -27,7 +27,7 @@ describe('a @media rule', () => { beforeEach( () => void (node = scss.parse('@media (hover: #{hover}) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('media')); @@ -40,7 +40,7 @@ describe('a @media rule', () => { expect(params.nodes[3]).toBeInstanceOf(StringExpression); expect((params.nodes[3] as StringExpression).text).toHaveStringExpression( 0, - 'hover' + 'hover', ); expect(params.nodes[4]).toBe(')'); }); @@ -55,7 +55,7 @@ describe('a @media rule', () => { it('to SCSS', () => expect( (node = scss.parse('@media #{screen} and (hover: #{hover}) {@foo}') - .nodes[0] as GenericAtRule).toString() + .nodes[0] as GenericAtRule).toString(), ).toBe('@media #{screen} and (hover: #{hover}) {\n @foo\n}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/root-internal.d.ts b/pkg/sass-parser/lib/src/statement/root-internal.d.ts index 975b19ed7..7306eeeb2 100644 --- a/pkg/sass-parser/lib/src/statement/root-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/root-internal.d.ts @@ -29,10 +29,10 @@ export class _Root extends postcss.Root { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -42,37 +42,37 @@ export class _Root extends postcss.Root { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/root.test.ts b/pkg/sass-parser/lib/src/statement/root.test.ts index 2d8d19687..a236dc874 100644 --- a/pkg/sass-parser/lib/src/statement/root.test.ts +++ b/pkg/sass-parser/lib/src/statement/root.test.ts @@ -48,7 +48,7 @@ describe('a root node', () => { describeNode( 'constructed manually', - () => new Root({nodes: [{name: 'foo'}]}) + () => new Root({nodes: [{name: 'foo'}]}), ); }); @@ -70,7 +70,7 @@ describe('a root node', () => { new Root({ nodes: [{name: 'foo'}], raws: {after: '/**/'}, - }).toString() + }).toString(), ).toBe('@foo/**/')); }); @@ -83,7 +83,7 @@ describe('a root node', () => { new Root({ nodes: [{name: 'foo'}], raws: {semicolon: true}, - }).toString() + }).toString(), ).toBe('@foo;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/root.ts b/pkg/sass-parser/lib/src/statement/root.ts index f3b2471a7..7f2dd4b80 100644 --- a/pkg/sass-parser/lib/src/statement/root.ts +++ b/pkg/sass-parser/lib/src/statement/root.ts @@ -69,7 +69,7 @@ export class Root extends _Root implements Statement { toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/rule-internal.d.ts b/pkg/sass-parser/lib/src/statement/rule-internal.d.ts index 31bef89ac..89f4e1a00 100644 --- a/pkg/sass-parser/lib/src/statement/rule-internal.d.ts +++ b/pkg/sass-parser/lib/src/statement/rule-internal.d.ts @@ -29,10 +29,10 @@ export class _Rule extends postcss.Rule { cloneAfter(overrides?: Partial): this; cloneBefore(overrides?: Partial): this; each( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; every( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; @@ -42,37 +42,37 @@ export class _Rule extends postcss.Rule { replaceWith(...nodes: NewNode[]): this; root(): Root; some( - condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean, ): boolean; walk( - callback: (node: ChildNode, index: number) => false | void + callback: (node: ChildNode, index: number) => false | void, ): false | undefined; walkAtRules( nameFilter: RegExp | string, - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkAtRules( - callback: (atRule: AtRule, index: number) => false | void + callback: (atRule: AtRule, index: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkComments( - callback: (comment: Comment, indexed: number) => false | void + callback: (comment: Comment, indexed: number) => false | void, ): false | undefined; walkDecls( propFilter: RegExp | string, - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkDecls( - callback: (decl: Declaration, index: number) => false | void + callback: (decl: Declaration, index: number) => false | void, ): false | undefined; walkRules( selectorFilter: RegExp | string, - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; walkRules( - callback: (rule: Rule, index: number) => false | void + callback: (rule: Rule, index: number) => false | void, ): false | undefined; get first(): ChildNode | undefined; get last(): ChildNode | undefined; diff --git a/pkg/sass-parser/lib/src/statement/rule.test.ts b/pkg/sass-parser/lib/src/statement/rule.test.ts index 1146867cb..708de8170 100644 --- a/pkg/sass-parser/lib/src/statement/rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/rule.test.ts @@ -27,7 +27,7 @@ describe('a style rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('.foo {}').nodes[0] as Rule + () => scss.parse('.foo {}').nodes[0] as Rule, ); describeNode('parsed as CSS', () => css.parse('.foo {}').nodes[0] as Rule); @@ -51,12 +51,12 @@ describe('a style rule', () => { () => new Rule({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), - }) + }), ); describeNode( 'with a selector string', - () => new Rule({selector: '.foo '}) + () => new Rule({selector: '.foo '}), ); }); @@ -64,11 +64,11 @@ describe('a style rule', () => { describeNode('with an interpolation', () => utils.fromChildProps({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), - }) + }), ); describeNode('with a selector string', () => - utils.fromChildProps({selector: '.foo '}) + utils.fromChildProps({selector: '.foo '}), ); }); }); @@ -93,12 +93,12 @@ describe('a style rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('.foo {@bar}').nodes[0] as Rule + () => scss.parse('.foo {@bar}').nodes[0] as Rule, ); describeNode( 'parsed as CSS', - () => css.parse('.foo {@bar}').nodes[0] as Rule + () => css.parse('.foo {@bar}').nodes[0] as Rule, ); describe('parsed as Sass', () => { @@ -125,12 +125,12 @@ describe('a style rule', () => { new Rule({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), nodes: [{name: 'bar'}], - }) + }), ); describeNode( 'with a selector string', - () => new Rule({selector: '.foo ', nodes: [{name: 'bar'}]}) + () => new Rule({selector: '.foo ', nodes: [{name: 'bar'}]}), ); }); @@ -139,11 +139,11 @@ describe('a style rule', () => { utils.fromChildProps({ selectorInterpolation: new Interpolation({nodes: ['.foo ']}), nodes: [{name: 'bar'}], - }) + }), ); describeNode('with a selector string', () => - utils.fromChildProps({selector: '.foo ', nodes: [{name: 'bar'}]}) + utils.fromChildProps({selector: '.foo ', nodes: [{name: 'bar'}]}), ); }); }); @@ -193,7 +193,7 @@ describe('a style rule', () => { new Rule({ selector: '.foo', nodes: [{selector: '.bar'}], - }).toString() + }).toString(), ).toBe('.foo {\n .bar {}\n}')); }); @@ -202,13 +202,13 @@ describe('a style rule', () => { new Rule({ selector: '.foo', raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('.foo/**/{}')); describe('with after', () => { it('with no children', () => expect( - new Rule({selector: '.foo', raws: {after: '/**/'}}).toString() + new Rule({selector: '.foo', raws: {after: '/**/'}}).toString(), ).toBe('.foo {/**/}')); it('with a child', () => @@ -217,7 +217,7 @@ describe('a style rule', () => { selector: '.foo', nodes: [{selector: '.bar'}], raws: {after: '/**/'}, - }).toString() + }).toString(), ).toBe('.foo {\n .bar {}/**/}')); }); @@ -225,7 +225,7 @@ describe('a style rule', () => { expect( new Root({ nodes: [new Rule({selector: '.foo', raws: {before: '/**/'}})], - }).toString() + }).toString(), ).toBe('/**/.foo {}')); }); }); @@ -303,7 +303,7 @@ describe('a style rule', () => { it('preserves selectorInterpolation', () => expect(clone).toHaveInterpolation( 'selectorInterpolation', - '.foo ' + '.foo ', )); }); }); @@ -334,7 +334,7 @@ describe('a style rule', () => { it('preserves selectorInterpolation', () => expect(clone).toHaveInterpolation( 'selectorInterpolation', - '.foo ' + '.foo ', )); }); }); diff --git a/pkg/sass-parser/lib/src/statement/rule.ts b/pkg/sass-parser/lib/src/statement/rule.ts index 087a99ba1..b53605a09 100644 --- a/pkg/sass-parser/lib/src/statement/rule.ts +++ b/pkg/sass-parser/lib/src/statement/rule.ts @@ -104,7 +104,7 @@ export class Rule extends _Rule implements Statement { this, overrides, ['nodes', 'raws', 'selectorInterpolation'], - ['selector', 'selectors'] + ['selector', 'selectors'], ); } @@ -115,14 +115,14 @@ export class Rule extends _Rule implements Statement { return utils.toJSON( this, ['selector', 'selectorInterpolation', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/sass-comment.test.ts b/pkg/sass-parser/lib/src/statement/sass-comment.test.ts index cbd88598b..3f2655eee 100644 --- a/pkg/sass-parser/lib/src/statement/sass-comment.test.ts +++ b/pkg/sass-parser/lib/src/statement/sass-comment.test.ts @@ -24,21 +24,21 @@ describe('a Sass-style comment', () => { describeNode( 'parsed as SCSS', - () => scss.parse('// foo\n// bar').nodes[0] as SassComment + () => scss.parse('// foo\n// bar').nodes[0] as SassComment, ); describeNode( 'parsed as Sass', - () => sass.parse('// foo\n// bar').nodes[0] as SassComment + () => sass.parse('// foo\n// bar').nodes[0] as SassComment, ); describeNode( 'constructed manually', - () => new SassComment({text: 'foo\nbar'}) + () => new SassComment({text: 'foo\nbar'}), ); describeNode('constructed from ChildProps', () => - utils.fromChildProps({silentText: 'foo\nbar'}) + utils.fromChildProps({silentText: 'foo\nbar'}), ); describe('parses raws', () => { @@ -217,7 +217,7 @@ describe('a Sass-style comment', () => { describe('to SCSS', () => { it('with default raws', () => expect(new SassComment({text: 'foo\nbar'}).toString()).toBe( - '// foo\n// bar' + '// foo\n// bar', )); it('with left', () => @@ -225,7 +225,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\nbar', raws: {left: '\t'}, - }).toString() + }).toString(), ).toBe('//\tfoo\n//\tbar')); it('with left and an empty line', () => @@ -233,7 +233,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\n\nbar', raws: {left: '\t'}, - }).toString() + }).toString(), ).toBe('//\tfoo\n//\n//\tbar')); it('with left and a whitespace-only line', () => @@ -241,7 +241,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\n \nbar', raws: {left: '\t'}, - }).toString() + }).toString(), ).toBe('//\tfoo\n// \n//\tbar')); it('with before', () => @@ -249,7 +249,7 @@ describe('a Sass-style comment', () => { new SassComment({ text: 'foo\nbar', raws: {before: '\t'}, - }).toString() + }).toString(), ).toBe('\t// foo\n\t// bar')); it('with beforeLines', () => @@ -261,7 +261,7 @@ describe('a Sass-style comment', () => { raws: {beforeLines: [' ', '\t']}, }), ], - }).toString() + }).toString(), ).toBe(' // foo\n\t// bar')); describe('with a following sibling', () => { @@ -269,7 +269,7 @@ describe('a Sass-style comment', () => { expect( new Root({ nodes: [{silentText: 'foo\nbar'}, {name: 'baz'}], - }).toString() + }).toString(), ).toBe('// foo\n// bar\n@baz')); it('with before with newline', () => @@ -279,7 +279,7 @@ describe('a Sass-style comment', () => { {silentText: 'foo\nbar'}, {name: 'baz', raws: {before: '\n '}}, ], - }).toString() + }).toString(), ).toBe('// foo\n// bar\n @baz')); it('with before without newline', () => @@ -289,7 +289,7 @@ describe('a Sass-style comment', () => { {silentText: 'foo\nbar'}, {name: 'baz', raws: {before: ' '}}, ], - }).toString() + }).toString(), ).toBe('// foo\n// bar\n @baz')); }); @@ -299,7 +299,7 @@ describe('a Sass-style comment', () => { new Rule({ selector: '.zip', nodes: [{silentText: 'foo\nbar'}], - }).toString() + }).toString(), ).toBe('.zip {\n // foo\n// bar\n}')); it('with after with newline', () => @@ -308,7 +308,7 @@ describe('a Sass-style comment', () => { selector: '.zip', nodes: [{silentText: 'foo\nbar'}], raws: {after: '\n '}, - }).toString() + }).toString(), ).toBe('.zip {\n // foo\n// bar\n }')); it('with after without newline', () => @@ -317,7 +317,7 @@ describe('a Sass-style comment', () => { selector: '.zip', nodes: [{silentText: 'foo\nbar'}], raws: {after: ' '}, - }).toString() + }).toString(), ).toBe('.zip {\n // foo\n// bar\n }')); }); }); @@ -358,7 +358,7 @@ describe('a Sass-style comment', () => { describe('clone', () => { let original: SassComment; beforeEach( - () => void (original = scss.parse('// foo').nodes[0] as SassComment) + () => void (original = scss.parse('// foo').nodes[0] as SassComment), ); describe('with no overrides', () => { diff --git a/pkg/sass-parser/lib/src/statement/sass-comment.ts b/pkg/sass-parser/lib/src/statement/sass-comment.ts index 1c8bb66ec..6aa9e4aa6 100644 --- a/pkg/sass-parser/lib/src/statement/sass-comment.ts +++ b/pkg/sass-parser/lib/src/statement/sass-comment.ts @@ -136,17 +136,17 @@ export class SassComment } lineInfo[0].before = inner.span.file.getText( i + 1, - inner.span.start.offset + inner.span.start.offset, ); const before = (this.raws.before = utils.longestCommonInitialSubstring( - lineInfo.map(info => info.before) + lineInfo.map(info => info.before), )); this.raws.beforeLines = lineInfo.map(info => - info.before.substring(before.length) + info.before.substring(before.length), ); const left = (this.raws.left = utils.longestCommonInitialSubstring( - lineInfo.map(info => info.left).filter(left => left !== null) + lineInfo.map(info => info.left).filter(left => left !== null), )); this.text = lineInfo .map(info => (info.left?.substring(left.length) ?? '') + info.text) @@ -168,7 +168,7 @@ export class SassComment /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/supports-rule.test.ts b/pkg/sass-parser/lib/src/statement/supports-rule.test.ts index 1de844e5d..cde095733 100644 --- a/pkg/sass-parser/lib/src/statement/supports-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/supports-rule.test.ts @@ -11,7 +11,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports ( foo $&#{bar} baz) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -35,7 +35,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports ( foo : bar, #abc, []) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -43,7 +43,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '( foo : bar, #abc, [])' + '( foo : bar, #abc, [])', )); it('has matching params', () => @@ -58,7 +58,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports ($foo: $bar) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -66,7 +66,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '(#{$foo}: #{$bar})' + '(#{$foo}: #{$bar})', )); it('has matching params', () => expect(node.params).toBe('($foo: $bar)')); @@ -79,7 +79,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports (#{"foo"}: #{"bar"}) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -87,7 +87,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '(#{"foo"}: #{"bar"})' + '(#{"foo"}: #{"bar"})', )); it('has matching params', () => @@ -102,7 +102,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports foo#{"bar"}(baz &*^ #{"bang"}) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -110,7 +110,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - 'foo#{"bar"}(baz &*^ #{"bang"})' + 'foo#{"bar"}(baz &*^ #{"bang"})', )); it('has matching params', () => @@ -118,7 +118,7 @@ describe('a @supports rule', () => { it('stringifies to SCSS', () => expect(node.toString()).toBe( - '@supports foo#{"bar"}(baz &*^ #{"bang"}) {}' + '@supports foo#{"bar"}(baz &*^ #{"bang"}) {}', )); }); @@ -126,7 +126,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports #{"bar"} {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -145,7 +145,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports not #{"bar"} {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -153,7 +153,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - 'not #{"bar"}' + 'not #{"bar"}', )); it('has matching params', () => expect(node.params).toBe('not #{"bar"}')); @@ -166,7 +166,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports not/**/#{"bar"} {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -174,7 +174,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - 'not/**/#{"bar"}' + 'not/**/#{"bar"}', )); it('has matching params', () => @@ -189,7 +189,7 @@ describe('a @supports rule', () => { beforeEach( () => void (node = scss.parse('@supports (#{"foo"} or #{"bar"}) {}') - .nodes[0] as GenericAtRule) + .nodes[0] as GenericAtRule), ); it('has a name', () => expect(node.name).toBe('supports')); @@ -197,7 +197,7 @@ describe('a @supports rule', () => { it('has a paramsInterpolation', () => expect(node).toHaveInterpolation( 'paramsInterpolation', - '(#{"foo"} or #{"bar"})' + '(#{"foo"} or #{"bar"})', )); it('has matching params', () => diff --git a/pkg/sass-parser/lib/src/statement/use-rule.test.ts b/pkg/sass-parser/lib/src/statement/use-rule.test.ts index 27a76c5ee..cacbb4d40 100644 --- a/pkg/sass-parser/lib/src/statement/use-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/use-rule.test.ts @@ -36,12 +36,12 @@ describe('a @use rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@use "foo"').nodes[0] as UseRule + () => scss.parse('@use "foo"').nodes[0] as UseRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@use "foo"').nodes[0] as UseRule + () => sass.parse('@use "foo"').nodes[0] as UseRule, ); describeNode( @@ -49,13 +49,13 @@ describe('a @use rule', () => { () => new UseRule({ useUrl: 'foo', - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ useUrl: 'foo', - }) + }), ); }); @@ -88,12 +88,12 @@ describe('a @use rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@use "foo" as *').nodes[0] as UseRule + () => scss.parse('@use "foo" as *').nodes[0] as UseRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@use "foo" as *').nodes[0] as UseRule + () => sass.parse('@use "foo" as *').nodes[0] as UseRule, ); describeNode( @@ -102,14 +102,14 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: null, - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ useUrl: 'foo', namespace: null, - }) + }), ); }); @@ -147,13 +147,13 @@ describe('a @use rule', () => { describeNode( 'parsed as SCSS', () => - scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule + scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule, ); describeNode( 'parsed as Sass', () => - sass.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule + sass.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] as UseRule, ); describeNode( @@ -165,7 +165,7 @@ describe('a @use rule', () => { configuration: { variables: {baz: {text: 'qux', quotes: true}}, }, - }) + }), ); describeNode('constructed from ChildProps', () => @@ -175,7 +175,7 @@ describe('a @use rule', () => { configuration: { variables: {baz: {text: 'qux', quotes: true}}, }, - }) + }), ); }); @@ -216,12 +216,12 @@ describe('a @use rule', () => { describe('is null for', () => { it('a URL without a pathname', () => expect( - new UseRule({useUrl: 'https://example.org'}).defaultNamespace + new UseRule({useUrl: 'https://example.org'}).defaultNamespace, ).toBeNull()); it('a URL with a slash pathname', () => expect( - new UseRule({useUrl: 'https://example.org/'}).defaultNamespace + new UseRule({useUrl: 'https://example.org/'}).defaultNamespace, ).toBeNull()); it('a basename that starts with .', () => @@ -239,7 +239,7 @@ describe('a @use rule', () => { it('the basename', () => expect(new UseRule({useUrl: 'foo/bar/baz'}).defaultNamespace).toBe( - 'baz' + 'baz', )); it('without an extension', () => @@ -247,17 +247,18 @@ describe('a @use rule', () => { it('the basename of an HTTP URL', () => expect( - new UseRule({useUrl: 'http://example.org/foo/bar/baz'}).defaultNamespace + new UseRule({useUrl: 'http://example.org/foo/bar/baz'}) + .defaultNamespace, ).toBe('baz')); it('the basename of a file: URL', () => expect( - new UseRule({useUrl: 'file:///foo/bar/baz'}).defaultNamespace + new UseRule({useUrl: 'file:///foo/bar/baz'}).defaultNamespace, ).toBe('baz')); it('the basename of an unknown scheme URL', () => expect(new UseRule({useUrl: 'foo:bar/bar/qux'}).defaultNamespace).toBe( - 'qux' + 'qux', )); it('a sass: URL', () => @@ -272,7 +273,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: 'bar', - }).toString() + }).toString(), ).toBe('@use "foo" as bar;')); it('with a non-identifier namespace', () => @@ -280,7 +281,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: ' ', - }).toString() + }).toString(), ).toBe('@use "foo" as \\20;')); it('with no namespace', () => @@ -288,7 +289,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', namespace: null, - }).toString() + }).toString(), ).toBe('@use "foo" as *;')); it('with configuration', () => @@ -298,7 +299,7 @@ describe('a @use rule', () => { configuration: { variables: {bar: {text: 'baz', quotes: true}}, }, - }).toString() + }).toString(), ).toBe('@use "foo" with ($bar: "baz");')); }); @@ -308,7 +309,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {url: {raw: "'foo'", value: 'foo'}}, - }).toString() + }).toString(), ).toBe("@use 'foo';")); it("that doesn't match", () => @@ -316,7 +317,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {url: {raw: "'bar'", value: 'bar'}}, - }).toString() + }).toString(), ).toBe('@use "foo";')); }); @@ -326,7 +327,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {namespace: {raw: ' as foo', value: 'foo'}}, - }).toString() + }).toString(), ).toBe('@use "foo" as foo;')); it('that matches null', () => @@ -335,7 +336,7 @@ describe('a @use rule', () => { useUrl: 'foo', namespace: null, raws: {namespace: {raw: ' as *', value: null}}, - }).toString() + }).toString(), ).toBe('@use "foo" as *;')); it("that doesn't match", () => @@ -343,7 +344,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {url: {raw: ' as bar', value: 'bar'}}, - }).toString() + }).toString(), ).toBe('@use "foo";')); }); @@ -356,7 +357,7 @@ describe('a @use rule', () => { variables: {bar: {text: 'baz', quotes: true}}, }, raws: {beforeWith: '/**/'}, - }).toString() + }).toString(), ).toBe('@use "foo"/**/with ($bar: "baz");')); it('and no configuration', () => @@ -364,7 +365,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {beforeWith: '/**/'}, - }).toString() + }).toString(), ).toBe('@use "foo";')); }); @@ -377,7 +378,7 @@ describe('a @use rule', () => { variables: {bar: {text: 'baz', quotes: true}}, }, raws: {afterWith: '/**/'}, - }).toString() + }).toString(), ).toBe('@use "foo" with/**/($bar: "baz");')); it('and no configuration', () => @@ -385,7 +386,7 @@ describe('a @use rule', () => { new UseRule({ useUrl: 'foo', raws: {afterWith: '/**/'}, - }).toString() + }).toString(), ).toBe('@use "foo";')); }); }); @@ -548,6 +549,6 @@ describe('a @use rule', () => { // Can't JSON-serialize this until we implement Configuration.source.span it.skip('toJSON', () => expect( - scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0] + scss.parse('@use "foo" as bar with ($baz: "qux")').nodes[0], ).toMatchSnapshot()); }); diff --git a/pkg/sass-parser/lib/src/statement/use-rule.ts b/pkg/sass-parser/lib/src/statement/use-rule.ts index f64b3eee3..66bfb3368 100644 --- a/pkg/sass-parser/lib/src/statement/use-rule.ts +++ b/pkg/sass-parser/lib/src/statement/use-rule.ts @@ -101,7 +101,7 @@ export class UseRule const basename = url.pathname.split('/').at(-1)!; const dot = basename.indexOf('.'); return sassInternal.parseIdentifier( - dot === -1 ? basename : basename.substring(0, dot) + dot === -1 ? basename : basename.substring(0, dot), ); } @@ -188,14 +188,14 @@ export class UseRule return utils.toJSON( this, ['useUrl', 'namespace', 'configuration', 'params'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts b/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts index cfb943296..26bb44391 100644 --- a/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts +++ b/pkg/sass-parser/lib/src/statement/variable-declaration.test.ts @@ -12,13 +12,13 @@ describe('a variable declaration', () => { void (node = new VariableDeclaration({ variableName: 'foo', expression: {text: 'bar'}, - })) + })), ); describe('with no namespace and no flags', () => { function describeNode( description: string, - create: () => VariableDeclaration + create: () => VariableDeclaration, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -45,12 +45,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('$foo: bar').nodes[0] as VariableDeclaration + () => scss.parse('$foo: bar').nodes[0] as VariableDeclaration, ); describeNode( 'parsed as Sass', - () => sass.parse('$foo: bar').nodes[0] as VariableDeclaration + () => sass.parse('$foo: bar').nodes[0] as VariableDeclaration, ); describe('constructed manually', () => { @@ -60,7 +60,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', expression: new StringExpression({text: 'bar'}), - }) + }), ); describeNode( @@ -69,7 +69,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', expression: {text: 'bar'}, - }) + }), ); describeNode( @@ -78,19 +78,19 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', value: 'bar', - }) + }), ); }); describeNode('constructed from ChildProps', () => - utils.fromChildProps({variableName: 'foo', expression: {text: 'bar'}}) + utils.fromChildProps({variableName: 'foo', expression: {text: 'bar'}}), ); }); describe('with a namespace', () => { function describeNode( description: string, - create: () => VariableDeclaration + create: () => VariableDeclaration, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -117,12 +117,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration + () => scss.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration, ); describeNode( 'parsed as Sass', - () => sass.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration + () => sass.parse('baz.$foo: "bar"').nodes[0] as VariableDeclaration, ); describeNode( @@ -132,7 +132,7 @@ describe('a variable declaration', () => { namespace: 'baz', variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), - }) + }), ); describeNode('constructed from ChildProps', () => @@ -140,14 +140,14 @@ describe('a variable declaration', () => { namespace: 'baz', variableName: 'foo', expression: {text: 'bar', quotes: true}, - }) + }), ); }); describe('guarded', () => { function describeNode( description: string, - create: () => VariableDeclaration + create: () => VariableDeclaration, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -174,12 +174,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration + () => scss.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration, ); describeNode( 'parsed as Sass', - () => sass.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration + () => sass.parse('$foo: "bar" !default').nodes[0] as VariableDeclaration, ); describeNode( @@ -189,7 +189,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), guarded: true, - }) + }), ); describeNode('constructed from ChildProps', () => @@ -197,14 +197,14 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, guarded: true, - }) + }), ); }); describe('global', () => { function describeNode( description: string, - create: () => VariableDeclaration + create: () => VariableDeclaration, ): void { describe(description, () => { beforeEach(() => (node = create())); @@ -231,12 +231,12 @@ describe('a variable declaration', () => { describeNode( 'parsed as SCSS', - () => scss.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration + () => scss.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration, ); describeNode( 'parsed as Sass', - () => sass.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration + () => sass.parse('$foo: "bar" !global').nodes[0] as VariableDeclaration, ); describeNode( @@ -246,7 +246,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: new StringExpression({text: 'bar', quotes: true}), global: true, - }) + }), ); describeNode('constructed from ChildProps', () => @@ -254,7 +254,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar', quotes: true}, global: true, - }) + }), ); }); @@ -302,7 +302,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'foo', expression: {text: 'bar'}, - }).toString() + }).toString(), ).toBe('$foo: bar')); describe('with a namespace', () => { @@ -312,7 +312,7 @@ describe('a variable declaration', () => { namespace: 'baz', variableName: 'foo', expression: {text: 'bar'}, - }).toString() + }).toString(), ).toBe('baz.$foo: bar')); it("that's not an identifier", () => @@ -321,7 +321,7 @@ describe('a variable declaration', () => { namespace: 'b z', variableName: 'foo', expression: {text: 'bar'}, - }).toString() + }).toString(), ).toBe('b\\20z.$foo: bar')); }); @@ -330,7 +330,7 @@ describe('a variable declaration', () => { new VariableDeclaration({ variableName: 'f o', expression: {text: 'bar'}, - }).toString() + }).toString(), ).toBe('$f\\20o: bar')); it('global', () => @@ -339,7 +339,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, global: true, - }).toString() + }).toString(), ).toBe('$foo: bar !global')); it('guarded', () => @@ -348,7 +348,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, guarded: true, - }).toString() + }).toString(), ).toBe('$foo: bar !default')); it('with both flags', () => @@ -358,7 +358,7 @@ describe('a variable declaration', () => { expression: {text: 'bar'}, global: true, guarded: true, - }).toString() + }).toString(), ).toBe('$foo: bar !default !global')); }); @@ -370,7 +370,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {namespace: {raw: 'b\\41z', value: 'baz'}}, - }).toString() + }).toString(), ).toBe('b\\41z.$foo: bar')); it("that doesn't match", () => @@ -380,7 +380,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {namespace: {raw: 'z\\41p', value: 'zap'}}, - }).toString() + }).toString(), ).toBe('baz.$foo: bar')); }); @@ -391,7 +391,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {variableName: {raw: 'f\\f3o', value: 'foo'}}, - }).toString() + }).toString(), ).toBe('$f\\f3o: bar')); it("that doesn't match", () => @@ -400,7 +400,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {namespace: {raw: 'z\\41p', value: 'zap'}}, - }).toString() + }).toString(), ).toBe('$foo: bar')); }); @@ -410,7 +410,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {between: '/**/:'}, - }).toString() + }).toString(), ).toBe('$foo/**/:bar')); describe('with a flags raw', () => { @@ -426,7 +426,7 @@ describe('a variable declaration', () => { value: {guarded: true, global: false}, }, }, - }).toString() + }).toString(), ).toBe('$foo: bar/**/!default')); it('that matches only one', () => @@ -441,7 +441,7 @@ describe('a variable declaration', () => { value: {guarded: true, global: true}, }, }, - }).toString() + }).toString(), ).toBe('$foo: bar !default')); it('that matches neither', () => @@ -456,7 +456,7 @@ describe('a variable declaration', () => { value: {guarded: false, global: true}, }, }, - }).toString() + }).toString(), ).toBe('$foo: bar !default')); }); @@ -467,7 +467,7 @@ describe('a variable declaration', () => { variableName: 'foo', expression: {text: 'bar'}, raws: {afterValue: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: bar/**/')); it('with flags', () => @@ -477,7 +477,7 @@ describe('a variable declaration', () => { expression: {text: 'bar'}, global: true, raws: {afterValue: '/**/'}, - }).toString() + }).toString(), ).toBe('$foo: bar !global/**/')); }); }); @@ -587,12 +587,12 @@ describe('a variable declaration', () => { describe('expression', () => { it('defined changes expression', () => expect( - original.clone({expression: {text: 'zap'}}) + original.clone({expression: {text: 'zap'}}), ).toHaveStringExpression('expression', 'zap')); it('undefined preserves expression', () => expect( - original.clone({expression: undefined}) + original.clone({expression: undefined}), ).toHaveStringExpression('expression', 'bar')); }); diff --git a/pkg/sass-parser/lib/src/statement/variable-declaration.ts b/pkg/sass-parser/lib/src/statement/variable-declaration.ts index 780e2a4cf..50377d802 100644 --- a/pkg/sass-parser/lib/src/statement/variable-declaration.ts +++ b/pkg/sass-parser/lib/src/statement/variable-declaration.ts @@ -162,7 +162,7 @@ export class VariableDeclaration constructor(_: undefined, inner: sassInternal.VariableDeclaration); constructor( defaults?: VariableDeclarationProps, - inner?: sassInternal.VariableDeclaration + inner?: sassInternal.VariableDeclaration, ) { super(defaults as unknown as postcss.DeclarationProps); this.raws ??= {}; @@ -192,7 +192,7 @@ export class VariableDeclaration 'guarded', 'global', ], - ['value'] + ['value'], ); } @@ -203,7 +203,7 @@ export class VariableDeclaration return utils.toJSON( this, ['namespace', 'variableName', 'expression', 'guarded', 'global'], - inputs + inputs, ); } diff --git a/pkg/sass-parser/lib/src/statement/warn-rule.test.ts b/pkg/sass-parser/lib/src/statement/warn-rule.test.ts index 0e51af5e7..a314ada09 100644 --- a/pkg/sass-parser/lib/src/statement/warn-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/warn-rule.test.ts @@ -24,12 +24,12 @@ describe('a @warn rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@warn foo').nodes[0] as WarnRule + () => scss.parse('@warn foo').nodes[0] as WarnRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@warn foo').nodes[0] as WarnRule + () => sass.parse('@warn foo').nodes[0] as WarnRule, ); describeNode( @@ -37,13 +37,13 @@ describe('a @warn rule', () => { () => new WarnRule({ warnExpression: {text: 'foo'}, - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ warnExpression: {text: 'foo'}, - }) + }), ); it('throws an error when assigned a new name', () => @@ -51,7 +51,7 @@ describe('a @warn rule', () => { () => (new WarnRule({ warnExpression: {text: 'foo'}, - }).name = 'bar') + }).name = 'bar'), ).toThrow()); describe('assigned a new expression', () => { @@ -106,7 +106,7 @@ describe('a @warn rule', () => { expect( new WarnRule({ warnExpression: {text: 'foo'}, - }).toString() + }).toString(), ).toBe('@warn foo;')); it('with afterName', () => @@ -114,7 +114,7 @@ describe('a @warn rule', () => { new WarnRule({ warnExpression: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@warn/**/foo;')); it('with between', () => @@ -122,7 +122,7 @@ describe('a @warn rule', () => { new WarnRule({ warnExpression: {text: 'foo'}, raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('@warn foo/**/;')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/warn-rule.ts b/pkg/sass-parser/lib/src/statement/warn-rule.ts index d45eca18d..cc2529ece 100644 --- a/pkg/sass-parser/lib/src/statement/warn-rule.ts +++ b/pkg/sass-parser/lib/src/statement/warn-rule.ts @@ -97,7 +97,7 @@ export class WarnRule this, overrides, ['raws', 'warnExpression'], - [{name: 'params', explicitUndefined: true}] + [{name: 'params', explicitUndefined: true}], ); } @@ -108,14 +108,14 @@ export class WarnRule return utils.toJSON( this, ['name', 'warnExpression', 'params', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/statement/while-rule.test.ts b/pkg/sass-parser/lib/src/statement/while-rule.test.ts index 29adbd414..473534dee 100644 --- a/pkg/sass-parser/lib/src/statement/while-rule.test.ts +++ b/pkg/sass-parser/lib/src/statement/while-rule.test.ts @@ -25,12 +25,12 @@ describe('a @while rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@while foo {}').nodes[0] as WhileRule + () => scss.parse('@while foo {}').nodes[0] as WhileRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@while foo').nodes[0] as WhileRule + () => sass.parse('@while foo').nodes[0] as WhileRule, ); describeNode( @@ -38,13 +38,13 @@ describe('a @while rule', () => { () => new WhileRule({ whileCondition: {text: 'foo'}, - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ whileCondition: {text: 'foo'}, - }) + }), ); }); @@ -70,12 +70,12 @@ describe('a @while rule', () => { describeNode( 'parsed as SCSS', - () => scss.parse('@while foo {@child}').nodes[0] as WhileRule + () => scss.parse('@while foo {@child}').nodes[0] as WhileRule, ); describeNode( 'parsed as Sass', - () => sass.parse('@while foo\n @child').nodes[0] as WhileRule + () => sass.parse('@while foo\n @child').nodes[0] as WhileRule, ); describeNode( @@ -84,20 +84,20 @@ describe('a @while rule', () => { new WhileRule({ whileCondition: {text: 'foo'}, nodes: [{name: 'child'}], - }) + }), ); describeNode('constructed from ChildProps', () => utils.fromChildProps({ whileCondition: {text: 'foo'}, nodes: [{name: 'child'}], - }) + }), ); }); describe('throws an error when assigned a new', () => { beforeEach( - () => void (node = new WhileRule({whileCondition: {text: 'foo'}})) + () => void (node = new WhileRule({whileCondition: {text: 'foo'}})), ); it('name', () => expect(() => (node.name = 'bar')).toThrow()); @@ -140,7 +140,7 @@ describe('a @while rule', () => { expect( new WhileRule({ whileCondition: {text: 'foo'}, - }).toString() + }).toString(), ).toBe('@while foo {}')); it('with afterName', () => @@ -148,7 +148,7 @@ describe('a @while rule', () => { new WhileRule({ whileCondition: {text: 'foo'}, raws: {afterName: '/**/'}, - }).toString() + }).toString(), ).toBe('@while/**/foo {}')); it('with between', () => @@ -156,7 +156,7 @@ describe('a @while rule', () => { new WhileRule({ whileCondition: {text: 'foo'}, raws: {between: '/**/'}, - }).toString() + }).toString(), ).toBe('@while foo/**/{}')); }); }); diff --git a/pkg/sass-parser/lib/src/statement/while-rule.ts b/pkg/sass-parser/lib/src/statement/while-rule.ts index 0169527de..9284454d4 100644 --- a/pkg/sass-parser/lib/src/statement/while-rule.ts +++ b/pkg/sass-parser/lib/src/statement/while-rule.ts @@ -110,14 +110,14 @@ export class WhileRule return utils.toJSON( this, ['name', 'whileCondition', 'params', 'nodes'], - inputs + inputs, ); } /** @hidden */ toString( stringifier: postcss.Stringifier | postcss.Syntax = sassParser.scss - .stringify + .stringify, ): string { return super.toString(stringifier); } diff --git a/pkg/sass-parser/lib/src/stringifier.ts b/pkg/sass-parser/lib/src/stringifier.ts index b83a3aa3c..f2d0e9fcc 100644 --- a/pkg/sass-parser/lib/src/stringifier.ts +++ b/pkg/sass-parser/lib/src/stringifier.ts @@ -63,13 +63,13 @@ export class Stringifier extends PostCssStringifier { if (!this[statement.sassType]) { throw new Error( `Unknown AST node type ${statement.sassType}. ` + - 'Maybe you need to change PostCSS stringifier.' + 'Maybe you need to change PostCSS stringifier.', ); } ( this[statement.sassType] as ( node: AnyStatement, - semicolon: boolean + semicolon: boolean, ) => void )(statement, semicolon); } @@ -104,7 +104,7 @@ export class Stringifier extends PostCssStringifier { node.nodes[0], '@at-root' + (node.raws.afterName ?? ' ') + - node.nodes[0].selectorInterpolation + node.nodes[0].selectorInterpolation, ); return; } @@ -118,7 +118,7 @@ export class Stringifier extends PostCssStringifier { } else { this.builder( start + (node.raws.between ?? '') + (semicolon ? ';' : ''), - node + node, ); } } @@ -138,7 +138,7 @@ export class Stringifier extends PostCssStringifier { (node.raws.beforeLines?.[i] ?? '') + '//' + (/[^ \t]/.test(line) ? left : '') + - line + line, ) .join('\n'); @@ -178,7 +178,7 @@ export class Stringifier extends PostCssStringifier { } else { this.builder( start + (node.raws.between ?? '') + (semicolon ? ';' : ''), - node + node, ); } } diff --git a/pkg/sass-parser/lib/src/utils.ts b/pkg/sass-parser/lib/src/utils.ts index f18f9816c..e4dafe7cc 100644 --- a/pkg/sass-parser/lib/src/utils.ts +++ b/pkg/sass-parser/lib/src/utils.ts @@ -33,7 +33,7 @@ type ClonableField = Name | ExplicitClonableField; /** Makes a {@link ClonableField} explicit. */ function parseClonableField( - field: ClonableField + field: ClonableField, ): ExplicitClonableField { return typeof field === 'string' ? {name: field} : field; } @@ -50,7 +50,7 @@ export function cloneNode>( node: T, overrides: Record | undefined, constructorFields: ClonableField[], - assignedFields?: ClonableField[] + assignedFields?: ClonableField[], ): T { // We have to do these casts because the actual `...Prop` types that get // passed in and used for the constructor aren't actually subtypes of @@ -124,7 +124,7 @@ function maybeClone(value: T): T { export function toJSON( node: T, fields: (keyof T & string)[], - inputs?: Map + inputs?: Map, ): object { // Only include the inputs field at the top level. const includeInputs = !inputs; @@ -169,7 +169,7 @@ export function toJSON( function toJsonField( field: string, value: unknown, - inputs: Map + inputs: Map, ): unknown { if (typeof value !== 'object' || value === null) { return value; @@ -211,7 +211,7 @@ export function longestCommonInitialSubstring(strings: string[]): string { } candidate = candidate.substring( 0, - Math.min(candidate.length, string.length) + Math.min(candidate.length, string.length), ); } } diff --git a/pkg/sass-parser/test/setup.ts b/pkg/sass-parser/test/setup.ts index 66cb2f8d0..cbafd0682 100644 --- a/pkg/sass-parser/test/setup.ts +++ b/pkg/sass-parser/test/setup.ts @@ -57,7 +57,7 @@ function toHaveInterpolation( this: MatcherContext, actual: unknown, property: unknown, - value: unknown + value: unknown, ): ExpectationResult { if (typeof property !== 'string') { throw new TypeError(`Property ${property} must be a string.`); @@ -70,7 +70,7 @@ function toHaveInterpolation( message: () => `expected ${printValue( this, - actual + actual, )} to have a property ${this.utils.printExpected(property)}`, pass: false, }; @@ -80,7 +80,7 @@ function toHaveInterpolation( const message = (): string => `expected (${printValue(this, actual)}).${property} ${printValue( this, - actualValue + actualValue, )} to be an Interpolation with value ${this.utils.printExpected(value)}`; if ( @@ -98,7 +98,7 @@ function toHaveInterpolation( message: () => `expected (${printValue(this, actual)}).${property} ${printValue( this, - actualValue + actualValue, )} to have the correct parent`, pass: false, }; @@ -113,14 +113,14 @@ function toHaveStringExpression( this: MatcherContext, actual: unknown, propertyOrIndex: unknown, - value: unknown + value: unknown, ): ExpectationResult { if ( typeof propertyOrIndex !== 'string' && typeof propertyOrIndex !== 'number' ) { throw new TypeError( - `Property ${propertyOrIndex} must be a string or number.` + `Property ${propertyOrIndex} must be a string or number.`, ); } else if (typeof value !== 'string') { throw new TypeError(`Value ${value} must be a string.`); @@ -140,7 +140,7 @@ function toHaveStringExpression( message: () => `expected ${printValue( this, - actual + actual, )} to have a property ${this.utils.printExpected(property)}`, pass: false, }; @@ -157,7 +157,7 @@ function toHaveStringExpression( message + ` ${printValue( this, - actualValue + actualValue, )} to be a StringExpression with value ${this.utils.printExpected(value)}` ); }; @@ -177,7 +177,7 @@ function toHaveStringExpression( message: () => `expected (${printValue(this, actual)}).${property} ${printValue( this, - actualValue + actualValue, )} to have the correct parent`, pass: false, }; @@ -202,7 +202,7 @@ expect.addSnapshotSerializer({ indentation: string, depth: number, refs: pretty.Refs, - printer: pretty.Printer + printer: pretty.Printer, ): string { if (depth !== 0) return `<${value}>`; @@ -285,7 +285,7 @@ function tersePosition(position: JsonPosition): string { if (position.offset !== position.column - 1) { throw new Error( 'Expected offset to be 1 less than column. Column is ' + - `${position.column} and offset is ${position.offset}.` + `${position.column} and offset is ${position.offset}.`, ); } diff --git a/pkg/sass-parser/test/utils.ts b/pkg/sass-parser/test/utils.ts index 1c667d62c..741be6a71 100644 --- a/pkg/sass-parser/test/utils.ts +++ b/pkg/sass-parser/test/utils.ts @@ -29,7 +29,7 @@ export function fromChildProps(props: ChildProps): T { /** Constructs a new expression from {@link props}. */ export function fromExpressionProps( - props: ExpressionProps + props: ExpressionProps, ): T { return new Interpolation({nodes: [props]}).nodes[0] as T; }