Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 14 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"extends": "shellscape"
"extends": "shellscape",
"overrides": [
{
"files": "test/**/*.js",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off"
}
}
]
}
12 changes: 4 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
uses: actions/checkout@v7

- name: NPM Rebuild
run: npm install
run: yarn

- name: Run unit tests
run: npm run ci:coverage
run: yarn ci:coverage

- name: Submit coverage data to codecov.
run: bash <(curl -s https://codecov.io/bash)
Expand All @@ -39,12 +39,8 @@ jobs:
uses: actions/checkout@v7

- name: NPM Rebuild
run: npm install
run: yarn

- name: Run Linting
run: npm run lint

# Disabled temporarily
# - name: Run NPM Audit
# run: npm run security
run: yarn lint

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"devDependencies": {
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"ava": "3.15.0",
"ava": "8.1.1",
"cheerio": "1.0.0-rc.10",
"eslint-config-shellscape": "6.0.2",
"eslint-plugin-filenames": "1.2.0",
Expand Down
15 changes: 7 additions & 8 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
// const { readFileSync } = require('fs');
// const { join } = require('path');

const test = require('ava');
const cheerio = require('cheerio');
const isAbsoluteUrl = require('is-absolute-url');
const fetch = require('node-fetch');
const postcss = require('postcss');
const urljoin = require('url-join');
import test from 'ava';
import cheerio from 'cheerio';
import isAbsoluteUrl from 'is-absolute-url';
import urljoin from 'url-join';
import postcss from 'postcss';

const syntax = require('../lib');
import syntax from '../lib/index.js';

const sites = ['https://github.com', 'https://news.ycombinator.com'];

for (const site of sites) {
test(`integration: ${site}`, async (t) => {
t.timeout(50000);
const res = await fetch(site);
const html = await res.text();
const $ = cheerio.load(html);
Expand All @@ -37,7 +37,6 @@ for (const site of sites) {
for (const href of hrefs) {
const req = await fetch(href);
const css = await req.text();

await postcss().process(css, {
from: null,
map: { annotation: false },
Expand Down
11 changes: 6 additions & 5 deletions test/map.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const { readFileSync } = require('fs');
import { readFileSync } from 'node:fs';

const { join } = require('path');
import { join } from 'node:path';

const test = require('ava');
const postcss = require('postcss');
import test from 'ava';
import postcss from 'postcss';

const syntax = require('../lib');
import syntax from '../lib/index.js';

const { parser } = syntax;
const __dirname = import.meta.dirname;

// silence the rediculously verbose "You did not set any plugins, parser, or
// stringifier" warnings in PostCSS.
Expand Down
1 change: 1 addition & 0 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "module", "//": "delete this file when we migrate to ESM"}
8 changes: 5 additions & 3 deletions test/parser/comments.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const test = require('ava');
const Comment = require('postcss/lib/comment');
import test from 'ava';
import Comment from 'postcss/lib/comment';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('inline comment', (t) => {
const less = '// batman';
Expand Down
6 changes: 4 additions & 2 deletions test/parser/declaration.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const test = require('ava');
import test from 'ava';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('should allow case-insensitive !important (#89)', (t) => {
const less = 'a{k: v !IMPORTANT;}';
Expand Down
6 changes: 4 additions & 2 deletions test/parser/escaping.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const test = require('ava');
import test from 'ava';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('parses escaped string', (t) => {
const less = `
Expand Down
6 changes: 4 additions & 2 deletions test/parser/extend.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const test = require('ava');
import test from 'ava';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('inline :extend()', (t) => {
const less = '.a:extend(.b) {color: red;}';
Expand Down
6 changes: 4 additions & 2 deletions test/parser/function.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const test = require('ava');
import test from 'ava';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('each (#121)', (t) => {
const params = `(@colors, {
Expand Down
8 changes: 5 additions & 3 deletions test/parser/import.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const test = require('ava');
const AtRule = require('postcss/lib/at-rule');
import test from 'ava';
import AtRule from 'postcss/lib/at-rule';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('@at-rules != @imports', async (t) => {
const less = '@const "foo.less";';
Expand Down
6 changes: 4 additions & 2 deletions test/parser/interpolation.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint no-useless-escape: off */

const test = require('ava');
import test from 'ava';

const { parse } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse } = syntax;

test('parses interpolation', (t) => {
const root = parse('@{selector}:hover { @{prop}-size: @{color} }');
Expand Down
6 changes: 4 additions & 2 deletions test/parser/mixins.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const test = require('ava');
import test from 'ava';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('basic', (t) => {
const params = '( 1, 2, 3; something, else; ...) when (@mode=huge)';
Expand Down
6 changes: 4 additions & 2 deletions test/parser/params.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const test = require('ava');
import test from 'ava';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('should not assign parameters for pseudo-selectors (#56)', (t) => {
const less = '.test2:not(.test3) {}';
Expand Down
10 changes: 8 additions & 2 deletions test/parser/postcss-sanity.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const test = require('ava');
import { createRequire } from 'node:module';

import test from 'ava';

import syntax from '../../lib/index.js';

const require = createRequire(import.meta.url);
const { eachTest, jsonify } = require('postcss-parser-tests');

const { nodeToString, parse, stringify } = require('../../lib');
const { nodeToString, parse, stringify } = syntax;

eachTest((name, code, json) => {
// Skip comments.css, because we have an extended Comment node
Expand Down
8 changes: 5 additions & 3 deletions test/parser/variables.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const test = require('ava');
const AtRule = require('postcss/lib/at-rule');
import test from 'ava';
import AtRule from 'postcss/lib/at-rule';

const { parse, nodeToString } = require('../../lib');
import syntax from '../../lib/index.js';

const { parse, nodeToString } = syntax;

test('numeric', (t) => {
const less = '@var: 1;';
Expand Down
8 changes: 4 additions & 4 deletions test/postcss.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const test = require('ava');
const postcss = require('postcss');
const CssSyntaxError = require('postcss/lib/css-syntax-error');
import test from 'ava';
import postcss from 'postcss';
import CssSyntaxError from 'postcss/lib/css-syntax-error';

const syntax = require('../lib');
import syntax from '../lib/index.js';

const { parser } = syntax;

Expand Down
4 changes: 2 additions & 2 deletions test/stringify.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('ava');
import test from 'ava';

const syntax = require('../lib');
import syntax from '../lib/index.js';

const { parse, nodeToString } = syntax;

Expand Down
Loading
Loading