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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

A [PostCSS] Syntax for parsing [LESS]

_Note: This module requires Node v6.14.4+. `poscss-less` is not a LESS compiler. For compiling LESS, please use the official toolset for LESS._
_Note: `postcss-less` is not a LESS compiler. For compiling LESS, please use the official toolset for LESS._

## Install

Expand Down Expand Up @@ -104,7 +104,7 @@ The AST will contain an `AtRule` node with a `variable: true` property.

_Note: LESS variables are strictly parsed - a colon (`:`) must immediately follow a variable name._

## Stringifying
## Stringify

To process LESS code without PostCSS transformations, custom stringifier
should be provided.
Expand Down
14 changes: 14 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.2",
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json",
"words": [
"atrule",
"jsonify",
"Kniazevych",
"Stringifier",
"unpadded",
"untokenized"
],
"ignoreRegExpList": [],
"ignorePaths": ["LICENSE", "test/integration/ext.cx.dashboard.less"]
}
4 changes: 2 additions & 2 deletions lib/LessParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export class LessParser extends Parser {

tokens = tokens.slice(0, tokens.length - 2).concat([newToken]);

for (const tokn of tokens.reverse()) {
this.tokenizer.back(tokn);
for (const token of tokens.reverse()) {
this.tokenizer.back(token);
}

return;
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/inline-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function isInlineComment(token) {
// Add string before newline to inline comment token
bits.push(token[1].substring(0, token[1].indexOf('\n')));

// Get remaining input and retokenize
// Get remaining input and re-tokenize
remainingInput = token[1].substring(token[1].indexOf('\n'));
const untokenizedRemainingInput = this.input.css
.valueOf()
Expand All @@ -40,7 +40,7 @@ export function isInlineComment(token) {
const newToken = ['comment', bits.join(''), first[2], endOffset];
this.inlineComment(newToken);

// Replace tokenizer to retokenize the rest of the string
// Replace tokenizer to re-tokenize the rest of the string
// we need replace it after we added new token with inline comment because token position is calculated for old input (#145)
if (remainingInput) {
this.input = new Input(remainingInput, { from: this.input.file });
Expand Down
2 changes: 1 addition & 1 deletion lib/nodes/interpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function isInterpolation(token) {
token = this.tokenizer.nextToken();
}

const words = tokens.map((tokn) => tokn[1]);
const words = tokens.map((token) => token[1]);
const [first] = tokens;
const last = tokens.pop();
const newToken = ['word', words.join(''), first[2], last[2]];
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"lint": "run-p --continue-on-error \"lint:*\"",
"lint:eslint": "eslint .",
"lint:prettier": "prettier . --check",
"lint:cspell": "cspell . --gitignore",
"test": "ava",
"test-coverage": "c8 yarn test",
"release": "release-it"
Expand All @@ -32,6 +33,7 @@
"ava": "8.2.0",
"c8": "12.0.0",
"cheerio": "1.2.0",
"cspell": "10.4.0",
"eslint": "10.13.0",
"eslint-config-prettier": "10.1.8",
"globals": "17.13.0",
Expand Down
10 changes: 5 additions & 5 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import test from 'ava';
import * as cheerio from 'cheerio';
import isAbsoluteUrl from 'is-absolute-url';
import urljoin from 'url-join';
import urlJoin from 'url-join';
import postcss from 'postcss';

import syntax from '../lib/index.js';
Expand All @@ -21,21 +21,21 @@ for (const site of sites) {
const html = await res.text();
const $ = cheerio.load(html);

const hrefs = $('head link[rel=stylesheet]')
const stylesheets = $('head link[rel=stylesheet]')
.filter((index, sheet) => !!sheet.attribs.href)
.map((index, sheet) => {
let { href } = sheet.attribs;

if (!isAbsoluteUrl(href)) {
href = urljoin(site, href);
href = urlJoin(site, href);
}

return href;
})
.get();

for (const href of hrefs) {
const req = await fetch(href);
for (const url of stylesheets) {
const req = await fetch(url);
const css = await req.text();
await postcss().process(css, {
from: null,
Expand Down
2 changes: 1 addition & 1 deletion test/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import syntax from '../lib/index.js';

const __dirname = import.meta.dirname;

// silence the rediculously verbose "You did not set any plugins, parser, or
// silence the ridiculously verbose "You did not set any plugins, parser, or
// stringifier" warnings in PostCSS.
console.warn = () => {};

Expand Down
6 changes: 3 additions & 3 deletions test/parser/comments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ test('close empty', (t) => {
});

test('close inline and block', (t) => {
const less = '// batman\n/* cleans the batcave */';
const less = '// batman\n/* cleans the bat cave */';
const root = parse(less);
const { first, last } = root;

t.truthy(root.nodes.length);
t.is(first.text, 'batman');
t.is(last.text, 'cleans the batcave');
t.is(last.text, 'cleans the bat cave');
t.is(nodeToString(root), less);
});

Expand Down Expand Up @@ -224,7 +224,7 @@ test('handles single quotes in comments (#163)', (t) => {
t.is(nodeToString(root), less);
});

test('preserves source.input.file when retokenizing inline comments', (t) => {
test('preserves source.input.file when re-tokenizing inline comments', (t) => {
const from = '/repro.less';
// The quote in the inline comment, plus a later quote, makes the tokenizer run
// the string past the newline, which sends `isInlineComment` down the path that
Expand Down
2 changes: 1 addition & 1 deletion test/parser/import.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test('malformed filename (#88)', async (t) => {
t.is(nodeToString(root), less);
});

test('mmissing semicolon (#88)', async (t) => {
test('missing semicolon (#88)', async (t) => {
const less = `
@import "../assets/font/league-gothic/league-gothic.css"

Expand Down
2 changes: 1 addition & 1 deletion test/parser/mixins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test('without body, no params', (t) => {
t.is(nodeToString(root), less);
});

test('without body, no params, no whitepsace', (t) => {
test('without body, no params, no whitespace', (t) => {
const less = '.base {.mixin-name}';
const root = parse(less);
const { first } = root;
Expand Down
2 changes: 1 addition & 1 deletion test/parser/variables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('numeric', (t) => {
t.is(nodeToString(root), less);
});

test('@pagexxx like variable but not @page selector', (t) => {
test('@pageXxx like variable but not @page selector', (t) => {
let less = '@pageWidth: "test";';
let root = parse(less);
let { first } = root;
Expand Down
2 changes: 1 addition & 1 deletion test/postcss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CssSyntaxError from 'postcss/lib/css-syntax-error';

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

// silence the rediculously verbose "You did not set any plugins, parser, or
// silence the ridiculously verbose "You did not set any plugins, parser, or
// stringifier" warnings in PostCSS.
console.warn = () => {};

Expand Down
Loading
Loading