Skip to content

Commit 09f61e7

Browse files
committed
checkpoint
1 parent dcefef0 commit 09f61e7

22 files changed

+203
-65
lines changed

ava.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
export default {
2-
extensions: ['ts'],
32
files: ['!**/fixtures/**', '!**/helpers/**', '!**/rewiremock.js'],
4-
require: ['ts-node/register', './test/rewiremock.js']
3+
require: ['./test/rewiremock.cjs'],
4+
typescript: {
5+
rewritePaths: {
6+
'src/': 'dist/'
7+
},
8+
compile: false
9+
}
510
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"prepare": "husky",
3232
"prepublishOnly": "pnpm lint && pnpm build",
3333
"security": "pnpm audit --audit-level=high --prod",
34-
"test": "ava test/numeric.ts"
34+
"test": "pnpm build && ava test/numeric.ts"
3535
},
3636
"files": [
3737
"dist",
@@ -62,6 +62,7 @@
6262
"quote-unquote": "^1.0.0"
6363
},
6464
"devDependencies": {
65+
"@ava/typescript": "^6.0.0",
6566
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
6667
"@types/color-name": "^2.0.0",
6768
"@types/css-tree": "^2.3.10",

pnpm-lock.yaml

Lines changed: 100 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
// - bare parens have their own node type (upstream; css-tree)
3030
// - comparison operators are not spec compliant and not supported. e.g. `(width < 1px)`, `(width < 1px) and (width < 2px)`
3131

32-
import { parse } from './parser';
33-
import { stringify } from './stringify';
32+
import { parse } from './parser.js';
33+
import { stringify } from './stringify.js';
3434

35-
export { registerWalkers } from './walker';
35+
export { registerWalkers } from './walker.js';
3636

3737
interface Builder {
3838
(part: string, node?: Node, type?: 'start' | 'end'): void;

src/nodes/Container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111
import { Input, Container as PostCssContainer } from 'postcss';
1212

13-
import { stringify } from '../stringify';
14-
import { Node, NodeOptions } from './Node';
13+
import { stringify } from '../stringify.js';
14+
import { Node, NodeOptions } from './Node.js';
1515

1616
export class Container extends PostCssContainer {
1717
public readonly value: string = '';

src/nodes/Func.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111
import { FunctionNode } from 'css-tree';
1212

13-
import { Container } from './Container';
14-
import { NodeOptions } from './Node';
13+
import { Container } from './Container.js';
14+
import { NodeOptions } from './Node.js';
1515

1616
const reColorFunctions = /^(hsla?|hwb|lab|lch|rgba?)$/i;
1717
const reVar = /^var$/i;
@@ -20,6 +20,7 @@ export class Func extends Container {
2020
readonly isColor: boolean = false;
2121
readonly isVar: boolean = false;
2222
readonly name: string = '<unknown>';
23+
declare type: string;
2324
constructor(options: NodeOptions) {
2425
super(options);
2526
this.name = (options.node as FunctionNode).name;

src/nodes/Node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { CssNode } from 'css-tree';
1212
import { Input, Node as PostCssNode } from 'postcss';
1313

14-
import { stringify } from '../stringify';
14+
import { stringify } from '../stringify.js';
1515

1616
export interface NodeOptions {
1717
node: CssNode;

src/nodes/Numeric.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
*/
1111
import { NumberNode } from 'css-tree';
1212

13-
import { Node, NodeOptions } from './Node';
13+
import { Node, NodeOptions } from './Node.js';
1414

1515
export class Numeric extends Node {
16-
readonly unit: string;
16+
readonly unit: string = '';
17+
readonly numericValue: number = 0;
18+
declare type: string;
1719
constructor(options: NodeOptions) {
1820
super(options);
1921
this.type = 'numeric';
2022
this.unit = options.node.type === 'Dimension' ? options.node.unit : '';
21-
(this as any).value = (options.node as NumberNode).value;
23+
(this as any).value = String((options.node as NumberNode).value);
24+
(this as any).numericValue = (options.node as NumberNode).value;
2225
}
2326
}

src/nodes/Operator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
The above copyright notice and this permission notice shall be
99
included in all copies or substantial portions of this Source Code Form.
1010
*/
11-
import { Operator as OperatorNode } from 'css-tree';
1211

13-
import { Node, NodeOptions } from './Node';
12+
import { Node, NodeOptions } from './Node.js';
1413

1514
export class Operator extends Node {
15+
declare type: string;
1616
constructor(options: NodeOptions) {
1717
super(options);
1818
this.type = 'operator';
19-
(this as any).value = (options.node as OperatorNode).value;
2019
}
2120
}

0 commit comments

Comments
 (0)