Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
checkpoint
  • Loading branch information
shellscape committed Jun 27, 2025
commit 09f61e747556cc0bf18bb2af12150d19f1e29c78
9 changes: 7 additions & 2 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export default {
extensions: ['ts'],
files: ['!**/fixtures/**', '!**/helpers/**', '!**/rewiremock.js'],
require: ['ts-node/register', './test/rewiremock.js']
require: ['./test/rewiremock.cjs'],
typescript: {
rewritePaths: {
'src/': 'dist/'
},
compile: false
}
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"prepare": "husky",
"prepublishOnly": "pnpm lint && pnpm build",
"security": "pnpm audit --audit-level=high --prod",
"test": "ava test/numeric.ts"
"test": "pnpm build && ava test/numeric.ts"
},
"files": [
"dist",
Expand Down Expand Up @@ -62,6 +62,7 @@
"quote-unquote": "^1.0.0"
},
"devDependencies": {
"@ava/typescript": "^6.0.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@types/color-name": "^2.0.0",
"@types/css-tree": "^2.3.10",
Expand Down
102 changes: 100 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
// - bare parens have their own node type (upstream; css-tree)
// - comparison operators are not spec compliant and not supported. e.g. `(width < 1px)`, `(width < 1px) and (width < 2px)`

import { parse } from './parser';
import { stringify } from './stringify';
import { parse } from './parser.js';
import { stringify } from './stringify.js';

export { registerWalkers } from './walker';
export { registerWalkers } from './walker.js';

interface Builder {
(part: string, node?: Node, type?: 'start' | 'end'): void;
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
import { Input, Container as PostCssContainer } from 'postcss';

import { stringify } from '../stringify';
import { Node, NodeOptions } from './Node';
import { stringify } from '../stringify.js';
import { Node, NodeOptions } from './Node.js';

export class Container extends PostCssContainer {
public readonly value: string = '';
Expand Down
5 changes: 3 additions & 2 deletions src/nodes/Func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
import { FunctionNode } from 'css-tree';

import { Container } from './Container';
import { NodeOptions } from './Node';
import { Container } from './Container.js';
import { NodeOptions } from './Node.js';

const reColorFunctions = /^(hsla?|hwb|lab|lch|rgba?)$/i;
const reVar = /^var$/i;
Expand All @@ -20,6 +20,7 @@ export class Func extends Container {
readonly isColor: boolean = false;
readonly isVar: boolean = false;
readonly name: string = '<unknown>';
declare type: string;
constructor(options: NodeOptions) {
super(options);
this.name = (options.node as FunctionNode).name;
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { CssNode } from 'css-tree';
import { Input, Node as PostCssNode } from 'postcss';

import { stringify } from '../stringify';
import { stringify } from '../stringify.js';

export interface NodeOptions {
node: CssNode;
Expand Down
9 changes: 6 additions & 3 deletions src/nodes/Numeric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
*/
import { NumberNode } from 'css-tree';

import { Node, NodeOptions } from './Node';
import { Node, NodeOptions } from './Node.js';

export class Numeric extends Node {
readonly unit: string;
readonly unit: string = '';
readonly numericValue: number = 0;
declare type: string;
constructor(options: NodeOptions) {
super(options);
this.type = 'numeric';
this.unit = options.node.type === 'Dimension' ? options.node.unit : '';
(this as any).value = (options.node as NumberNode).value;
(this as any).value = String((options.node as NumberNode).value);
(this as any).numericValue = (options.node as NumberNode).value;
}
}
5 changes: 2 additions & 3 deletions src/nodes/Operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of this Source Code Form.
*/
import { Operator as OperatorNode } from 'css-tree';

import { Node, NodeOptions } from './Node';
import { Node, NodeOptions } from './Node.js';

export class Operator extends Node {
declare type: string;
constructor(options: NodeOptions) {
super(options);
this.type = 'operator';
(this as any).value = (options.node as OperatorNode).value;
}
}
Loading