Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: csstree/csstree
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: eslint/csstree
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 44 files changed
  • 2 contributors

Commits on Mar 3, 2025

  1. feat: Rename to @eslint/css-tree (#1)

    * feat: Rename to @eslint/css-tree
    
    * Update references
    
    * Update package.json
    
    Co-authored-by: Francesco Trotta <github@fasttime.org>
    
    * Revert CHANGELOG changes
    
    * Update module names in script
    
    * Update package-lock.json
    
    ---------
    
    Co-authored-by: Francesco Trotta <github@fasttime.org>
    nzakas and fasttime authored Mar 3, 2025
    Copy the full SHA
    6f20a43 View commit details
Showing with 146 additions and 140 deletions.
  1. +1 −0 LICENSE
  2. +27 −25 README.md
  3. +13 −13 docs/definition-syntax.md
  4. +5 −5 docs/generate.md
  5. +15 −15 docs/parsing.md
  6. +14 −14 docs/traversal.md
  7. +7 −7 docs/utils.md
  8. +1 −1 lib/__tests/clone.js
  9. +1 −1 lib/__tests/common.js
  10. +1 −1 lib/__tests/convert.js
  11. +1 −1 lib/__tests/decode-encode.js
  12. +1 −1 lib/__tests/definition-syntax-generate.js
  13. +1 −1 lib/__tests/definition-syntax-match.js
  14. +1 −1 lib/__tests/definition-syntax-parse.js
  15. +1 −1 lib/__tests/definition-syntax-walk.js
  16. +12 −12 lib/__tests/exports.js
  17. +1 −1 lib/__tests/find.js
  18. +1 −1 lib/__tests/fixture/definition-syntax.js
  19. +1 −1 lib/__tests/fixture/generate-auto-emit-ws.js
  20. +1 −1 lib/__tests/generate.js
  21. +1 −1 lib/__tests/lexer-check-atrule-descriptor.js
  22. +1 −1 lib/__tests/lexer-check-atrule-name.js
  23. +1 −1 lib/__tests/lexer-check-atrule-prelude.js
  24. +1 −1 lib/__tests/lexer-check-property-name.js
  25. +1 −1 lib/__tests/lexer-check-structure.js
  26. +1 −1 lib/__tests/lexer-match-atrule-descriptor.js
  27. +1 −1 lib/__tests/lexer-match-atrule-prelude.js
  28. +1 −1 lib/__tests/lexer-match-property.js
  29. +1 −1 lib/__tests/lexer-match-result.js
  30. +1 −1 lib/__tests/lexer-match-type.js
  31. +1 −1 lib/__tests/lexer-match.js
  32. +1 −1 lib/__tests/lexer-search-fragments.js
  33. +1 −1 lib/__tests/lexer.js
  34. +1 −1 lib/__tests/list.js
  35. +1 −1 lib/__tests/names.js
  36. +1 −1 lib/__tests/parse-extension.js
  37. +1 −1 lib/__tests/parse-selector.js
  38. +1 −1 lib/__tests/parse.js
  39. +1 −1 lib/__tests/tokenizer.js
  40. +1 −1 lib/__tests/walk.js
  41. +2 −2 package-lock.json
  42. +5 −2 package.json
  43. +12 −12 scripts/esm-to-cjs.cjs
  44. +1 −1 scripts/generate-safe/fixture.js
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (C) 2016-2024 by Roman Dvornov
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<img align="right" width="111" height="111" alt="CSSTree logo" src="assets/csstree-logo-rounded.svg" />

# CSSTree

[![NPM version](https://img.shields.io/npm/v/css-tree.svg)](https://www.npmjs.com/package/css-tree)
[![Build Status](https://github.com/csstree/csstree/actions/workflows/build.yml/badge.svg)](https://github.com/csstree/csstree/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/github/csstree/csstree/badge.svg?branch=master)](https://coveralls.io/github/csstree/csstree?branch=master)
[![NPM Downloads](https://img.shields.io/npm/dm/css-tree.svg)](https://www.npmjs.com/package/css-tree)
[![Twitter](https://img.shields.io/badge/Twitter-@csstree-blue.svg)](https://twitter.com/csstree)
# CSSTree (ESLint Fork)

CSSTree is a tool set for CSS: [fast](https://github.com/postcss/benchmark) detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations. The main goal is to be efficient and W3C spec compliant, with focus on CSS analyzing and source-to-source transforming tasks.

@@ -90,13 +84,13 @@ CSSTree is a tool set for CSS: [fast](https://github.com/postcss/benchmark) deta
Install with npm:

```
npm install css-tree
npm install @eslint/css-tree
```

Basic usage:

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

// parse CSS to AST
const ast = csstree.parse('.example { world: "!" }');
@@ -136,17 +130,17 @@ console.log(matchResult.getTrace(ast.children.first));

### Exports

Is it possible to import just a needed part of library like a parser or a walker. That's might useful for loading time or bundle size optimisations.
Is it possible to import just a needed part of library like a parser or a walker. That's might useful for loading time or bundle size optimisations.

```js
import * as tokenizer from 'css-tree/tokenizer';
import * as parser from 'css-tree/parser';
import * as walker from 'css-tree/walker';
import * as lexer from 'css-tree/lexer';
import * as definitionSyntax from 'css-tree/definition-syntax';
import * as data from 'css-tree/definition-syntax-data';
import * as dataPatch from 'css-tree/definition-syntax-data-patch';
import * as utils from 'css-tree/utils';
import * as tokenizer from '@eslint/css-tree/tokenizer';
import * as parser from '@eslint/css-tree/parser';
import * as walker from '@eslint/css-tree/walker';
import * as lexer from '@eslint/css-tree/lexer';
import * as definitionSyntax from '@eslint/css-tree/definition-syntax';
import * as data from '@eslint/css-tree/definition-syntax-data';
import * as dataPatch from '@eslint/css-tree/definition-syntax-data-patch';
import * as utils from '@eslint/css-tree/utils';
```

### Using in a browser
@@ -155,7 +149,7 @@ Bundles are available for use in a browser:

- `dist/csstree.js` – minified IIFE with `csstree` as global
```html
<script src="node_modules/css-tree/dist/csstree.js"></script>
<script src="node_modules/@eslint/css-tree/dist/csstree.js"></script>
<script>
csstree.parse('.example { color: green }');
</script>
@@ -164,7 +158,7 @@ Bundles are available for use in a browser:
- `dist/csstree.esm.js` – minified ES module
```html
<script type="module">
import { parse } from 'node_modules/css-tree/dist/csstree.esm.js'
import { parse } from 'node_modules/@eslint/css-tree/dist/csstree.esm.js'
parse('.example { color: green }');
</script>
```
@@ -174,19 +168,27 @@ One of CDN services like `unpkg` or `jsDelivr` can be used. By default (for shor
```html
<!-- ESM -->
<script type="module">
import * as csstree from 'https://cdn.jsdelivr.net/npm/css-tree';
import * as csstree from 'https://unpkg.com/css-tree';
import * as csstree from 'https://cdn.jsdelivr.net/npm/@eslint/css-tree';
import * as csstree from 'https://unpkg.com/@eslint/css-tree';
</script>

<!-- IIFE with an export to global -->
<script src="https://cdn.jsdelivr.net/npm/css-tree/dist/csstree.js"></script>
<script src="https://unpkg.com/css-tree/dist/csstree.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@eslint/css-tree/dist/csstree.js"></script>
<script src="https://unpkg.com/@eslint/css-tree/dist/csstree.js"></script>
```

## Top level API

![API map](https://cdn.rawgit.com/csstree/csstree/aaf327e/docs/api-map.svg)
![API map](https://cdn.rawgit.com/eslint/csstree/aaf327e/docs/api-map.svg)

## License

MIT


## Branch Setup and Development

* `main` - the default branch for new development in the fork repo
* `upstream` - kept in sync with `csstree/csstree`

When merging in changes from `csstree/csstree`, sync `upstream` in the GitHub UI (if possible). Then send a pull request to `main` to work through any merge conflicts.
26 changes: 13 additions & 13 deletions docs/definition-syntax.md
Original file line number Diff line number Diff line change
@@ -28,15 +28,15 @@ This article describes API to work with [Value Definition Syntax](https://www.w3

Arguments:

- **source**: `string`
- **source**: `string`
A definition to parse

```js
import { definitionSyntax } from 'css-tree';
import { definitionSyntax } from '@eslint/css-tree';

definitionSyntax.parse('foo | bar');
// { Group
// terms:
// terms:
// [ { Keyword name: 'foo' },
// { Keyword name: 'bar' } ],
// combinator: '|',
@@ -48,15 +48,15 @@ definitionSyntax.parse('foo | bar');

Arguments:

- **node**: `Object`
- **node**: `Object`
AST node
- **options**: `{ enter?: function, leave?: function }` or `function`
- **options**: `{ enter?: function, leave?: function }` or `function`
An object to specify enter and/or leave handlers. When value is a function, it treated as `{ enter: function }`. One of handlers is required.
- **context** (optional): `any`
- **context** (optional): `any`
Defines a value as `this` in enter and leave handlers.

```js
import { definitionSyntax } from 'css-tree';
import { definitionSyntax } from '@eslint/css-tree';

const ast = definitionSyntax.parse('foo | bar');

@@ -85,19 +85,19 @@ definitionSyntax.walk(ast, node =>

## generate(node, options)

- **node**: `Object`
- **node**: `Object`
AST node to generate a string from
- **options** (optional): `Object`
- **options** (optional): `Object`
An object to specify output behaviour (all options are optional):
- **forceBraces**: `Boolean` (default: `false`)
- **forceBraces**: `Boolean` (default: `false`)
Enforce printing brackets for any groups (even implicit). Useful for debugging and priority revelation.
- **compact**: `Boolean` (default: `false`)
- **compact**: `Boolean` (default: `false`)
Avoid formatting (primary whitespaces around brackets and so on) when possible.
- **decorate**: `function(nodeGenerateResult, node)`
- **decorate**: `function(nodeGenerateResult, node)`
A function to post-process result of node translation to a string. Handy to make some kind of result wrapping.

```js
import { definitionSyntax } from 'css-tree';
import { definitionSyntax } from '@eslint/css-tree';

const ast = definitionSyntax.parse('foo && bar || [ baz | qux ]');

10 changes: 5 additions & 5 deletions docs/generate.md
Original file line number Diff line number Diff line change
@@ -26,13 +26,13 @@ Options (optional):

### sourceMap

Type: `boolean`
Type: `boolean`
Default: `false`

Generates a source map (nodes should contain positions in `loc` property). Note, that an object instead of string is returned in that case.

```js
import { parse, generate } from 'css-tree';
import { parse, generate } from '@eslint/css-tree';

const ast = parse('.test { color: red }', {
filename: 'my.css',
@@ -45,14 +45,14 @@ const result = generate(ast, { sourceMap: true });

### decorator

Type: `function`
Type: `function`
Default: none

A function that returns handlers used by a generator. TBD

### mode

Type: `"spec"` or `"safe"`
Type: `"spec"` or `"safe"`
Default: `"safe"`

CSS Syntax Module defines [rules for CSS serialization](https://www.w3.org/TR/css-syntax-3/#serialization) that it must "round-trip" with parsing. The generator follows these rules and determines itself when to output the space to avoid unintended CSS tokens combining. However, some older browsers fail to parse the resulting CSS because they didn't follow the spec in some cases. For this reason, the generator supports two modes:
@@ -61,7 +61,7 @@ CSS Syntax Module defines [rules for CSS serialization](https://www.w3.org/TR/cs
- `spec` which completely follows the spec.

```js
import { parse, generate } from 'css-tree';
import { parse, generate } from '@eslint/css-tree';

const ast = parse('a { border: calc(1px) solid #ff0000 }');

30 changes: 15 additions & 15 deletions docs/parsing.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
Parses CSS into AST.

```js
import { parse } from 'css-tree';
import { parse } from '@eslint/css-tree';

// simple parsing with no options
const ast = parse('.example { color: red }');
@@ -42,7 +42,7 @@ Options (optional):

### context

Type: `string`
Type: `string`
Default: `'stylesheet'`

Defines what part of CSS is parsing.
@@ -64,21 +64,21 @@ Contexts:

### atrule

Type: `string` or `null`
Type: `string` or `null`
Default: `null`

Using for `atrulePrelude` context to apply atrule specific parse rules.

### positions

Type: `boolean`
Type: `boolean`
Default: `false`

Specify to store locations of node content in original source. Location is storing as `loc` field of nodes. `loc` property is always `null` when this option is `false`. See structure of [`loc`](ast.md#loc) in AST format description.

### onParseError

Type: `function(error, fallbackNode)` or `null`
Type: `function(error, fallbackNode)` or `null`
Default: `null`

Parsing is tolerant by default, i.e. any text may to be parsed with no an raised exception. However, mistakes in CSS may make it imposible to parse some part, e.g. a selector or declaration. In that case bad content is wrapping into a `Raw` node and `onParseError` is invoking.
@@ -99,49 +99,49 @@ csstree.parse('example { foo; bar: 1! }', {

### onComment

Type: `function(value, loc)` or `null`
Type: `function(value, loc)` or `null`
Default: `null`

A handler to call for every comment in parsing source. Value is passing without surrounding `/*` and `*/`. [`loc`](ast.md#loc) will be `null` until `positions` option is set to `true`.

### onToken

Type: `function(type, start, end, index)` or `Array` or `null`
Type: `function(type, start, end, index)` or `Array` or `null`
Default: `null`

When a function, `onToken` is a handler to call for every token in the parsing source. The arguments are the numeric type of the token, the start offset, the end offset, and the token index. When an array, `onToken` is populated with objects containing the numeric type of the token (`type`), the start offset (`start`), and the end offset (`end`).

### filename

Type: `string`
Type: `string`
Default: `'<unknown>'`

Filename of source. This value adds to [`loc`](ast.md#loc) as `source` property when `positions` option is `true`. Using for source map generation.

### offset

Type: `number`
Type: `number`
Default: `0`

Start offset. Useful when parsing a fragment of CSS to store a correct positions for node's [`loc`](ast.md#loc) property.

### line

Type: `number`
Type: `number`
Default: `1`

Start line number. Useful when parsing fragment of CSS to store correct positions in node's [`loc`](ast.md#loc) property.

### column

Type: `number`
Type: `number`
Default: `1`

Start column number. Useful when parsing fragment of CSS to store correct positions in node's `loc` property.

### parseAtrulePrelude

Type: `boolean`
Type: `boolean`
Default: `true`

Defines to parse an at-rule prelude in details (represents as `AtruleExpresion`, `MediaQueryList` or `SelectorList` if any). Otherwise, represents prelude as `Raw` node.
@@ -187,7 +187,7 @@ csstree.parse('@example 1 2;', {

### parseRulePrelude

Type: `boolean`
Type: `boolean`
Default: `true`

Defines to parse a rule prelude in details or left unparsed (represents as `Raw` node).
@@ -241,7 +241,7 @@ csstree.parse('.foo {}', {

### parseValue

Type: `boolean`
Type: `boolean`
Default: `true`

Defines to parse a declaration value in details (represents as `Value`). Otherwise represents value as `Raw` node.
@@ -282,7 +282,7 @@ csstree.parse('color: #aabbcc', {

### parseCustomProperty

Type: `boolean`
Type: `boolean`
Default: `false`

Defines to parse a custom property value and a `var()` fallback in details (represents as `Value`). Otherwise represents value as `Raw` node.
28 changes: 14 additions & 14 deletions docs/traversal.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
Method visits each node of passed AST in a natural way and calls handlers for each one. It takes two arguments: a root node (`ast`) and an object (`options`). In simple case, it may take a function (handler) instead of `options` (`walk(ast, fn)` is equivalent to `walk(ast, { enter: fn })`).

```js
import { parse, walk } from 'css-tree';
import { parse, walk } from '@eslint/css-tree';

const ast = parse('.a { color: red; }');

@@ -67,13 +67,13 @@ Options:

### enter

Type: `function` or `undefined`
Type: `function` or `undefined`
Default: `undefined`

Handler on node entrance, i.e. before any nested node is processed.

```js
import { parse, walk } from 'css-tree';
import { parse, walk } from '@eslint/css-tree';

const ast = parse('.a { color: red; }');

@@ -103,7 +103,7 @@ Handler receives three arguments:
> NOTE: If `children` is an array, the last two arguments are `index` and `array`, like for `Array#forEach()` or `Array#map()` methods.
```js
import { parse, walk, generate } from 'css-tree';
import { parse, walk, generate } from '@eslint/css-tree';

const ast = parse(`
.a { foo: 1; bar: 2; }
@@ -140,7 +140,7 @@ Context (`this`) for a handler is an object with a references to the closest anc
- `function` – refers to closest `Function`, `PseudoClassSelector` or `PseudoElementSelector` node if current node inside one of them

```js
import { parse, walk } from 'css-tree';
import { parse, walk } from '@eslint/css-tree';

const ast = parse(`
@import url(import.css);
@@ -163,13 +163,13 @@ console.log(urls);

### leave

Type: `function` or `undefined`
Type: `function` or `undefined`
Default: `undefined`

The same as `enter` handler but invokes on node exit, i.e. after all nested nodes are processed.

```js
import { parse, walk } from 'css-tree';
import { parse, walk } from '@eslint/css-tree';

const ast = parse('.a { color: red; }');

@@ -191,13 +191,13 @@ walk(ast, {

### visit

Type: `string` or `null`
Type: `string` or `null`
Default: `null`

Invokes a handler for a specified node type only.

```js
import { parse, walk } from 'css-tree';
import { parse, walk } from '@eslint/css-tree';

const ast = parse('.a { color: red; } .b { color: green; }');

@@ -228,15 +228,15 @@ The traversal for some node types can perform faster (10-15 times depending on t
### reverse

Type: `boolean`
Type: `boolean`
Default: `false`

Inverts the natural order of node traversing:
- node's properties are iterated in reverse order to the node's `structure` definition
- children nodes are iterated from last to first

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

const ast = csstree.parse('.a { color: red; }');

@@ -301,7 +301,7 @@ csstree.walk(ast, {
Returns the first node in natural order for which `fn` function returns a truthy value.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

const ast = csstree.parse('.a { color: red; } .b { color: green; }');

@@ -318,7 +318,7 @@ console.log(csstree.generate(firstColorDeclaration));
Returns the first node in reverse order for which `fn` function returns a truthy value.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

const ast = csstree.parse('.a { color: red; } .b { color: green; }');

@@ -335,7 +335,7 @@ console.log(csstree.generate(firstColorDeclaration));
Returns all nodes in natural order for which `fn` function returns a truthy value.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

const ast = csstree.parse('.a { color: red; } .b { color: green; }');

14 changes: 7 additions & 7 deletions docs/utils.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
Returns details for a property name, such as vendor prefix, used hack etc. Using for safe test of declaration property names, i.e. `Declaration.property`.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

csstree.property('*-vendor-property');
// {
@@ -72,7 +72,7 @@ Supported hacks:
Mostly the same as `property()` function, but without hack detection. Using for any identifier except declaration property name.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

csstree.keyword('-vendor-keyword');
// {
@@ -89,7 +89,7 @@ csstree.keyword('-vendor-keyword');
Decode and encode of `ident` token values.

```js
import { ident } from 'css-tree';
import { ident } from '@eslint/css-tree';

ident.decode('hello\\9 \\ world') // hello\t world
ident.encode('hello\t world') // hello\9 \ world
@@ -100,7 +100,7 @@ ident.encode('hello\t world') // hello\9 \ world
Decode and encode of `string` token values.

```js
import { string } from 'css-tree';
import { string } from '@eslint/css-tree';

string.decode('"hello\\9 \\"world\\""') // hello\t "world"
string.decode('\'hello\\9 "world"\'') // hello\t "world"
@@ -113,7 +113,7 @@ string.encode('hello\t "world"', true) // 'hello\9 "world"'
Decode and encode of `url` token values.

```js
import { url } from 'css-tree';
import { url } from '@eslint/css-tree';

url.decode('url(file\ \(1\).ext)') // file (1).ext
url.encode('file (1).ext') // url(file\ \(1\).ext)
@@ -146,7 +146,7 @@ console.log(csstree.generate(copy));
`fromPlainObject()` walks through AST and coverts each `children` value into a `List` instance when value is an array.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

const ast = {
type: 'SelectorList',
@@ -173,7 +173,7 @@ astClone = csstree.fromPlainObject(csstree.clone(ast));
`fromPlainObject()` walks through AST and coverts each `children` value to regular array when value is a `List` instance.

```js
import * as csstree from 'css-tree';
import * as csstree from '@eslint/css-tree';

const ast = {
type: 'SelectorList',
2 changes: 1 addition & 1 deletion lib/__tests/clone.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import {
clone,
walk,
toPlainObject
} from 'css-tree';
} from '@eslint/css-tree';

function createCloneTest(name, getAst) {
it(name, () => {
2 changes: 1 addition & 1 deletion lib/__tests/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import assert from 'assert';
import { parse, walk, fork, version, tokenTypes, generate } from 'css-tree';
import { parse, walk, fork, version, tokenTypes, generate } from '@eslint/css-tree';

const fixtureFilename = './fixtures/stringify.css';
const fixture = normalize(fs.readFileSync(fixtureFilename, 'utf-8'));;
2 changes: 1 addition & 1 deletion lib/__tests/convert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, generate, fromPlainObject, toPlainObject } from 'css-tree';
import { parse, generate, fromPlainObject, toPlainObject } from '@eslint/css-tree';

const css = '.test{a:123}';

2 changes: 1 addition & 1 deletion lib/__tests/decode-encode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { ident, string, url } from 'css-tree';
import { ident, string, url } from '@eslint/css-tree';

function forEachTest(tests, func) {
Object.keys(tests).forEach((from, idx) => {
2 changes: 1 addition & 1 deletion lib/__tests/definition-syntax-generate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer, definitionSyntax } from 'css-tree';
import { lexer, definitionSyntax } from '@eslint/css-tree';
import { tests } from './fixture/definition-syntax.js';

const { parse, generate } = definitionSyntax;
2 changes: 1 addition & 1 deletion lib/__tests/definition-syntax-match.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer } from 'css-tree';
import { lexer } from '@eslint/css-tree';
import prepareTokens from '../lexer/prepare-tokens.js';
import { createGenericTypes } from '../lexer/generic.js';
import * as units from '../lexer/units.js';
2 changes: 1 addition & 1 deletion lib/__tests/definition-syntax-parse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer, definitionSyntax } from 'css-tree';
import { lexer, definitionSyntax } from '@eslint/css-tree';

const { parse } = definitionSyntax;

2 changes: 1 addition & 1 deletion lib/__tests/definition-syntax-walk.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { definitionSyntax } from 'css-tree';
import { definitionSyntax } from '@eslint/css-tree';

const { parse, generate, walk } = definitionSyntax;

24 changes: 12 additions & 12 deletions lib/__tests/exports.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fs from 'fs';
import assert from 'assert';
import * as csstree from 'css-tree';
import * as tokenizer from 'css-tree/tokenizer';
import parse from 'css-tree/parser';
import parseSelector from 'css-tree/selector-parser';
import walk from 'css-tree/walker';
import generate from 'css-tree/generator';
import convertor from 'css-tree/convertor';
import * as lexer from 'css-tree/lexer';
import * as definitionSyntax from 'css-tree/definition-syntax';
import data from 'css-tree/definition-syntax-data';
import dataPatch from 'css-tree/definition-syntax-data-patch';
import * as utils from 'css-tree/utils';
import * as csstree from '@eslint/css-tree';
import * as tokenizer from '@eslint/css-tree/tokenizer';
import parse from '@eslint/css-tree/parser';
import parseSelector from '@eslint/css-tree/selector-parser';
import walk from '@eslint/css-tree/walker';
import generate from '@eslint/css-tree/generator';
import convertor from '@eslint/css-tree/convertor';
import * as lexer from '@eslint/css-tree/lexer';
import * as definitionSyntax from '@eslint/css-tree/definition-syntax';
import data from '@eslint/css-tree/definition-syntax-data';
import dataPatch from '@eslint/css-tree/definition-syntax-data-patch';
import * as utils from '@eslint/css-tree/utils';

const stringifyWithNoInfo = ast => JSON.stringify(ast, (key, value) => key !== 'loc' ? value : undefined, 4);
const fixtureFilename = './fixtures/stringify.css';
2 changes: 1 addition & 1 deletion lib/__tests/find.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, find, findLast, findAll } from 'css-tree';
import { parse, find, findLast, findAll } from '@eslint/css-tree';
import { lazyValues } from './helpers/index.js';

const values = lazyValues({
2 changes: 1 addition & 1 deletion lib/__tests/fixture/definition-syntax.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import { createLexer, lexer as defaultLexer } from 'css-tree';
import { createLexer, lexer as defaultLexer } from '@eslint/css-tree';
import { JsonLocator } from '../helpers/JsonLocator.js';

const __dirname = 'fixtures/definition-syntax';
2 changes: 1 addition & 1 deletion lib/__tests/fixture/generate-auto-emit-ws.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tokenize, tokenTypes, generate } from 'css-tree';
import { tokenize, tokenTypes, generate } from '@eslint/css-tree';

function num(postfix = '') {
return [
2 changes: 1 addition & 1 deletion lib/__tests/generate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert, { strictEqual } from 'assert';
import { parse, generate, toPlainObject } from 'css-tree';
import { parse, generate, toPlainObject } from '@eslint/css-tree';
import { forEachTest as forEachAstTest } from './fixture/ast.js';
import { fixture as generateAutoWsFixture } from './fixture/generate-auto-emit-ws.js';

2 changes: 1 addition & 1 deletion lib/__tests/lexer-check-atrule-descriptor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer } from 'css-tree';
import { lexer } from '@eslint/css-tree';

describe('Lexer#checkAtruleDescriptorName()', () => {
it('should fail on invalid atrule', () => {
2 changes: 1 addition & 1 deletion lib/__tests/lexer-check-atrule-name.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer } from 'css-tree';
import { lexer } from '@eslint/css-tree';

describe('Lexer#checkAtruleName()', () => {
it('should pass correct atrule', () => {
2 changes: 1 addition & 1 deletion lib/__tests/lexer-check-atrule-prelude.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer } from 'css-tree';
import { lexer } from '@eslint/css-tree';

describe('Lexer#checkAtrulePrelude()', () => {
it('should fail on invalid atrule', () => {
2 changes: 1 addition & 1 deletion lib/__tests/lexer-check-property-name.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer } from 'css-tree';
import { lexer } from '@eslint/css-tree';

describe('Lexer#checkPropertyName()', () => {
it('should pass correct property', () => {
2 changes: 1 addition & 1 deletion lib/__tests/lexer-check-structure.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, lexer, fork } from 'css-tree';
import { parse, lexer, fork } from '@eslint/css-tree';
import { forEachTest as forEachAstTest } from './fixture/ast.js';

describe('Lexer#checkStructure()', () => {
2 changes: 1 addition & 1 deletion lib/__tests/lexer-match-atrule-descriptor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, lexer, fork } from 'css-tree';
import { parse, lexer, fork } from '@eslint/css-tree';
import { lazyValues, cssWideKeywords } from './helpers/index.js';
import { forEachAtruleDescriptorTest } from './fixture/definition-syntax.js';

2 changes: 1 addition & 1 deletion lib/__tests/lexer-match-atrule-prelude.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, lexer, fork } from 'css-tree';
import { parse, lexer, fork } from '@eslint/css-tree';
import { lazyValues, cssWideKeywords } from './helpers/index.js';
import { forEachAtrulePreludeTest } from './fixture/definition-syntax.js';

2 changes: 1 addition & 1 deletion lib/__tests/lexer-match-property.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, lexer, fork } from 'css-tree';
import { parse, lexer, fork } from '@eslint/css-tree';
import { lazyValues, cssWideKeywords } from './helpers/index.js';
import { forEachTest } from './fixture/definition-syntax.js';

2 changes: 1 addition & 1 deletion lib/__tests/lexer-match-result.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, lexer } from 'css-tree';
import { parse, lexer } from '@eslint/css-tree';

describe('lexer match result', () => {
let testNode;
2 changes: 1 addition & 1 deletion lib/__tests/lexer-match-type.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, fork } from 'css-tree';
import { parse, fork } from '@eslint/css-tree';
import { lazyValues, cssWideKeywords } from './helpers/index.js';

const values = lazyValues({
2 changes: 1 addition & 1 deletion lib/__tests/lexer-match.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, generate, fork } from 'css-tree';
import { parse, generate, fork } from '@eslint/css-tree';

describe('Lexer#match()', () => {
const customSyntax = fork(prev => ({
2 changes: 1 addition & 1 deletion lib/__tests/lexer-search-fragments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, generate, lexer } from 'css-tree';
import { parse, generate, lexer } from '@eslint/css-tree';

function translateFragments(fragments) {
return fragments.map(fragment => generate({
2 changes: 1 addition & 1 deletion lib/__tests/lexer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { lexer, createLexer, fork } from 'css-tree';
import { lexer, createLexer, fork } from '@eslint/css-tree';

describe('lexer', () => {
it('should not override generic types when used', () => {
2 changes: 1 addition & 1 deletion lib/__tests/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { List } from 'css-tree';
import { List } from '@eslint/css-tree';

function getFirstArg(data) {
return data;
2 changes: 1 addition & 1 deletion lib/__tests/names.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { keyword, property, isCustomProperty, vendorPrefix } from 'css-tree';
import { keyword, property, isCustomProperty, vendorPrefix } from '@eslint/css-tree';

describe('names utils', () => {
describe('keyword', () => {
2 changes: 1 addition & 1 deletion lib/__tests/parse-extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { parse, tokenTypes, toPlainObject, fork } from 'css-tree';
import { parse, tokenTypes, toPlainObject, fork } from '@eslint/css-tree';

const DollarSign = 0x0024; // U+0024 DOLLAR SIGN ($)
const PercentageSign = 0x0025; // U+0025 PERCENTAGE SIGN (%)
2 changes: 1 addition & 1 deletion lib/__tests/parse-selector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import parse from 'css-tree/selector-parser';
import parse from '@eslint/css-tree/selector-parser';
import { forEachSelectorTest } from './fixture/ast.js';

const stringifyWithNoLoc = ast => JSON.stringify(ast, (key, value) => key !== 'loc' ? value : undefined, 4);
2 changes: 1 addition & 1 deletion lib/__tests/parse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'assert';
import fs from 'fs';
import { parse, walk, List } from 'css-tree';
import { parse, walk, List } from '@eslint/css-tree';
import { forEachTest as forEachAstTest } from './fixture/ast.js';
import { tokenTypes, tokenNames, OffsetToLocation, TokenStream, tokenize } from '../tokenizer/index.js';

2 changes: 1 addition & 1 deletion lib/__tests/tokenizer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert';
import { TokenStream, tokenize, tokenNames } from 'css-tree';
import { TokenStream, tokenize, tokenNames } from '@eslint/css-tree';
import * as fixture from './fixture/tokenize.js';

describe('tokenize/stream', () => {
2 changes: 1 addition & 1 deletion lib/__tests/walk.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'assert';
import path from 'path';
import { lazyValues } from './helpers/index.js';
import { parse, walk } from 'css-tree';
import { parse, walk } from '@eslint/css-tree';
import { tests, forEachTest as forEachAstTest } from './fixture/ast.js';

const notInsideAtrulePrelude = stack => stack.every(node => node.type !== 'AtrulePrelude');
4 changes: 2 additions & 2 deletions package-lock.json
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"name": "css-tree",
"name": "@eslint/css-tree",
"version": "3.1.0",
"description": "A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations",
"author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
"license": "MIT",
"repository": "csstree/csstree",
"publishConfig": {
"access": "public"
},
"repository": "eslint/csstree",
"keywords": [
"css",
"ast",
24 changes: 12 additions & 12 deletions scripts/esm-to-cjs.cjs
Original file line number Diff line number Diff line change
@@ -15,18 +15,18 @@ const external = [
'path',
'assert',
'json-to-ast',
'css-tree',
'css-tree/tokenizer',
'css-tree/parser',
'css-tree/selector-parser',
'css-tree/generator',
'css-tree/walker',
'css-tree/definition-syntax',
'css-tree/definition-syntax-data',
'css-tree/definition-syntax-data-patch',
'css-tree/lexer',
'css-tree/convertor',
'css-tree/utils',
'@eslint/css-tree',
'@eslint/css-tree/tokenizer',
'@eslint/css-tree/parser',
'@eslint/css-tree/selector-parser',
'@eslint/css-tree/generator',
'@eslint/css-tree/walker',
'@eslint/css-tree/definition-syntax',
'@eslint/css-tree/definition-syntax-data',
'@eslint/css-tree/definition-syntax-data-patch',
'@eslint/css-tree/lexer',
'@eslint/css-tree/convertor',
'@eslint/css-tree/utils',
/^source-map/
];

2 changes: 1 addition & 1 deletion scripts/generate-safe/fixture.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tokenize, tokenTypes, generate } from 'css-tree';
import { tokenize, tokenTypes, generate } from '@eslint/css-tree';

function num(postfix = '') {
return [