diff --git a/pkg/sass-parser/lib/src/__snapshots__/configured-variable.test.ts.snap b/pkg/sass-parser/lib/src/__snapshots__/configured-variable.test.ts.snap
index 2b5609937..ec5132c40 100644
--- a/pkg/sass-parser/lib/src/__snapshots__/configured-variable.test.ts.snap
+++ b/pkg/sass-parser/lib/src/__snapshots__/configured-variable.test.ts.snap
@@ -11,9 +11,9 @@ exports[`a configured variable toJSON 1`] = `
"id": "",
},
],
+ "name": "baz",
"raws": {},
"sassType": "configured-variable",
"source": <1:18-1:29 in 0>,
- "variableName": "baz",
}
`;
diff --git a/pkg/sass-parser/lib/src/configuration.test.ts b/pkg/sass-parser/lib/src/configuration.test.ts
index e0f88aa6d..5882d64ee 100644
--- a/pkg/sass-parser/lib/src/configuration.test.ts
+++ b/pkg/sass-parser/lib/src/configuration.test.ts
@@ -76,7 +76,7 @@ describe('a configuration map', () => {
it('contains the variable', () => {
expect(node.size).toBe(1);
const variable = [...node.variables()][0];
- expect(variable.variableName).toEqual('bar');
+ expect(variable.name).toEqual('bar');
expect(variable).toHaveStringExpression('expression', 'baz');
});
});
@@ -101,9 +101,7 @@ describe('a configuration map', () => {
'variables array',
() =>
new Configuration({
- variables: [
- {variableName: 'bar', expression: {text: 'baz', quotes: true}},
- ],
+ variables: [{name: 'bar', expression: {text: 'baz', quotes: true}}],
}),
);
@@ -127,7 +125,7 @@ describe('a configuration map', () => {
describe('add()', () => {
test('with a ConfiguredVariable', () => {
const variable = new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
});
expect(node.add(variable)).toBe(node);
@@ -137,20 +135,20 @@ describe('a configuration map', () => {
});
test('with a ConfiguredVariableProps', () => {
- node.add({variableName: 'foo', expression: {text: 'bar', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'bar', quotes: true}});
expect(node.size).toBe(1);
const variable = node.get('foo');
- expect(variable?.variableName).toBe('foo');
+ expect(variable?.name).toBe('foo');
expect(variable).toHaveStringExpression('expression', 'bar');
expect(variable?.parent).toBe(node);
});
test('overwrites on old variable', () => {
- node.add({variableName: 'foo', expression: {text: 'old', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'old', quotes: true}});
const old = node.get('foo');
expect(old?.parent).toBe(node);
- node.add({variableName: 'foo', expression: {text: 'new', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'new', quotes: true}});
expect(node.size).toBe(1);
expect(old?.parent).toBeUndefined();
expect(node.get('foo')).toHaveStringExpression('expression', 'new');
@@ -158,8 +156,8 @@ describe('a configuration map', () => {
});
test('clear() removes all variables', () => {
- node.add({variableName: 'foo', expression: {text: 'bar', quotes: true}});
- node.add({variableName: 'baz', expression: {text: 'bang', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'bar', quotes: true}});
+ node.add({name: 'baz', expression: {text: 'bang', quotes: true}});
const foo = node.get('foo');
const bar = node.get('bar');
node.clear();
@@ -172,8 +170,8 @@ describe('a configuration map', () => {
describe('delete()', () => {
beforeEach(() => {
- node.add({variableName: 'foo', expression: {text: 'bar', quotes: true}});
- node.add({variableName: 'baz', expression: {text: 'bang', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'bar', quotes: true}});
+ node.add({name: 'baz', expression: {text: 'bang', quotes: true}});
});
test('removes a matching variable', () => {
@@ -192,12 +190,12 @@ describe('a configuration map', () => {
describe('get()', () => {
beforeEach(() => {
- node.add({variableName: 'foo', expression: {text: 'bar', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'bar', quotes: true}});
});
test('returns a variable in the configuration', () => {
const variable = node.get('foo');
- expect(variable?.variableName).toBe('foo');
+ expect(variable?.name).toBe('foo');
expect(variable).toHaveStringExpression('expression', 'bar');
});
@@ -208,7 +206,7 @@ describe('a configuration map', () => {
describe('has()', () => {
beforeEach(() => {
- node.add({variableName: 'foo', expression: {text: 'bar', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'bar', quotes: true}});
});
test('returns true for a variable in the configuration', () =>
@@ -220,7 +218,7 @@ describe('a configuration map', () => {
describe('set()', () => {
beforeEach(() => {
- node.add({variableName: 'foo', expression: {text: 'bar', quotes: true}});
+ node.add({name: 'foo', expression: {text: 'bar', quotes: true}});
});
describe('adds a new variable', () => {
@@ -233,7 +231,7 @@ describe('a configuration map', () => {
expect(node.size).toBe(2);
const variable = node.get('baz');
expect(variable?.parent).toBe(node);
- expect(variable?.variableName).toBe('baz');
+ expect(variable?.name).toBe('baz');
expect(variable).toHaveStringExpression('expression', 'bang');
});
}
@@ -285,7 +283,7 @@ describe('a configuration map', () => {
}).toString(),
).toBe('($foo: "bar", $baz: "bang",)'));
- it('with comma: true and afterValue', () =>
+ it('with comma: true and after', () =>
expect(
new Configuration({
raws: {comma: true},
@@ -293,7 +291,7 @@ describe('a configuration map', () => {
foo: {text: 'bar', quotes: true},
baz: {
expression: {text: 'bang', quotes: true},
- raws: {afterValue: '/**/'},
+ raws: {after: '/**/'},
},
},
}).toString(),
@@ -310,7 +308,7 @@ describe('a configuration map', () => {
}).toString(),
).toBe('($foo: "bar", $baz: "bang"/**/)'));
- it('with after and afterValue', () =>
+ it('with after and after', () =>
expect(
new Configuration({
raws: {after: '/**/'},
@@ -318,20 +316,20 @@ describe('a configuration map', () => {
foo: {text: 'bar', quotes: true},
baz: {
expression: {text: 'bang', quotes: true},
- raws: {afterValue: ' '},
+ raws: {after: ' '},
},
},
}).toString(),
).toBe('($foo: "bar", $baz: "bang" /**/)'));
- it('with afterValue and a guard', () =>
+ it('with after and a guard', () =>
expect(
new Configuration({
variables: {
foo: {text: 'bar', quotes: true},
baz: {
expression: {text: 'bang', quotes: true},
- raws: {afterValue: '/**/'},
+ raws: {after: '/**/'},
guarded: true,
},
},
@@ -359,10 +357,10 @@ describe('a configuration map', () => {
it('variables', () => {
expect(clone.size).toBe(2);
const variables = [...clone.variables()];
- expect(variables[0]?.variableName).toBe('foo');
+ expect(variables[0]?.name).toBe('foo');
expect(variables[0]?.parent).toBe(clone);
expect(variables[0]).toHaveStringExpression('expression', 'bar');
- expect(variables[1]?.variableName).toBe('baz');
+ expect(variables[1]?.name).toBe('baz');
expect(variables[1]?.parent).toBe(clone);
expect(variables[1]).toHaveStringExpression('expression', 'bang');
});
@@ -399,7 +397,7 @@ describe('a configuration map', () => {
});
expect(clone.size).toBe(1);
const variables = [...clone.variables()];
- expect(variables[0]?.variableName).toBe('zip');
+ expect(variables[0]?.name).toBe('zip');
expect(variables[0]?.parent).toBe(clone);
expect(variables[0]).toHaveStringExpression('expression', 'zap');
});
@@ -408,10 +406,10 @@ describe('a configuration map', () => {
const clone = original.clone({variables: undefined});
expect(clone.size).toBe(2);
const variables = [...clone.variables()];
- expect(variables[0]?.variableName).toBe('foo');
+ expect(variables[0]?.name).toBe('foo');
expect(variables[0]?.parent).toBe(clone);
expect(variables[0]).toHaveStringExpression('expression', 'bar');
- expect(variables[1]?.variableName).toBe('baz');
+ expect(variables[1]?.name).toBe('baz');
expect(variables[1]?.parent).toBe(clone);
expect(variables[1]).toHaveStringExpression('expression', 'bang');
});
diff --git a/pkg/sass-parser/lib/src/configuration.ts b/pkg/sass-parser/lib/src/configuration.ts
index e9c025563..46f67130d 100644
--- a/pkg/sass-parser/lib/src/configuration.ts
+++ b/pkg/sass-parser/lib/src/configuration.ts
@@ -101,9 +101,9 @@ export class Configuration extends Node {
const realVariable =
'sassType' in variable ? variable : new ConfiguredVariable(variable);
realVariable.parent = this;
- const old = this._variables.get(realVariable.variableName);
+ const old = this._variables.get(realVariable.name);
if (old) old.parent = undefined;
- this._variables.set(realVariable.variableName, realVariable);
+ this._variables.set(realVariable.name, realVariable);
return this;
}
@@ -189,7 +189,7 @@ export class Configuration extends Node {
result += variable.raws.before ?? ' ';
}
result += variable.toString();
- result += variable.raws.afterValue ?? '';
+ result += variable.raws.after ?? '';
}
return result + `${this.raws.comma ? ',' : ''}${this.raws.after ?? ''})`;
}
diff --git a/pkg/sass-parser/lib/src/configured-variable.test.ts b/pkg/sass-parser/lib/src/configured-variable.test.ts
index c673670a8..d9e06a3af 100644
--- a/pkg/sass-parser/lib/src/configured-variable.test.ts
+++ b/pkg/sass-parser/lib/src/configured-variable.test.ts
@@ -9,7 +9,7 @@ describe('a configured variable', () => {
beforeEach(
() =>
void (node = new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
})),
);
@@ -25,7 +25,7 @@ describe('a configured variable', () => {
it('has a sassType', () =>
expect(node.sassType.toString()).toBe('configured-variable'));
- it('has a name', () => expect(node.variableName).toBe('foo'));
+ it('has a name', () => expect(node.name).toBe('foo'));
it('has a value', () =>
expect(node).toHaveStringExpression('expression', 'bar'));
@@ -92,7 +92,7 @@ describe('a configured variable', () => {
'with an expression',
() =>
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: new StringExpression({text: 'bar', quotes: true}),
}),
);
@@ -101,7 +101,7 @@ describe('a configured variable', () => {
'with ExpressionProps',
() =>
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
}),
);
@@ -120,7 +120,7 @@ describe('a configured variable', () => {
it('has a sassType', () =>
expect(node.sassType.toString()).toBe('configured-variable'));
- it('has a name', () => expect(node.variableName).toBe('foo'));
+ it('has a name', () => expect(node.name).toBe('foo'));
it('has a value', () =>
expect(node).toHaveStringExpression('expression', 'bar'));
@@ -177,7 +177,7 @@ describe('a configured variable', () => {
'with an expression',
() =>
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: new StringExpression({text: 'bar', quotes: true}),
guarded: true,
}),
@@ -187,7 +187,7 @@ describe('a configured variable', () => {
'with ExpressionProps',
() =>
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
guarded: true,
}),
@@ -196,9 +196,9 @@ describe('a configured variable', () => {
});
});
- it('assigned a new variableName', () => {
- node.variableName = 'baz';
- expect(node.variableName).toBe('baz');
+ it('assigned a new name', () => {
+ node.name = 'baz';
+ expect(node.name).toBe('baz');
});
it('assigned a new expression', () => {
@@ -219,7 +219,7 @@ describe('a configured variable', () => {
it('unguarded', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
}).toString(),
).toBe('$foo: "bar"'));
@@ -227,7 +227,7 @@ describe('a configured variable', () => {
it('guarded', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
guarded: true,
}).toString(),
@@ -236,7 +236,7 @@ describe('a configured variable', () => {
it('with a non-identifier name', () =>
expect(
new ConfiguredVariable({
- variableName: 'f o',
+ name: 'f o',
expression: {text: 'bar', quotes: true},
}).toString(),
).toBe('$f\\20o: "bar"'));
@@ -246,7 +246,7 @@ describe('a configured variable', () => {
it('ignores before', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
raws: {before: '/**/'},
}).toString(),
@@ -255,25 +255,25 @@ describe('a configured variable', () => {
it('with matching name', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
- raws: {variableName: {raw: 'f\\6fo', value: 'foo'}},
+ raws: {name: {raw: 'f\\6fo', value: 'foo'}},
}).toString(),
).toBe('$f\\6fo: "bar"'));
it('with non-matching name', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
- raws: {variableName: {raw: 'f\\41o', value: 'fao'}},
+ raws: {name: {raw: 'f\\41o', value: 'fao'}},
}).toString(),
).toBe('$foo: "bar"'));
it('with between', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
raws: {between: ' : '},
}).toString(),
@@ -282,7 +282,7 @@ describe('a configured variable', () => {
it('with beforeGuard and a guard', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
guarded: true,
raws: {beforeGuard: '/**/'},
@@ -292,30 +292,30 @@ describe('a configured variable', () => {
it('with beforeGuard and no guard', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
raws: {beforeGuard: '/**/'},
}).toString(),
).toBe('$foo: "bar"'));
// raws.before is only used as part of a Configuration
- describe('ignores afterValue', () => {
+ describe('ignores after', () => {
it('with no guard', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
- raws: {afterValue: '/**/'},
+ raws: {after: '/**/'},
}).toString(),
).toBe('$foo: "bar"'));
it('with a guard', () =>
expect(
new ConfiguredVariable({
- variableName: 'foo',
+ name: 'foo',
expression: {text: 'bar', quotes: true},
guarded: true,
- raws: {afterValue: '/**/'},
+ raws: {after: '/**/'},
}).toString(),
).toBe('$foo: "bar" !default'));
});
@@ -336,7 +336,7 @@ describe('a configured variable', () => {
beforeEach(() => void (clone = original.clone()));
describe('has the same properties:', () => {
- it('variableName', () => expect(clone.variableName).toBe('foo'));
+ it('name', () => expect(clone.name).toBe('foo'));
it('expression', () =>
expect(clone).toHaveStringExpression('expression', 'bar'));
@@ -366,16 +366,12 @@ describe('a configured variable', () => {
}));
});
- describe('variableName', () => {
+ describe('name', () => {
it('defined', () =>
- expect(original.clone({variableName: 'baz'}).variableName).toBe(
- 'baz',
- ));
+ expect(original.clone({name: 'baz'}).name).toBe('baz'));
it('undefined', () =>
- expect(original.clone({variableName: undefined}).variableName).toBe(
- 'foo',
- ));
+ expect(original.clone({name: undefined}).name).toBe('foo'));
});
describe('expression', () => {
diff --git a/pkg/sass-parser/lib/src/configured-variable.ts b/pkg/sass-parser/lib/src/configured-variable.ts
index 17dcea6f7..7565ad056 100644
--- a/pkg/sass-parser/lib/src/configured-variable.ts
+++ b/pkg/sass-parser/lib/src/configured-variable.ts
@@ -29,7 +29,7 @@ export interface ConfiguredVariableRaws {
* This may be different than {@link ConfiguredVariable.variable} if the name
* contains escape codes or underscores.
*/
- variableName?: RawWithValue;
+ name?: RawWithValue;
/** The whitespace and colon between the variable name and value. */
between?: string;
@@ -44,7 +44,7 @@ export interface ConfiguredVariableRaws {
* The space symbols between the end of the variable declaration and the comma
* afterwards. Always empty for a variable that doesn't have a trailing comma.
*/
- afterValue?: string;
+ after?: string;
}
/**
@@ -55,7 +55,7 @@ export interface ConfiguredVariableRaws {
*/
export interface ConfiguredVariableObjectProps {
raws?: ConfiguredVariableRaws;
- variableName: string;
+ name: string;
expression: Expression | ExpressionProps;
guarded?: boolean;
}
@@ -72,7 +72,7 @@ export interface ConfiguredVariableObjectProps {
export type ConfiguredVariableExpressionProps =
| Expression
| ExpressionProps
- | Omit;
+ | Omit;
/**
* The initializer properties for {@link ConfiguredVariable}.
@@ -100,7 +100,7 @@ export class ConfiguredVariable extends Node {
* This is the parsed and normalized value, with underscores converted to
* hyphens and escapes resolved to the characters they represent.
*/
- variableName!: string;
+ name!: string;
/** The expresison whose value the variable is assigned. */
get expression(): Expression {
@@ -125,14 +125,14 @@ export class ConfiguredVariable extends Node {
inner?: sassInternal.ConfiguredVariable,
) {
if (Array.isArray(defaults!)) {
- const [variableName, rest] = defaults;
+ const [name, rest] = defaults;
if ('sassType' in rest || !('expression' in rest)) {
defaults = {
- variableName,
+ name,
expression: rest as Expression | ExpressionProps,
};
} else {
- defaults = {variableName, ...rest};
+ defaults = {name, ...rest};
}
}
super(defaults);
@@ -140,7 +140,7 @@ export class ConfiguredVariable extends Node {
if (inner) {
this.source = new LazySource(inner);
- this.variableName = inner.name;
+ this.name = inner.name;
this.expression = convertExpression(inner.expression);
this.guarded = inner.isGuarded;
} else {
@@ -151,7 +151,7 @@ export class ConfiguredVariable extends Node {
clone(overrides?: Partial): this {
return utils.cloneNode(this, overrides, [
'raws',
- 'variableName',
+ 'name',
'expression',
'guarded',
]);
@@ -161,20 +161,16 @@ export class ConfiguredVariable extends Node {
/** @hidden */
toJSON(_: string, inputs: Map): object;
toJSON(_?: string, inputs?: Map): object {
- return utils.toJSON(
- this,
- ['variableName', 'expression', 'guarded'],
- inputs,
- );
+ return utils.toJSON(this, ['name', 'expression', 'guarded'], inputs);
}
/** @hidden */
toString(): string {
return (
'$' +
- (this.raws.variableName?.value === this.variableName
- ? this.raws.variableName.raw
- : sassInternal.toCssIdentifier(this.variableName)) +
+ (this.raws.name?.value === this.name
+ ? this.raws.name.raw
+ : sassInternal.toCssIdentifier(this.name)) +
(this.raws.between ?? ': ') +
this.expression +
(this.guarded ? `${this.raws.beforeGuard ?? ' '}!default` : '')
diff --git a/pkg/sass-parser/lib/src/statement/forward-rule.test.ts b/pkg/sass-parser/lib/src/statement/forward-rule.test.ts
index 56f22600c..08a81f843 100644
--- a/pkg/sass-parser/lib/src/statement/forward-rule.test.ts
+++ b/pkg/sass-parser/lib/src/statement/forward-rule.test.ts
@@ -291,7 +291,7 @@ describe('a @forward rule', () => {
expect(node.configuration.size).toBe(1);
expect(node.configuration.parent).toBe(node);
const variables = [...node.configuration.variables()];
- expect(variables[0].variableName).toBe('baz');
+ expect(variables[0].name).toBe('baz');
expect(variables[0]).toHaveStringExpression('expression', 'qux');
});
@@ -714,7 +714,7 @@ describe('a @forward rule', () => {
expect(clone.configuration.size).toBe(1);
expect(clone.configuration.parent).toBe(clone);
const variables = [...clone.configuration.variables()];
- expect(variables[0].variableName).toBe('zip');
+ expect(variables[0].name).toBe('zip');
expect(variables[0]).toHaveStringExpression('expression', 'zap');
});
@@ -912,7 +912,7 @@ describe('a @forward rule', () => {
expect(clone.configuration.size).toBe(1);
expect(clone.configuration.parent).toBe(clone);
const variables = [...clone.configuration.variables()];
- expect(variables[0].variableName).toBe('zip');
+ expect(variables[0].name).toBe('zip');
expect(variables[0]).toHaveStringExpression('expression', 'zap');
});
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 fa079fb76..2786a3033 100644
--- a/pkg/sass-parser/lib/src/statement/use-rule.test.ts
+++ b/pkg/sass-parser/lib/src/statement/use-rule.test.ts
@@ -134,7 +134,7 @@ describe('a @use rule', () => {
expect(node.configuration.size).toBe(1);
expect(node.configuration.parent).toBe(node);
const variables = [...node.configuration.variables()];
- expect(variables[0].variableName).toBe('baz');
+ expect(variables[0].name).toBe('baz');
expect(variables[0]).toHaveStringExpression('expression', 'qux');
});
@@ -418,7 +418,7 @@ describe('a @use rule', () => {
expect(clone.configuration.size).toBe(1);
expect(clone.configuration.parent).toBe(clone);
const variables = [...clone.configuration.variables()];
- expect(variables[0].variableName).toBe('baz');
+ expect(variables[0].name).toBe('baz');
expect(variables[0]).toHaveStringExpression('expression', 'qux');
});
@@ -536,7 +536,7 @@ describe('a @use rule', () => {
expect(clone.configuration.size).toBe(1);
expect(clone.configuration.parent).toBe(clone);
const variables = [...clone.configuration.variables()];
- expect(variables[0].variableName).toBe('baz');
+ expect(variables[0].name).toBe('baz');
expect(variables[0]).toHaveStringExpression('expression', 'qux');
});