Fixes #3787 -- ESLint updates and linting cleanup (#3790)

* ESLint updates and linting cleanup

* Exclude test files from some linting rules for now

* Fix some TypeScript and build issues
This commit is contained in:
Matthew Dean
2023-04-08 09:27:41 -07:00
committed by GitHub
parent a917965340
commit 4d3189c051
68 changed files with 449 additions and 442 deletions

View File

@@ -0,0 +1,63 @@
module.exports = {
'parser': '@typescript-eslint/parser',
'extends': 'eslint:recommended',
'parserOptions': {
'ecmaVersion': 2018,
'sourceType': 'module'
},
'plugins': ['@typescript-eslint'],
'env': {
'browser': true,
'node': true,
'mocha': true
},
'globals': {},
'rules': {
indent: ['error', 4, {
SwitchCase: 1
}],
'no-empty': ['error', { 'allowEmptyCatch': true }],
quotes: ['error', 'single', {
avoidEscape: true
}],
/**
* The codebase uses some while(true) statements.
* Refactor to remove this rule.
*/
'no-constant-condition': 0,
/**
* Less combines assignments with conditionals sometimes
*/
'no-cond-assign': 0,
/**
* @todo - remove when some kind of code style (XO?) is added
*/
'no-multiple-empty-lines': 'error'
},
'overrides': [
{
files: ['*.ts'],
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
/**
* Suppress until Less has better-defined types
* @see https://github.com/less/less.js/discussions/3786
*/
'@typescript-eslint/no-explicit-any': 0
}
},
{
files: ['test/**/*.{js,ts}', 'benchmark/index.js'],
/**
* @todo - fix later
*/
rules: {
'no-undef': 0,
'no-useless-escape': 0,
'no-unused-vars': 0,
'no-redeclare': 0,
'@typescript-eslint/no-unused-vars': 0
}
},
]
}

View File

@@ -1,71 +0,0 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"env": {
"browser": true,
"node": true
},
"globals": {},
"rules": {
"no-eval": 2,
"no-use-before-define": [
2,
{
"functions": false
}
],
"no-undef": 0,
"no-unused-vars": 1,
"no-caller": 2,
"no-eq-null": 1,
"guard-for-in": 2,
"no-implicit-coercion": [
2,
{
"boolean": false,
"string": true,
"number": true
}
],
"no-with": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": 2,
"dot-location": [2, "property"],
"operator-linebreak": [0, "after"],
"keyword-spacing": [2, {}],
"space-unary-ops": [
2,
{
"words": false,
"nonwords": false
}
],
"no-spaced-func": 2,
"space-before-function-paren": [
1,
{
"anonymous": "ignore",
"named": "never"
}
],
"comma-dangle": [2, "never"],
"no-trailing-spaces": 0,
"max-len": [2, 160],
"comma-style": [2, "last"],
"curly": [2, "all"],
"space-infix-ops": 2,
"spaced-comment": 1,
"space-before-blocks": [2, "always"],
"indent": [
2,
4,
{
"SwitchCase": 1
}
]
}
}

View File

@@ -283,7 +283,7 @@ module.exports = function(grunt) {
"!test/less/errors/plugin/plugin-error.js"
],
options: {
configFile: ".eslintrc.json",
configFile: ".eslintrc.js",
fix: true
}
},

View File

@@ -1,6 +1,6 @@
var path = require('path'),
fs = require('fs'),
now = require("performance-now");
now = require('performance-now');
var less = require('../.');
var file = path.join(__dirname, 'benchmark.less');
@@ -10,12 +10,12 @@ if (process.argv[2]) { file = path.join(process.cwd(), process.argv[2]) }
fs.readFile(file, 'utf8', function (e, data) {
var start, total;
console.log("Benchmarking...\n", path.basename(file) + " (" +
parseInt(data.length / 1024) + " KB)", "");
console.log('Benchmarking...\n', path.basename(file) + ' (' +
parseInt(data.length / 1024) + ' KB)', '');
var renderBenchmark = []
, parserBenchmark = []
, evalBenchmark = [];
, parserBenchmark = []
, evalBenchmark = [];
var totalruns = 30;
var ignoreruns = 5;
@@ -74,13 +74,13 @@ fs.readFile(file, 'utf8', function (e, data) {
var variation = maxtime - mintime;
var variationperc = (variation / avgtime) * 100;
console.log("Min. Time: " + Math.round(mintime) + " ms");
console.log("Max. Time: " + Math.round(maxtime) + " ms");
console.log("Total Average Time: " + Math.round(avgtime) + " ms (" +
console.log('Min. Time: ' + Math.round(mintime) + ' ms');
console.log('Max. Time: ' + Math.round(maxtime) + ' ms');
console.log('Total Average Time: ' + Math.round(avgtime) + ' ms (' +
parseInt(1000 / avgtime *
data.length / 1024) + " KB\/s)");
console.log("+/- " + Math.round(variationperc) + "%");
console.log("");
data.length / 1024) + ' KB\/s)');
console.log('+/- ' + Math.round(variationperc) + '%');
console.log('');
}
analyze('Parsing', parserBenchmark);

View File

@@ -47,7 +47,7 @@ async function buildBrowser() {
include: [/^.+\.min\.js$/],
output: {
comments: function(node, comment) {
if (comment.type == "comment2") {
if (comment.type == 'comment2') {
// preserve banner
return /@license/i.test(comment.value);
}

View File

@@ -37,11 +37,13 @@
"scripts": {
"test": "grunt test",
"grunt": "grunt",
"lint": "eslint '**/*.{ts,js}'",
"lint:fix": "eslint '**/*.{ts,js}' --fix",
"build": "npm-run-all clean compile",
"clean": "shx rm -rf ./lib tsconfig.tsbuildinfo",
"compile": "tsc -p tsconfig.json",
"compile": "tsc -p tsconfig.build.json",
"copy:root": "shx cp -rf ./dist ../../",
"dev": "tsc -p tsconfig.json -w",
"dev": "tsc -p tsconfig.build.json -w",
"prepublishOnly": "grunt dist"
},
"optionalDependencies": {

View File

@@ -3,8 +3,6 @@
* used in the browser distributed version of less
* to kick-start less using the browser api
*/
/* global window, document */
import defaultOptions from '../less/default-options';
import addDefaultOptions from './add-default-options';
import root from './index';
@@ -13,7 +11,7 @@ const options = defaultOptions();
if (window.less) {
for (const key in window.less) {
if (window.less.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(window.less, key)) {
options[key] = window.less[key];
}
}

View File

@@ -29,7 +29,7 @@ export default (window, options, logger) => {
let vars = cache && cache.getItem(`${path}:vars`);
modifyVars = modifyVars || {};
vars = vars || "{}"; // if not set, treat as the JSON representation of an empty object
vars = vars || '{}'; // if not set, treat as the JSON representation of an empty object
if (timestamp && webInfo.lastModified &&
(new Date(webInfo.lastModified).valueOf() ===

View File

@@ -11,7 +11,7 @@ export default (window, less, options) => {
let content;
const errors = [];
const filename = e.filename || rootHref;
const filenameNoPath = filename.match(/([^\/]+(\?.*)?)$/)[1];
const filenameNoPath = filename.match(/([^/]+(\?.*)?)$/)[1];
elem.id = id;
elem.className = 'less-error-message';
@@ -113,7 +113,7 @@ export default (window, less, options) => {
}
}
function removeErrorConsole(path) {
function removeErrorConsole() {
// no action
}

View File

@@ -1,5 +1,3 @@
/* global window, XMLHttpRequest */
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
let options;
@@ -66,7 +64,7 @@ FileManager.prototype = Object.assign(new AbstractFileManager(), {
fileCache = {};
},
loadFile(filename, currentDirectory, options, environment) {
loadFile(filename, currentDirectory, options) {
// TODO: Add prefix support like less-node?
// What about multiple paths?

View File

@@ -39,7 +39,7 @@ export default (window, options) => {
function clone(obj) {
const cloned = {};
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
cloned[prop] = obj[prop];
}
}
@@ -159,6 +159,10 @@ export default (window, options) => {
less.watchTimer = setInterval(() => {
if (less.watchMode) {
fileManager.clearFileCache();
/**
* @todo remove when this is typed with JSDoc
*/
// eslint-disable-next-line no-unused-vars
loadStyleSheets((e, css, _, sheet, webInfo) => {
if (e) {
errors.add(e, e.href || sheet.href);
@@ -174,7 +178,7 @@ export default (window, options) => {
//
// Watch mode
//
less.watch = function () {
less.watch = function () {
if (!less.watchMode ) {
less.env = 'development';
initRunningMode();
@@ -205,7 +209,7 @@ export default (window, options) => {
// Asynchronously get all <link> tags with the 'rel' attribute set to
// "stylesheet/less", returning a Promise.
//
less.registerStylesheets = () => new Promise((resolve, reject) => {
less.registerStylesheets = () => new Promise((resolve) => {
less.registerStylesheetsImmediately();
resolve();
});

View File

@@ -1,6 +1,6 @@
// TODO: Add tests for browser @plugin
/* global window */
/**
* @todo Add tests for browser `@plugin`
*/
import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
/**

View File

@@ -1,17 +1,17 @@
export function extractId(href) {
return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain
.replace(/[\?\&]livereload=\w+/, '') // Remove LiveReload cachebuster
return href.replace(/^[a-z-]+:\/+?[^/]+/, '') // Remove protocol & domain
.replace(/[?&]livereload=\w+/, '') // Remove LiveReload cachebuster
.replace(/^\//, '') // Remove root /
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
.replace(/[^.\w-]+/g, '-') // Replace illegal characters
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
}
export function addDataAttr(options, tag) {
if (!tag) {return;} // in case of tag is null or undefined
for (const opt in tag.dataset) {
if (tag.dataset.hasOwnProperty(opt)) {
if (Object.prototype.hasOwnProperty.call(tag.dataset, opt)) {
if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {
options[opt] = tag.dataset[opt];
} else {

View File

@@ -61,6 +61,23 @@ FileManager.prototype = Object.assign(new AbstractFileManager(), {
function getFileData(fulfill, reject) {
(function tryPathIndex(i) {
function tryWithExtension() {
const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(extFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + extFilename);
fullFilename = extFilename;
}
}
else {
fullFilename = extFilename;
}
}
if (i < paths.length) {
(function tryPrefix(j) {
if (j < prefixes.length) {
@@ -83,25 +100,7 @@ FileManager.prototype = Object.assign(new AbstractFileManager(), {
}
else {
tryWithExtension();
}
function tryWithExtension() {
const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
try {
fullFilename = require.resolve(extFilename);
isNodeModule = true;
}
catch (e) {
filenamesTried.push(npmPrefix + extFilename);
fullFilename = extFilename;
}
}
else {
fullFilename = extFilename;
}
}
}
const readFileArgs = [fullFilename];
if (!options.rawBuffer) {

View File

@@ -88,4 +88,5 @@ const lessc_helper = {
};
// Exports helper functions
// eslint-disable-next-line no-prototype-builtins
for (const h in lessc_helper) { if (lessc_helper.hasOwnProperty(h)) { exports[h] = lessc_helper[h]; }}

View File

@@ -1,3 +1,8 @@
/* eslint-disable no-unused-vars */
/**
* @todo - remove top eslint rule when FileManagers have JSDoc type
* and are TS-type-checked
*/
const isUrlRe = /^(?:https?:)?\/\//i;
import url from 'url';
let request;

View File

@@ -6,7 +6,7 @@ const copyFromOriginal = function copyFromOriginal(original, destination, proper
if (!original) { return; }
for (let i = 0; i < propertiesToCopy.length; i++) {
if (original.hasOwnProperty(propertiesToCopy[i])) {
if (Object.prototype.hasOwnProperty.call(original, propertiesToCopy[i])) {
destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];
}
}
@@ -113,7 +113,7 @@ contexts.Eval.prototype.pathRequiresRewrite = function (path) {
contexts.Eval.prototype.rewritePath = function (path, rootpath) {
let newPath;
rootpath = rootpath || '';
rootpath = rootpath || '';
newPath = this.normalizePath(rootpath + path);
// If a path was explicit relative and the rootpath was not an absolute path

View File

@@ -67,4 +67,4 @@ export default function() {
/* This option allows you to specify a argument to go on to every URL. */
urlArgs: ''
}
};
}

View File

@@ -15,7 +15,7 @@ class AbstractFileManager {
}
tryAppendExtension(path, ext) {
return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext;
return /(\.[a-z]*$)|([?;].*)$/.test(path) ? path : path + ext;
}
tryAppendLessExtension(path) {
@@ -71,7 +71,13 @@ class AbstractFileManager {
return diff;
}
// helper function, not part of API
/**
* Helper function, not part of API.
* This should be replaceable by newer Node / Browser APIs
*
* @param {string} url
* @param {string} baseUrl
*/
extractUrlParts(url, baseUrl) {
// urlParts[1] = protocol://hostname/ OR /
// urlParts[2] = / if path relative to host base
@@ -79,7 +85,7 @@ class AbstractFileManager {
// urlParts[4] = filename
// urlParts[5] = parameters
const urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i;
const urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^/?#]*\/)|([/\\]))?((?:[^/\\?#]*[/\\])*)([^/\\?#]*)([#?].*)?$/i;
const urlParts = url.match(urlPartsRegex);
const returner = {};

View File

@@ -1,25 +0,0 @@
export default {
/**
* Converts a string to a base 64 string
* @param str
*/
encodeBase64: function(str) {
},
/**
* Lookup the mime-type of a filename
* @param filename
*/
mimeLookup: function (filename) {
},
/**
* Look up the charset of a mime type
* @param mime
*/
charsetLookup: function (mime) {
},
/**
* Gets a source map generator
*/
getSourceMapGenerator: function getSourceMapGenerator() {
}
};

View File

@@ -0,0 +1,21 @@
export interface Environment {
/**
* Converts a string to a base 64 string
*/
encodeBase64(str: string): string
/**
* Lookup the mime-type of a filename
*/
mimeLookup(filename: string): string
/**
* Look up the charset of a mime type
* @param mime
*/
charsetLookup(mime: string): string
/**
* Gets a source map generator
*
* @todo - Figure out precise type
*/
getSourceMapGenerator(): any
}

View File

@@ -1,103 +0,0 @@
export default {
/**
* Given the full path to a file, return the path component
* Provided by AbstractFileManager
* @param {string} filename
* @returns {string}
*/
getPath: function(filename) {
},
/**
* Append a .less extension if appropriate. Only called if less thinks one could be added.
* Provided by AbstractFileManager
* @param filename
* @returns {string}
*/
tryAppendLessExtension: function(filename) {
},
/**
* Whether the rootpath should be converted to be absolute.
* The browser ovverides this to return true because urls must be absolute.
* Provided by AbstractFileManager (returns false)
* @returns {bool}
*/
alwaysMakePathsAbsolute: function() {
},
/**
* Returns whether a path is absolute
* Provided by AbstractFileManager
* @param {string} path
* @returns {bool}
*/
isPathAbsolute: function(path) {
},
/**
* joins together 2 paths
* Provided by AbstractFileManager
* @param {string} basePath
* @param {string} laterPath
*/
join: function(basePath, laterPath) {
},
/**
* Returns the difference between 2 paths
* E.g. url = a/ baseUrl = a/b/ returns ../
* url = a/b/ baseUrl = a/ returns b/
* Provided by AbstractFileManager
* @param {string} url
* @param {string} baseUrl
* @returns {string}
*/
pathDiff: function(url, baseUrl) {
},
/**
* Returns whether this file manager supports this file for syncronous file retrieval
* If true is returned, loadFileSync will then be called with the file.
* Provided by AbstractFileManager (returns false)
* @param {string} filename
* @param {string} currentDirectory
* @param {object} options
* @param {less.environment.environment} environment
* @returns {bool}
*/
supportsSync: function(filename, currentDirectory, options, environment) {
},
/**
*
* @param {string} filename
* @param {string} currentDirectory
* @param {object} options
* @param {less.environment.environment} environment
* @returns {bool}
*/
supports: function(filename, currentDirectory, options, environment) {
},
/**
* Loads a file asynchronously. Expects a promise that either rejects with an error or fulfills with an
* object containing
* { filename: - full resolved path to file
* contents: - the contents of the file, as a string }
*
* @param {string} filename
* @param {string} currentDirectory
* @param {object} options
* @param {less.environment.environment} environment
* @returns {Promise}
*/
loadFile: function(filename, currentDirectory, options, environment) {
},
/**
* Loads a file synchronously. Expects an immediate return with an object containing
* { error: - error object if an error occurs
* filename: - full resolved path to file
* contents: - the contents of the file, as a string }
*
* @param {string} filename
* @param {string} currentDirectory
* @param {object} options
* @param {less.environment.environment} environment
* @returns {object} should be an object containing error or contents and filename
*/
loadFileSync: function(filename, currentDirectory, options, environment) {
}
};

View File

@@ -0,0 +1,77 @@
import type { Environment } from './environment-api'
export interface FileManager {
/**
* Given the full path to a file, return the path component
* Provided by AbstractFileManager
*/
getPath(filename: string): string
/**
* Append a .less extension if appropriate. Only called if less thinks one could be added.
* Provided by AbstractFileManager
*/
tryAppendLessExtension(filename: string): string
/**
* Whether the rootpath should be converted to be absolute.
* The browser ovverides this to return true because urls must be absolute.
* Provided by AbstractFileManager (returns false)
*/
alwaysMakePathsAbsolute(): boolean
/**
* Returns whether a path is absolute
* Provided by AbstractFileManager
*/
isPathAbsolute(path: string): boolean
/**
* joins together 2 paths
* Provided by AbstractFileManager
*/
join(basePath: string, laterPath: string): string
/**
* Returns the difference between 2 paths
* E.g. url = a/ baseUrl = a/b/ returns ../
* url = a/b/ baseUrl = a/ returns b/
* Provided by AbstractFileManager
*/
pathDiff(url: string, baseUrl: string): string
/**
* Returns whether this file manager supports this file for syncronous file retrieval
* If true is returned, loadFileSync will then be called with the file.
* Provided by AbstractFileManager (returns false)
*
* @todo - Narrow Options type
*/
supportsSync(
filename: string,
currentDirectory: string,
options: Record<string, any>,
environment: Environment
): boolean
/**
* If file manager supports async file retrieval for this file type
*/
supports(
filename: string,
currentDirectory: string,
options: Record<string, any>,
environment: Environment
): boolean
/**
* Loads a file asynchronously.
*/
loadFile(
filename: string,
currentDirectory: string,
options: Record<string, any>,
environment: Environment
): Promise<{ filename: string, contents: string }>
/**
* Loads a file synchronously. Expects an immediate return with an object
*/
loadFileSync(
filename: string,
currentDirectory: string,
options: Record<string, any>,
environment: Environment
): { error?: unknown, filename: string, contents: string }
}

View File

@@ -76,6 +76,7 @@ const colorBlendModeFunctions = {
};
for (const f in colorBlendModeFunctions) {
// eslint-disable-next-line no-prototype-builtins
if (colorBlendModeFunctions.hasOwnProperty(f)) {
colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);
}

View File

@@ -121,6 +121,25 @@ colorFunctions = {
}
},
hsla: function (h, s, l, a) {
let m1;
let m2;
function hue(h) {
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
if (h * 6 < 1) {
return m1 + (m2 - m1) * h * 6;
}
else if (h * 2 < 1) {
return m2;
}
else if (h * 3 < 2) {
return m1 + (m2 - m1) * (2 / 3 - h) * 6;
}
else {
return m1;
}
}
try {
if (h instanceof Color) {
if (s) {
@@ -131,25 +150,6 @@ colorFunctions = {
return new Color(h.rgb, a, 'hsla');
}
let m1;
let m2;
function hue(h) {
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
if (h * 6 < 1) {
return m1 + (m2 - m1) * h * 6;
}
else if (h * 2 < 1) {
return m2;
}
else if (h * 3 < 2) {
return m1 + (m2 - m1) * (2 / 3 - h) * 6;
}
else {
return m1;
}
}
h = (number(h) % 360) / 360;
s = clamp(number(s));l = clamp(number(l));a = clamp(number(a));

View File

@@ -6,6 +6,7 @@ function makeRegistry( base ) {
// the registry by function-caller uses lower case as well.
name = name.toLowerCase();
// eslint-disable-next-line no-prototype-builtins
if (this._data.hasOwnProperty(name)) {
// TODO warn
}

View File

@@ -142,14 +142,14 @@ export default {
false, false, this.index, this.currentFileInfo));
}
rules.push(new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
newRules,
rs.strictImports,
rs.visibilityInfo()
));
}
return new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
return new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
rules,
rs.strictImports,
rs.visibilityInfo()

View File

@@ -15,6 +15,7 @@ const mathFunctions = {
};
for (const f in mathFunctions) {
// eslint-disable-next-line no-prototype-builtins
if (mathFunctions.hasOwnProperty(f)) {
mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);
}

View File

@@ -4,7 +4,7 @@ import Expression from '../tree/expression';
import Quoted from '../tree/quoted';
import URL from '../tree/url';
export default environment => {
export default () => {
return { 'svg-gradient': function(direction) {
let stops;
let gradientDirectionSvg;

View File

@@ -180,4 +180,4 @@ export default function(environment) {
}
return ImportManager;
};
}

View File

@@ -95,4 +95,4 @@ export default function(environment, fileManagers) {
initial.render = initial.render.bind(api);
return api;
};
}

View File

@@ -62,8 +62,7 @@ const LessError = function(e, fileContentMap, currentFilename) {
func();
} catch (e) {
const match = e.stack.match(anonymousFunc);
var line = parseInt(match[2]);
lineAdjust = 1 - line;
lineAdjust = 1 - parseInt(match[2]);
}
if (found) {

View File

@@ -54,7 +54,7 @@ export default function(SourceMapBuilder) {
result.imports = [];
for (const file in this.imports.files) {
if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {
if (Object.prototype.hasOwnProperty.call(this.imports.files, file) && file !== this.imports.rootFilename) {
result.imports.push(file);
}
}
@@ -63,4 +63,4 @@ export default function(SourceMapBuilder) {
}
return ParseTree;
};
}

View File

@@ -39,7 +39,7 @@ export default function(environment, ParseTree, ImportManager) {
rootFileInfo = options.rootFileInfo;
} else {
const filename = options.filename || 'input';
const entryPath = filename.replace(/[^\/\\]*$/, '');
const entryPath = filename.replace(/[^/\\]*$/, '');
rootFileInfo = {
filename,
rewriteUrls: context.rewriteUrls,
@@ -84,4 +84,4 @@ export default function(environment, ParseTree, ImportManager) {
}
};
return parse;
};
}

View File

@@ -119,4 +119,4 @@ export default function (input, fail) {
emitChunk(true);
return chunks;
};
}

View File

@@ -182,13 +182,14 @@ export default () => {
case '\r':
case '\n':
break;
case startChar:
case startChar: {
const str = input.substr(currentPosition, i + 1);
if (!loc && loc !== 0) {
skipWhitespace(i + 1);
return str
}
return [startChar, str];
}
default:
}
}
@@ -220,7 +221,6 @@ export default () => {
}
do {
let prevChar;
let nextChar = input.charAt(i);
if (blockDepth === 0 && testChar(nextChar)) {
returnVal = input.substr(lastPos, i - lastPos);
@@ -286,7 +286,7 @@ export default () => {
break;
case '}':
case ')':
case ']':
case ']': {
const expected = blockStack.pop();
if (nextChar === expected) {
blockDepth--;
@@ -296,13 +296,13 @@ export default () => {
returnVal = expected;
loop = false;
}
}
}
i++;
if (i > length) {
loop = false;
}
}
prevChar = nextChar;
} while (loop);
return returnVal ? returnVal : null;

View File

@@ -154,7 +154,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
error('@plugin statements are not allowed when disablePluginRule is set to true');
}
}
};
}
globalVars = (additionalData && additionalData.globalVars) ? `${Parser.serializeVars(additionalData.globalVars)}\n` : '';
modifyVars = (additionalData && additionalData.modifyVars) ? `\n${Parser.serializeVars(additionalData.modifyVars)}` : '';
@@ -422,7 +422,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
parserInput.save();
name = parserInput.$re(/^([\w-]+|%|~|progid:[\w\.]+)\(/);
name = parserInput.$re(/^([\w-]+|%|~|progid:[\w.]+)\(/);
if (!name) {
parserInput.forget();
return;
@@ -576,7 +576,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
}
value = this.quoted() || this.variable() || this.property() ||
parserInput.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || '';
parserInput.$re(/^(?:(?:\\[()'"])|[^()'"])+/) || '';
parserInput.autoCommentAbsorb = true;
@@ -661,7 +661,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
let rgb;
parserInput.save();
if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#\[])?/))) {
if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#[])?/))) {
if (!rgb[2]) {
parserInput.forget();
return new(tree.Color)(rgb[1], undefined, rgb[0]);
@@ -712,7 +712,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
unicodeDescriptor: function () {
let ud;
ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/);
ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(-[0-9a-fA-F?]+)?/);
if (ud) {
return new(tree.UnicodeDescriptor)(ud[0]);
}
@@ -1161,7 +1161,6 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
ruleLookups: function() {
let rule;
let args;
const lookups = [];
if (parserInput.currentChar() !== '[') {
@@ -1170,7 +1169,6 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
while (true) {
parserInput.save();
args = null;
rule = this.lookupValue();
if (!rule && rule !== '') {
parserInput.restore();
@@ -1268,9 +1266,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
c = this.combinator();
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) ||
// eslint-disable-next-line no-control-regex
parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
parserInput.$char('*') || parserInput.$char('&') || this.attribute() ||
parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) ||
parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[.#:](?=@)/) ||
this.entities.variableCurly();
if (!e) {
@@ -1389,11 +1388,11 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
}
parserInput.commentStore.length = 0;
if (s.condition && selectors.length > 1) {
error("Guards are only currently allowed on a single selector.");
error('Guards are only currently allowed on a single selector.');
}
if (!parserInput.$char(',')) { break; }
if (s.condition) {
error("Guards are only currently allowed on a single selector.");
error('Guards are only currently allowed on a single selector.');
}
parserInput.commentStore.length = 0;
}
@@ -1413,7 +1412,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
let cif;
if (!(key = entities.variableCurly())) {
key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
key = expect(/^(?:[_A-Za-z0-9-*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
}
op = parserInput.$re(/^[|~*$^]?=/);
@@ -1580,7 +1579,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
},
anonymousValue: function () {
const index = parserInput.i;
const match = parserInput.$re(/^([^.#@\$+\/'"*`(;{}-]*);/);
const match = parserInput.$re(/^([^.#@$+/'"*`(;{}-]*);/);
if (match) {
return new(tree.Anonymous)(match[1], index + currentIndex);
}
@@ -1890,7 +1889,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
parserInput.restore();
return null;
}
const args = parserInput.$re(/^\s*([^\);]+)\)\s*/);
const args = parserInput.$re(/^\s*([^);]+)\)\s*/);
if (args[1]) {
parserInput.forget();
return args[1].trim();
@@ -2057,7 +2056,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
if (m) {
isSpaced = parserInput.isWhitespace(-1);
while (true) {
if (parserInput.peek(/^\/[*\/]/)) {
if (parserInput.peek(/^\/[*/]/)) {
break;
}
@@ -2232,7 +2231,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
parserInput.forget();
return body;
},
atomicCondition: function (needsParens) {
atomicCondition: function () {
const entities = this.entities;
const index = parserInput.i;
let a;
@@ -2240,10 +2239,9 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
let c;
let op;
function cond() {
const cond = (function() {
return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup();
}
cond = cond.bind(this);
}).bind(this)
a = cond();
if (a) {
@@ -2292,7 +2290,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
const entities = this.entities;
let negate;
if (parserInput.peek(/^-[@\$\(]/)) {
if (parserInput.peek(/^-[@$(]/)) {
negate = parserInput.$char('-');
}
@@ -2338,7 +2336,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
if (e) {
entities.push(e);
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
if (!parserInput.peek(/^\/[\/*]/)) {
if (!parserInput.peek(/^\/[/*]/)) {
delim = parserInput.$char('/');
if (delim) {
entities.push(new(tree.Anonymous)(delim, index + currentIndex));
@@ -2382,7 +2380,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
match(/^(\*?)/);
while (true) {
if (!match(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/)) {
if (!match(/^((?:[\w-]+)|(?:[@$]\{[\w-]+\}))/)) {
break;
}
}

View File

@@ -1,6 +1,6 @@
import * as utils from './utils';
export default function(environment, ParseTree, ImportManager) {
export default function(environment, ParseTree) {
const render = function (input, options, callback) {
if (typeof options === 'function') {
callback = options;
@@ -38,4 +38,4 @@ export default function(environment, ParseTree, ImportManager) {
};
return render;
};
}

View File

@@ -79,4 +79,4 @@ export default function (SourceMapOutput, environment) {
}
return SourceMapBuilder;
};
}

View File

@@ -116,6 +116,7 @@ export default function (environment) {
if (this._outputSourceFiles) {
for (const filename in this._contentsMap) {
// eslint-disable-next-line no-prototype-builtins
if (this._contentsMap.hasOwnProperty(filename)) {
let source = this._contentsMap[filename];
if (this._contentsIgnoredCharsMap[filename]) {
@@ -147,4 +148,4 @@ export default function (environment) {
}
return SourceMapOutput;
};
}

View File

@@ -54,7 +54,7 @@ export default function(root, options) {
*/
if (options.pluginManager) {
visitorIterator = options.pluginManager.visitor();
for (var i = 0; i < 2; i++) {
for (let i = 0; i < 2; i++) {
visitorIterator.first();
while ((v = visitorIterator.get())) {
if (v.isPreEvalVisitor) {
@@ -79,7 +79,7 @@ export default function(root, options) {
evaldRoot = root.eval(evalEnv);
for (var i = 0; i < visitors.length; i++) {
for (let i = 0; i < visitors.length; i++) {
visitors[i].run(evaldRoot);
}
@@ -94,4 +94,4 @@ export default function(root, options) {
}
return evaldRoot;
};
}

View File

@@ -32,7 +32,7 @@ Attribute.prototype = Object.assign(new Node(), {
}
if (this.cif) {
value = value + " " + this.cif;
value = value + ' ' + this.cif;
}
return `[${value}]`;

View File

@@ -58,6 +58,7 @@ Call.prototype = Object.assign(new Node(), {
result = funcCaller.call(this.args);
exitCalc();
} catch (e) {
// eslint-disable-next-line no-prototype-builtins
if (e.hasOwnProperty('line') && e.hasOwnProperty('column')) {
throw e;
}

View File

@@ -96,6 +96,7 @@ Color.prototype = Object.assign(new Node(), {
break;
case 'hsla':
args.push(clamp(alpha, 1));
// eslint-disable-next-line no-fallthrough
case 'hsl':
color = this.toHSL();
args = [
@@ -212,6 +213,7 @@ Color.prototype = Object.assign(new Node(), {
Color.fromKeyword = function(keyword) {
let c;
const key = keyword.toLowerCase();
// eslint-disable-next-line no-prototype-builtins
if (colors.hasOwnProperty(key)) {
c = new Color(colors[key].slice(1));
}

View File

@@ -7,9 +7,9 @@ function asMediaQuery(ctx) {
if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
filenameWithProtocol = `file://${filenameWithProtocol}`;
}
return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:\/\\])/g, function (a) {
return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:/\\])/g, function (a) {
if (a == '\\') {
a = '\/';
a = '/';
}
return `\\${a}`;
})}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`;

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-prototype-builtins */
import Node from './node';
import unitConversions from '../data/unit-conversions';
import Unit from './unit';
@@ -23,6 +24,8 @@ Dimension.prototype = Object.assign(new Node(), {
this.unit = visitor.visit(this.unit);
},
// remove when Nodes have JSDoc types
// eslint-disable-next-line no-unused-vars
eval(context) {
return this;
},
@@ -81,7 +84,7 @@ Dimension.prototype = Object.assign(new Node(), {
other = other.convertTo(this.unit.usedUnits());
if (context.strictUnits && other.unit.toString() !== unit.toString()) {
throw new Error(`Incompatible units. Change the units or use the unit function. `
throw new Error('Incompatible units. Change the units or use the unit function. '
+ `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`);
}
@@ -144,7 +147,6 @@ Dimension.prototype = Object.assign(new Node(), {
conversions = derivedConversions;
}
applyUnit = function (atomicUnit, denominator) {
/* jshint loopfunc:true */
if (group.hasOwnProperty(atomicUnit)) {
if (denominator) {
value = value / (group[atomicUnit] / group[targetUnit]);

View File

@@ -35,6 +35,8 @@ Extend.prototype = Object.assign(new Node(), {
return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());
},
// remove when Nodes have JSDoc types
// eslint-disable-next-line no-unused-vars
clone(context) {
return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());
},

View File

@@ -31,7 +31,7 @@ const Import = function(path, features, options, index, currentFileInfo, visibil
this.css = !this.options.less || this.options.inline;
} else {
const pathValue = this.getPath();
if (pathValue && /[#\.\&\?]css([\?;].*)?$/.test(pathValue)) {
if (pathValue && /[#.&?]css([?;].*)?$/.test(pathValue)) {
this.css = true;
}
}

View File

@@ -29,8 +29,8 @@ JsEvalNode.prototype = Object.assign(new Node(), {
const variables = context.frames[0].variables();
for (const k in variables) {
// eslint-disable-next-line no-prototype-builtins
if (variables.hasOwnProperty(k)) {
/* jshint loopfunc:true */
evalContext[k.slice(1)] = {
value: variables[k].value,
toJS: function () {

View File

@@ -14,7 +14,7 @@ NamespaceValue.prototype = Object.assign(new Node(), {
type: 'NamespaceValue',
eval(context) {
let i, j, name, rules = this.value.eval(context);
let i, name, rules = this.value.eval(context);
for (i = 0; i < this.lookups.length; i++) {
name = this.lookups[i];

View File

@@ -1,10 +1,8 @@
import * as utils from '../utils';
/**
* The reason why Node is a class and other nodes simply do not extend
* from Node (since we're transpiling) is due to this issue:
*
* https://github.com/less/less.js/issues/3434
* @see https://github.com/less/less.js/issues/3434
*/
class Node {
constructor() {
@@ -50,6 +48,8 @@ class Node {
toCSS(context) {
const strs = [];
this.genCSS(context, {
// remove when genCSS has JSDoc types
// eslint-disable-next-line no-unused-vars
add: function(chunk, fileInfo, index) {
strs.push(chunk);
},

View File

@@ -1,8 +1,6 @@
import Node from './node';
import Variable from './variable';
import Property from './property';
import * as utils from '../utils';
const Quoted = function(str, content, escaped, index, currentFileInfo) {
this.escaped = (escaped === undefined) ? true : escaped;

View File

@@ -45,7 +45,6 @@ Ruleset.prototype = Object.assign(new Node(), {
},
eval(context) {
const that = this;
let selectors;
let selCnt;
let selector;
@@ -62,7 +61,7 @@ Ruleset.prototype = Object.assign(new Node(), {
for (i = 0; i < selCnt; i++) {
selector = this.selectors[i].eval(context);
for (var j = 0; j < selector.elements.length; j++) {
for (let j = 0; j < selector.elements.length; j++) {
if (selector.elements[j].isVariable) {
hasVariable = true;
break;
@@ -84,7 +83,7 @@ Ruleset.prototype = Object.assign(new Node(), {
const selectorFileInfo = selectors[0].fileInfo();
new Parser(context, this.parse.importManager, selectorFileInfo, startingIndex).parseNode(
toParseSelectors.join(','),
["selectors"],
['selectors'],
function(err, result) {
if (result) {
selectors = utils.flattenArray(result);
@@ -201,7 +200,7 @@ Ruleset.prototype = Object.assign(new Node(), {
if (rule.selectors[0] && rule.selectors[0].isJustParentSelector()) {
rsRules.splice(i--, 1);
for (var j = 0; (subRule = rule.rules[j]); j++) {
for (let j = 0; (subRule = rule.rules[j]); j++) {
if (subRule instanceof Node) {
subRule.copyVisibilityInfo(rule.visibilityInfo());
if (!(subRule instanceof Declaration) || !subRule.variable) {
@@ -296,6 +295,7 @@ Ruleset.prototype = Object.assign(new Node(), {
if (r.type === 'Import' && r.root && r.root.variables) {
const vars = r.root.variables();
for (const name in vars) {
// eslint-disable-next-line no-prototype-builtins
if (vars.hasOwnProperty(name)) {
hash[name] = r.root.variable(name);
}

View File

@@ -95,7 +95,7 @@ Selector.prototype = Object.assign(new Node(), {
let elements = this.elements.map( function(v) {
return v.combinator.value + (v.value.value || v.value);
}).join('').match(/[,&#\*\.\w-]([\w-]|(\\.))*/g);
}).join('').match(/[,&#*.\w-]([\w-]|(\\.))*/g);
if (elements) {
if (elements[0] === '&') {

View File

@@ -78,7 +78,7 @@ Unit.prototype = Object.assign(new Node(), {
let groupName;
mapUnit = function (atomicUnit) {
/* jshint loopfunc:true */
// eslint-disable-next-line no-prototype-builtins
if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {
result[groupName] = atomicUnit;
}
@@ -87,6 +87,7 @@ Unit.prototype = Object.assign(new Node(), {
};
for (groupName in unitConversions) {
// eslint-disable-next-line no-prototype-builtins
if (unitConversions.hasOwnProperty(groupName)) {
group = unitConversions[groupName];
@@ -116,6 +117,7 @@ Unit.prototype = Object.assign(new Node(), {
this.denominator = [];
for (atomicUnit in counter) {
// eslint-disable-next-line no-prototype-builtins
if (counter.hasOwnProperty(atomicUnit)) {
const count = counter[atomicUnit];

View File

@@ -1,7 +1,7 @@
import Node from './node';
function escapePath(path) {
return path.replace(/[\(\)'"\s]/g, function(match) { return `\\${match}`; });
return path.replace(/[()'"\s]/g, function(match) { return `\\${match}`; });
}
const URL = function(val, index, currentFileInfo, isEvald) {
@@ -33,7 +33,7 @@ URL.prototype = Object.assign(new Node(), {
rootpath = this.fileInfo() && this.fileInfo().rootpath;
if (typeof rootpath === 'string' &&
typeof val.value === 'string' &&
context.pathRequiresRewrite(val.value)) {
context.pathRequiresRewrite(val.value)) {
if (!val.quote) {
rootpath = escapePath(rootpath);
}

View File

@@ -35,7 +35,7 @@ export function copyArray(arr) {
export function clone(obj) {
const cloned = {};
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
cloned[prop] = obj[prop];
}
}
@@ -100,7 +100,7 @@ export function copyOptions(obj1, obj2) {
export function merge(obj1, obj2) {
for (const prop in obj2) {
if (obj2.hasOwnProperty(prop)) {
if (Object.prototype.hasOwnProperty.call(obj2, prop)) {
obj1[prop] = obj2[prop];
}
}

View File

@@ -1,3 +1,7 @@
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
import tree from '../tree';
import Visitor from './visitor';
import logger from '../logger';

View File

@@ -1,3 +1,7 @@
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
import contexts from '../contexts';
import Visitor from './visitor';
import ImportSequencer from './import-sequencer';

View File

@@ -1,3 +1,7 @@
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
import Visitor from './visitor';
class JoinSelectorVisitor {

View File

@@ -1,3 +1,7 @@
/* eslint-disable no-unused-vars */
/**
* @todo - Remove unused when JSDoc types are added for visitor methods
*/
import tree from '../tree';
import Visitor from './visitor';

View File

@@ -3,48 +3,48 @@ module.exports = {
current: {
// src is used to build list of less files to compile
src: [
"benchmark/benchmark.less"
'benchmark/benchmark.less'
],
options: {
helpers: "benchmark/browseroptions.js",
specs: "benchmark/browserspec.js",
outfile: "tmp/browser/test-runner-benchmark-current.html"
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-current.html'
}
},
v3_10_3: {
// src is used to build list of less files to compile
src: [
"benchmark/benchmark.less"
'benchmark/benchmark.less'
],
options: {
helpers: "benchmark/browseroptions.js",
specs: "benchmark/browserspec.js",
outfile: "tmp/browser/test-runner-benchmark-v3_10_3.html",
less: "https://cdnjs.cloudflare.com/ajax/libs/less.js/3.10.3/less.min.js"
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-v3_10_3.html',
less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.10.3/less.min.js'
}
},
v3_9_0: {
// src is used to build list of less files to compile
src: [
"benchmark/benchmark.less"
'benchmark/benchmark.less'
],
options: {
helpers: "benchmark/browseroptions.js",
specs: "benchmark/browserspec.js",
outfile: "tmp/browser/test-runner-benchmark-v3_9_0.html",
less: "https://cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js"
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-v3_9_0.html',
less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js'
}
},
v2_7_3: {
// src is used to build list of less files to compile
src: [
"benchmark/benchmark.less"
'benchmark/benchmark.less'
],
options: {
helpers: "benchmark/browseroptions.js",
specs: "benchmark/browserspec.js",
outfile: "tmp/browser/test-runner-benchmark-v2_7_3.html",
less: "https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.3/less.min.js"
helpers: 'benchmark/browseroptions.js',
specs: 'benchmark/browserspec.js',
outfile: 'tmp/browser/test-runner-benchmark-v2_7_3.html',
less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.3/less.min.js'
}
}
}

View File

@@ -19,168 +19,168 @@ module.exports = {
`!${lessFolder}/_main/empty.less`
],
options: {
helpers: "test/browser/runner-main-options.js",
specs: "test/browser/runner-main-spec.js",
outfile: "tmp/browser/test-runner-main.html"
helpers: 'test/browser/runner-main-options.js',
specs: 'test/browser/runner-main-spec.js',
outfile: 'tmp/browser/test-runner-main.html'
}
},
legacy: {
src: [`${lessFolder}/legacy/*.less`],
options: {
helpers: "test/browser/runner-legacy-options.js",
specs: "test/browser/runner-legacy-spec.js",
outfile: "tmp/browser/test-runner-legacy.html"
helpers: 'test/browser/runner-legacy-options.js',
specs: 'test/browser/runner-legacy-spec.js',
outfile: 'tmp/browser/test-runner-legacy.html'
}
},
strictUnits: {
src: [`${lessFolder}/strict-units/*.less`],
options: {
helpers: "test/browser/runner-strict-units-options.js",
specs: "test/browser/runner-strict-units-spec.js",
outfile: "tmp/browser/test-runner-strict-units.html"
helpers: 'test/browser/runner-strict-units-options.js',
specs: 'test/browser/runner-strict-units-spec.js',
outfile: 'tmp/browser/test-runner-strict-units.html'
}
},
errors: {
src: [
`${lessFolder}/errors/*.less`,
`${testFolder}/errors/javascript-error.less`,
"test/browser/less/errors/*.less"
'test/browser/less/errors/*.less'
],
options: {
timeout: 20000,
helpers: "test/browser/runner-errors-options.js",
specs: "test/browser/runner-errors-spec.js",
outfile: "tmp/browser/test-runner-errors.html"
helpers: 'test/browser/runner-errors-options.js',
specs: 'test/browser/runner-errors-spec.js',
outfile: 'tmp/browser/test-runner-errors.html'
}
},
noJsErrors: {
src: [`${lessFolder}/no-js-errors/*.less`],
options: {
helpers: "test/browser/runner-no-js-errors-options.js",
specs: "test/browser/runner-no-js-errors-spec.js",
outfile: "tmp/browser/test-runner-no-js-errors.html"
helpers: 'test/browser/runner-no-js-errors-options.js',
specs: 'test/browser/runner-no-js-errors-spec.js',
outfile: 'tmp/browser/test-runner-no-js-errors.html'
}
},
browser: {
src: [
"test/browser/less/*.less",
"test/browser/less/plugin/*.less"
'test/browser/less/*.less',
'test/browser/less/plugin/*.less'
],
options: {
helpers: "test/browser/runner-browser-options.js",
specs: "test/browser/runner-browser-spec.js",
outfile: "tmp/browser/test-runner-browser.html"
helpers: 'test/browser/runner-browser-options.js',
specs: 'test/browser/runner-browser-spec.js',
outfile: 'tmp/browser/test-runner-browser.html'
}
},
relativeUrls: {
src: ["test/browser/less/relative-urls/*.less"],
src: ['test/browser/less/relative-urls/*.less'],
options: {
helpers: "test/browser/runner-relative-urls-options.js",
specs: "test/browser/runner-relative-urls-spec.js",
outfile: "tmp/browser/test-runner-relative-urls.html"
helpers: 'test/browser/runner-relative-urls-options.js',
specs: 'test/browser/runner-relative-urls-spec.js',
outfile: 'tmp/browser/test-runner-relative-urls.html'
}
},
rewriteUrls: {
src: ["test/browser/less/rewrite-urls/*.less"],
src: ['test/browser/less/rewrite-urls/*.less'],
options: {
helpers: "test/browser/runner-rewrite-urls-options.js",
specs: "test/browser/runner-rewrite-urls-spec.js",
outfile: "tmp/browser/test-runner-rewrite-urls.html"
helpers: 'test/browser/runner-rewrite-urls-options.js',
specs: 'test/browser/runner-rewrite-urls-spec.js',
outfile: 'tmp/browser/test-runner-rewrite-urls.html'
}
},
rootpath: {
src: ["test/browser/less/rootpath/*.less"],
src: ['test/browser/less/rootpath/*.less'],
options: {
helpers: "test/browser/runner-rootpath-options.js",
specs: "test/browser/runner-rootpath-spec.js",
outfile: "tmp/browser/test-runner-rootpath.html"
helpers: 'test/browser/runner-rootpath-options.js',
specs: 'test/browser/runner-rootpath-spec.js',
outfile: 'tmp/browser/test-runner-rootpath.html'
}
},
rootpathRelative: {
src: ["test/browser/less/rootpath-relative/*.less"],
src: ['test/browser/less/rootpath-relative/*.less'],
options: {
helpers: "test/browser/runner-rootpath-relative-options.js",
specs: "test/browser/runner-rootpath-relative-spec.js",
outfile: "tmp/browser/test-runner-rootpath-relative.html"
helpers: 'test/browser/runner-rootpath-relative-options.js',
specs: 'test/browser/runner-rootpath-relative-spec.js',
outfile: 'tmp/browser/test-runner-rootpath-relative.html'
}
},
rootpathRewriteUrls: {
src: ["test/browser/less/rootpath-rewrite-urls/*.less"],
src: ['test/browser/less/rootpath-rewrite-urls/*.less'],
options: {
helpers:
"test/browser/runner-rootpath-rewrite-urls-options.js",
specs: "test/browser/runner-rootpath-rewrite-urls-spec.js",
'test/browser/runner-rootpath-rewrite-urls-options.js',
specs: 'test/browser/runner-rootpath-rewrite-urls-spec.js',
outfile:
"tmp/browser/test-runner-rootpath-rewrite-urls.html"
'tmp/browser/test-runner-rootpath-rewrite-urls.html'
}
},
production: {
src: ["test/browser/less/production/*.less"],
src: ['test/browser/less/production/*.less'],
options: {
helpers: "test/browser/runner-production-options.js",
specs: "test/browser/runner-production-spec.js",
outfile: "tmp/browser/test-runner-production.html"
helpers: 'test/browser/runner-production-options.js',
specs: 'test/browser/runner-production-spec.js',
outfile: 'tmp/browser/test-runner-production.html'
}
},
modifyVars: {
src: ["test/browser/less/modify-vars/*.less"],
src: ['test/browser/less/modify-vars/*.less'],
options: {
helpers: "test/browser/runner-modify-vars-options.js",
specs: "test/browser/runner-modify-vars-spec.js",
outfile: "tmp/browser/test-runner-modify-vars.html"
helpers: 'test/browser/runner-modify-vars-options.js',
specs: 'test/browser/runner-modify-vars-spec.js',
outfile: 'tmp/browser/test-runner-modify-vars.html'
}
},
globalVars: {
src: ["test/browser/less/global-vars/*.less"],
src: ['test/browser/less/global-vars/*.less'],
options: {
helpers: "test/browser/runner-global-vars-options.js",
specs: "test/browser/runner-global-vars-spec.js",
outfile: "tmp/browser/test-runner-global-vars.html"
helpers: 'test/browser/runner-global-vars-options.js',
specs: 'test/browser/runner-global-vars-spec.js',
outfile: 'tmp/browser/test-runner-global-vars.html'
}
},
postProcessorPlugin: {
src: [`${lessFolder}/postProcessorPlugin/*.less`],
options: {
helpers: [
`test/plugins/postprocess/index.js`,
"test/browser/runner-postProcessorPlugin-options.js"
'test/plugins/postprocess/index.js',
'test/browser/runner-postProcessorPlugin-options.js'
],
specs: "test/browser/runner-postProcessorPlugin.js",
specs: 'test/browser/runner-postProcessorPlugin.js',
outfile:
"tmp/browser/test-runner-post-processor-plugin.html"
'tmp/browser/test-runner-post-processor-plugin.html'
}
},
preProcessorPlugin: {
src: [`${lessFolder}/preProcessorPlugin/*.less`],
options: {
helpers: [
`test/plugins/preprocess/index.js`,
"test/browser/runner-preProcessorPlugin-options.js"
'test/plugins/preprocess/index.js',
'test/browser/runner-preProcessorPlugin-options.js'
],
specs: "test/browser/runner-preProcessorPlugin.js",
outfile: "tmp/browser/test-runner-pre-processor-plugin.html"
specs: 'test/browser/runner-preProcessorPlugin.js',
outfile: 'tmp/browser/test-runner-pre-processor-plugin.html'
}
},
visitorPlugin: {
src: [`${lessFolder}/visitorPlugin/*.less`],
options: {
helpers: [
`test/plugins/visitor/index.js`,
"test/browser/runner-VisitorPlugin-options.js"
'test/plugins/visitor/index.js',
'test/browser/runner-VisitorPlugin-options.js'
],
specs: "test/browser/runner-VisitorPlugin.js",
outfile: "tmp/browser/test-runner-visitor-plugin.html"
specs: 'test/browser/runner-VisitorPlugin.js',
outfile: 'tmp/browser/test-runner-visitor-plugin.html'
}
},
filemanagerPlugin: {
src: [`${lessFolder}/filemanagerPlugin/*.less`],
options: {
helpers: [
`test/plugins/filemanager/index.js`,
"test/browser/runner-filemanagerPlugin-options.js"
'test/plugins/filemanager/index.js',
'test/browser/runner-filemanagerPlugin-options.js'
],
specs: "test/browser/runner-filemanagerPlugin.js",
outfile: "tmp/browser/test-runner-filemanager-plugin.html"
specs: 'test/browser/runner-filemanagerPlugin.js',
outfile: 'tmp/browser/test-runner-filemanager-plugin.html'
}
}
}

View File

@@ -1,3 +1,3 @@
describe("less.js browser test - rewrite urls", function() {
describe('less.js browser test - rewrite urls', function() {
testLessEqualsInDocument();
});

View File

@@ -1,7 +1,7 @@
(function(exports) {
var plugin = function(less) {
var FileManager = less.FileManager, TestFileManager = new FileManager();
function TestFileManager() { };
function TestFileManager() { }
TestFileManager.loadFile = function (filename, currentDirectory, options, environment, callback) {
if (filename.match(/.*\.test$/)) {
return less.environment.fileManagers[0].loadFile('colors.test', currentDirectory, options, environment, callback);

View File

@@ -2,16 +2,16 @@
console.log('Testing ES6 imports...')
import less from '..';
let lessRender = less.render;
const lessRender = less.render;
// then I call lessRender on something
let y = lessRender(`
lessRender(`
body {
a: 1;
b: 2;
c: 30;
d: 4;
}`, {sourceMap: {}}, function(error, output) {
if (error)
console.error(error)
}`, {sourceMap: {}}, function(error: any, output: any) {
if (error)
console.error(error)
})

View File

@@ -0,0 +1,7 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"rootDir": "./src",
},
"include": ["src/**/*"]
}

View File

@@ -1,12 +1,13 @@
{
"compilerOptions": {
"outDir": "./lib",
"rootDir": "./src",
"rootDir": ".",
"allowJs": true,
"sourceMap": true,
"inlineSources": true,
"esModuleInterop": true,
"importHelpers": true,
"noImplicitAny": true,
"target": "ES5"
},
"ts-node": {
@@ -14,6 +15,6 @@
"rootDir": "."
}
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
"include": ["**/*"],
"exclude": ["node_modules", "lib/**/*"]
}