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" "!test/less/errors/plugin/plugin-error.js"
], ],
options: { options: {
configFile: ".eslintrc.json", configFile: ".eslintrc.js",
fix: true fix: true
} }
}, },

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,7 +29,7 @@ export default (window, options, logger) => {
let vars = cache && cache.getItem(`${path}:vars`); let vars = cache && cache.getItem(`${path}:vars`);
modifyVars = modifyVars || {}; 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 && if (timestamp && webInfo.lastModified &&
(new Date(webInfo.lastModified).valueOf() === (new Date(webInfo.lastModified).valueOf() ===

View File

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

View File

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

View File

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

View File

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

View File

@@ -61,6 +61,23 @@ FileManager.prototype = Object.assign(new AbstractFileManager(), {
function getFileData(fulfill, reject) { function getFileData(fulfill, reject) {
(function tryPathIndex(i) { (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) { if (i < paths.length) {
(function tryPrefix(j) { (function tryPrefix(j) {
if (j < prefixes.length) { if (j < prefixes.length) {
@@ -83,25 +100,7 @@ FileManager.prototype = Object.assign(new AbstractFileManager(), {
} }
else { else {
tryWithExtension(); 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]; const readFileArgs = [fullFilename];
if (!options.rawBuffer) { if (!options.rawBuffer) {

View File

@@ -88,4 +88,5 @@ const lessc_helper = {
}; };
// Exports helper functions // 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]; }} 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; const isUrlRe = /^(?:https?:)?\/\//i;
import url from 'url'; import url from 'url';
let request; let request;

View File

@@ -6,7 +6,7 @@ const copyFromOriginal = function copyFromOriginal(original, destination, proper
if (!original) { return; } if (!original) { return; }
for (let i = 0; i < propertiesToCopy.length; i++) { 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]]; destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];
} }
} }
@@ -113,7 +113,7 @@ contexts.Eval.prototype.pathRequiresRewrite = function (path) {
contexts.Eval.prototype.rewritePath = function (path, rootpath) { contexts.Eval.prototype.rewritePath = function (path, rootpath) {
let newPath; let newPath;
rootpath = rootpath || ''; rootpath = rootpath || '';
newPath = this.normalizePath(rootpath + path); newPath = this.normalizePath(rootpath + path);
// If a path was explicit relative and the rootpath was not an absolute 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. */ /* This option allows you to specify a argument to go on to every URL. */
urlArgs: '' urlArgs: ''
} }
}; }

View File

@@ -15,7 +15,7 @@ class AbstractFileManager {
} }
tryAppendExtension(path, ext) { tryAppendExtension(path, ext) {
return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext; return /(\.[a-z]*$)|([?;].*)$/.test(path) ? path : path + ext;
} }
tryAppendLessExtension(path) { tryAppendLessExtension(path) {
@@ -71,7 +71,13 @@ class AbstractFileManager {
return diff; 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) { extractUrlParts(url, baseUrl) {
// urlParts[1] = protocol://hostname/ OR / // urlParts[1] = protocol://hostname/ OR /
// urlParts[2] = / if path relative to host base // urlParts[2] = / if path relative to host base
@@ -79,7 +85,7 @@ class AbstractFileManager {
// urlParts[4] = filename // urlParts[4] = filename
// urlParts[5] = parameters // urlParts[5] = parameters
const urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i; const urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^/?#]*\/)|([/\\]))?((?:[^/\\?#]*[/\\])*)([^/\\?#]*)([#?].*)?$/i;
const urlParts = url.match(urlPartsRegex); const urlParts = url.match(urlPartsRegex);
const returner = {}; 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) { for (const f in colorBlendModeFunctions) {
// eslint-disable-next-line no-prototype-builtins
if (colorBlendModeFunctions.hasOwnProperty(f)) { if (colorBlendModeFunctions.hasOwnProperty(f)) {
colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]); colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);
} }

View File

@@ -121,6 +121,25 @@ colorFunctions = {
} }
}, },
hsla: function (h, s, l, a) { 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 { try {
if (h instanceof Color) { if (h instanceof Color) {
if (s) { if (s) {
@@ -131,25 +150,6 @@ colorFunctions = {
return new Color(h.rgb, a, 'hsla'); 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; h = (number(h) % 360) / 360;
s = clamp(number(s));l = clamp(number(l));a = clamp(number(a)); 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. // the registry by function-caller uses lower case as well.
name = name.toLowerCase(); name = name.toLowerCase();
// eslint-disable-next-line no-prototype-builtins
if (this._data.hasOwnProperty(name)) { if (this._data.hasOwnProperty(name)) {
// TODO warn // TODO warn
} }

View File

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

View File

@@ -15,6 +15,7 @@ const mathFunctions = {
}; };
for (const f in mathFunctions) { for (const f in mathFunctions) {
// eslint-disable-next-line no-prototype-builtins
if (mathFunctions.hasOwnProperty(f)) { if (mathFunctions.hasOwnProperty(f)) {
mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[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 Quoted from '../tree/quoted';
import URL from '../tree/url'; import URL from '../tree/url';
export default environment => { export default () => {
return { 'svg-gradient': function(direction) { return { 'svg-gradient': function(direction) {
let stops; let stops;
let gradientDirectionSvg; let gradientDirectionSvg;

View File

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

View File

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

View File

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

View File

@@ -54,7 +54,7 @@ export default function(SourceMapBuilder) {
result.imports = []; result.imports = [];
for (const file in this.imports.files) { 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); result.imports.push(file);
} }
} }
@@ -63,4 +63,4 @@ export default function(SourceMapBuilder) {
} }
return ParseTree; return ParseTree;
}; }

View File

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

View File

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

View File

@@ -182,13 +182,14 @@ export default () => {
case '\r': case '\r':
case '\n': case '\n':
break; break;
case startChar: case startChar: {
const str = input.substr(currentPosition, i + 1); const str = input.substr(currentPosition, i + 1);
if (!loc && loc !== 0) { if (!loc && loc !== 0) {
skipWhitespace(i + 1); skipWhitespace(i + 1);
return str return str
} }
return [startChar, str]; return [startChar, str];
}
default: default:
} }
} }
@@ -220,7 +221,6 @@ export default () => {
} }
do { do {
let prevChar;
let nextChar = input.charAt(i); let nextChar = input.charAt(i);
if (blockDepth === 0 && testChar(nextChar)) { if (blockDepth === 0 && testChar(nextChar)) {
returnVal = input.substr(lastPos, i - lastPos); returnVal = input.substr(lastPos, i - lastPos);
@@ -286,7 +286,7 @@ export default () => {
break; break;
case '}': case '}':
case ')': case ')':
case ']': case ']': {
const expected = blockStack.pop(); const expected = blockStack.pop();
if (nextChar === expected) { if (nextChar === expected) {
blockDepth--; blockDepth--;
@@ -296,13 +296,13 @@ export default () => {
returnVal = expected; returnVal = expected;
loop = false; loop = false;
} }
}
} }
i++; i++;
if (i > length) { if (i > length) {
loop = false; loop = false;
} }
} }
prevChar = nextChar;
} while (loop); } while (loop);
return returnVal ? returnVal : null; 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'); error('@plugin statements are not allowed when disablePluginRule is set to true');
} }
} }
}; }
globalVars = (additionalData && additionalData.globalVars) ? `${Parser.serializeVars(additionalData.globalVars)}\n` : ''; globalVars = (additionalData && additionalData.globalVars) ? `${Parser.serializeVars(additionalData.globalVars)}\n` : '';
modifyVars = (additionalData && additionalData.modifyVars) ? `\n${Parser.serializeVars(additionalData.modifyVars)}` : ''; modifyVars = (additionalData && additionalData.modifyVars) ? `\n${Parser.serializeVars(additionalData.modifyVars)}` : '';
@@ -422,7 +422,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
parserInput.save(); parserInput.save();
name = parserInput.$re(/^([\w-]+|%|~|progid:[\w\.]+)\(/); name = parserInput.$re(/^([\w-]+|%|~|progid:[\w.]+)\(/);
if (!name) { if (!name) {
parserInput.forget(); parserInput.forget();
return; return;
@@ -576,7 +576,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
} }
value = this.quoted() || this.variable() || this.property() || value = this.quoted() || this.variable() || this.property() ||
parserInput.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || ''; parserInput.$re(/^(?:(?:\\[()'"])|[^()'"])+/) || '';
parserInput.autoCommentAbsorb = true; parserInput.autoCommentAbsorb = true;
@@ -661,7 +661,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
let rgb; let rgb;
parserInput.save(); 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]) { if (!rgb[2]) {
parserInput.forget(); parserInput.forget();
return new(tree.Color)(rgb[1], undefined, rgb[0]); return new(tree.Color)(rgb[1], undefined, rgb[0]);
@@ -712,7 +712,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
unicodeDescriptor: function () { unicodeDescriptor: function () {
let ud; 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) { if (ud) {
return new(tree.UnicodeDescriptor)(ud[0]); return new(tree.UnicodeDescriptor)(ud[0]);
} }
@@ -1161,7 +1161,6 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
ruleLookups: function() { ruleLookups: function() {
let rule; let rule;
let args;
const lookups = []; const lookups = [];
if (parserInput.currentChar() !== '[') { if (parserInput.currentChar() !== '[') {
@@ -1170,7 +1169,6 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
while (true) { while (true) {
parserInput.save(); parserInput.save();
args = null;
rule = this.lookupValue(); rule = this.lookupValue();
if (!rule && rule !== '') { if (!rule && rule !== '') {
parserInput.restore(); parserInput.restore();
@@ -1268,9 +1266,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
c = this.combinator(); c = this.combinator();
e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) || 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.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
parserInput.$char('*') || parserInput.$char('&') || this.attribute() || parserInput.$char('*') || parserInput.$char('&') || this.attribute() ||
parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) || parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[.#:](?=@)/) ||
this.entities.variableCurly(); this.entities.variableCurly();
if (!e) { if (!e) {
@@ -1389,11 +1388,11 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
} }
parserInput.commentStore.length = 0; parserInput.commentStore.length = 0;
if (s.condition && selectors.length > 1) { 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 (!parserInput.$char(',')) { break; }
if (s.condition) { 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; parserInput.commentStore.length = 0;
} }
@@ -1413,7 +1412,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
let cif; let cif;
if (!(key = entities.variableCurly())) { 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(/^[|~*$^]?=/); op = parserInput.$re(/^[|~*$^]?=/);
@@ -1580,7 +1579,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
}, },
anonymousValue: function () { anonymousValue: function () {
const index = parserInput.i; const index = parserInput.i;
const match = parserInput.$re(/^([^.#@\$+\/'"*`(;{}-]*);/); const match = parserInput.$re(/^([^.#@$+/'"*`(;{}-]*);/);
if (match) { if (match) {
return new(tree.Anonymous)(match[1], index + currentIndex); return new(tree.Anonymous)(match[1], index + currentIndex);
} }
@@ -1890,7 +1889,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
parserInput.restore(); parserInput.restore();
return null; return null;
} }
const args = parserInput.$re(/^\s*([^\);]+)\)\s*/); const args = parserInput.$re(/^\s*([^);]+)\)\s*/);
if (args[1]) { if (args[1]) {
parserInput.forget(); parserInput.forget();
return args[1].trim(); return args[1].trim();
@@ -2057,7 +2056,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
if (m) { if (m) {
isSpaced = parserInput.isWhitespace(-1); isSpaced = parserInput.isWhitespace(-1);
while (true) { while (true) {
if (parserInput.peek(/^\/[*\/]/)) { if (parserInput.peek(/^\/[*/]/)) {
break; break;
} }
@@ -2232,7 +2231,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
parserInput.forget(); parserInput.forget();
return body; return body;
}, },
atomicCondition: function (needsParens) { atomicCondition: function () {
const entities = this.entities; const entities = this.entities;
const index = parserInput.i; const index = parserInput.i;
let a; let a;
@@ -2240,10 +2239,9 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
let c; let c;
let op; let op;
function cond() { const cond = (function() {
return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup(); return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup();
} }).bind(this)
cond = cond.bind(this);
a = cond(); a = cond();
if (a) { if (a) {
@@ -2292,7 +2290,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
const entities = this.entities; const entities = this.entities;
let negate; let negate;
if (parserInput.peek(/^-[@\$\(]/)) { if (parserInput.peek(/^-[@$(]/)) {
negate = parserInput.$char('-'); negate = parserInput.$char('-');
} }
@@ -2338,7 +2336,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
if (e) { if (e) {
entities.push(e); entities.push(e);
// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
if (!parserInput.peek(/^\/[\/*]/)) { if (!parserInput.peek(/^\/[/*]/)) {
delim = parserInput.$char('/'); delim = parserInput.$char('/');
if (delim) { if (delim) {
entities.push(new(tree.Anonymous)(delim, index + currentIndex)); entities.push(new(tree.Anonymous)(delim, index + currentIndex));
@@ -2382,7 +2380,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
match(/^(\*?)/); match(/^(\*?)/);
while (true) { while (true) {
if (!match(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/)) { if (!match(/^((?:[\w-]+)|(?:[@$]\{[\w-]+\}))/)) {
break; break;
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,9 +7,9 @@ function asMediaQuery(ctx) {
if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
filenameWithProtocol = `file://${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 == '\\') { if (a == '\\') {
a = '\/'; a = '/';
} }
return `\\${a}`; return `\\${a}`;
})}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`; })}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`;

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-prototype-builtins */
import Node from './node'; import Node from './node';
import unitConversions from '../data/unit-conversions'; import unitConversions from '../data/unit-conversions';
import Unit from './unit'; import Unit from './unit';
@@ -23,6 +24,8 @@ Dimension.prototype = Object.assign(new Node(), {
this.unit = visitor.visit(this.unit); this.unit = visitor.visit(this.unit);
}, },
// remove when Nodes have JSDoc types
// eslint-disable-next-line no-unused-vars
eval(context) { eval(context) {
return this; return this;
}, },
@@ -81,7 +84,7 @@ Dimension.prototype = Object.assign(new Node(), {
other = other.convertTo(this.unit.usedUnits()); other = other.convertTo(this.unit.usedUnits());
if (context.strictUnits && other.unit.toString() !== unit.toString()) { 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()}'.`); + `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`);
} }
@@ -144,7 +147,6 @@ Dimension.prototype = Object.assign(new Node(), {
conversions = derivedConversions; conversions = derivedConversions;
} }
applyUnit = function (atomicUnit, denominator) { applyUnit = function (atomicUnit, denominator) {
/* jshint loopfunc:true */
if (group.hasOwnProperty(atomicUnit)) { if (group.hasOwnProperty(atomicUnit)) {
if (denominator) { if (denominator) {
value = value / (group[atomicUnit] / group[targetUnit]); 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()); 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) { clone(context) {
return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); 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; this.css = !this.options.less || this.options.inline;
} else { } else {
const pathValue = this.getPath(); const pathValue = this.getPath();
if (pathValue && /[#\.\&\?]css([\?;].*)?$/.test(pathValue)) { if (pathValue && /[#.&?]css([?;].*)?$/.test(pathValue)) {
this.css = true; this.css = true;
} }
} }

View File

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

View File

@@ -14,7 +14,7 @@ NamespaceValue.prototype = Object.assign(new Node(), {
type: 'NamespaceValue', type: 'NamespaceValue',
eval(context) { 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++) { for (i = 0; i < this.lookups.length; i++) {
name = this.lookups[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 * 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: * 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 { class Node {
constructor() { constructor() {
@@ -50,6 +48,8 @@ class Node {
toCSS(context) { toCSS(context) {
const strs = []; const strs = [];
this.genCSS(context, { this.genCSS(context, {
// remove when genCSS has JSDoc types
// eslint-disable-next-line no-unused-vars
add: function(chunk, fileInfo, index) { add: function(chunk, fileInfo, index) {
strs.push(chunk); strs.push(chunk);
}, },

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
import Node from './node'; import Node from './node';
function escapePath(path) { 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) { const URL = function(val, index, currentFileInfo, isEvald) {
@@ -33,7 +33,7 @@ URL.prototype = Object.assign(new Node(), {
rootpath = this.fileInfo() && this.fileInfo().rootpath; rootpath = this.fileInfo() && this.fileInfo().rootpath;
if (typeof rootpath === 'string' && if (typeof rootpath === 'string' &&
typeof val.value === 'string' && typeof val.value === 'string' &&
context.pathRequiresRewrite(val.value)) { context.pathRequiresRewrite(val.value)) {
if (!val.quote) { if (!val.quote) {
rootpath = escapePath(rootpath); rootpath = escapePath(rootpath);
} }

View File

@@ -35,7 +35,7 @@ export function copyArray(arr) {
export function clone(obj) { export function clone(obj) {
const cloned = {}; const cloned = {};
for (const prop in obj) { for (const prop in obj) {
if (obj.hasOwnProperty(prop)) { if (Object.prototype.hasOwnProperty.call(obj, prop)) {
cloned[prop] = obj[prop]; cloned[prop] = obj[prop];
} }
} }
@@ -100,7 +100,7 @@ export function copyOptions(obj1, obj2) {
export function merge(obj1, obj2) { export function merge(obj1, obj2) {
for (const prop in obj2) { for (const prop in obj2) {
if (obj2.hasOwnProperty(prop)) { if (Object.prototype.hasOwnProperty.call(obj2, prop)) {
obj1[prop] = 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 tree from '../tree';
import Visitor from './visitor'; import Visitor from './visitor';
import logger from '../logger'; 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 contexts from '../contexts';
import Visitor from './visitor'; import Visitor from './visitor';
import ImportSequencer from './import-sequencer'; 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'; import Visitor from './visitor';
class JoinSelectorVisitor { 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 tree from '../tree';
import Visitor from './visitor'; import Visitor from './visitor';

View File

@@ -3,48 +3,48 @@ module.exports = {
current: { current: {
// src is used to build list of less files to compile // src is used to build list of less files to compile
src: [ src: [
"benchmark/benchmark.less" 'benchmark/benchmark.less'
], ],
options: { options: {
helpers: "benchmark/browseroptions.js", helpers: 'benchmark/browseroptions.js',
specs: "benchmark/browserspec.js", specs: 'benchmark/browserspec.js',
outfile: "tmp/browser/test-runner-benchmark-current.html" outfile: 'tmp/browser/test-runner-benchmark-current.html'
} }
}, },
v3_10_3: { v3_10_3: {
// src is used to build list of less files to compile // src is used to build list of less files to compile
src: [ src: [
"benchmark/benchmark.less" 'benchmark/benchmark.less'
], ],
options: { options: {
helpers: "benchmark/browseroptions.js", helpers: 'benchmark/browseroptions.js',
specs: "benchmark/browserspec.js", specs: 'benchmark/browserspec.js',
outfile: "tmp/browser/test-runner-benchmark-v3_10_3.html", 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" less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.10.3/less.min.js'
} }
}, },
v3_9_0: { v3_9_0: {
// src is used to build list of less files to compile // src is used to build list of less files to compile
src: [ src: [
"benchmark/benchmark.less" 'benchmark/benchmark.less'
], ],
options: { options: {
helpers: "benchmark/browseroptions.js", helpers: 'benchmark/browseroptions.js',
specs: "benchmark/browserspec.js", specs: 'benchmark/browserspec.js',
outfile: "tmp/browser/test-runner-benchmark-v3_9_0.html", 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" less: 'https://cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js'
} }
}, },
v2_7_3: { v2_7_3: {
// src is used to build list of less files to compile // src is used to build list of less files to compile
src: [ src: [
"benchmark/benchmark.less" 'benchmark/benchmark.less'
], ],
options: { options: {
helpers: "benchmark/browseroptions.js", helpers: 'benchmark/browseroptions.js',
specs: "benchmark/browserspec.js", specs: 'benchmark/browserspec.js',
outfile: "tmp/browser/test-runner-benchmark-v2_7_3.html", 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" 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` `!${lessFolder}/_main/empty.less`
], ],
options: { options: {
helpers: "test/browser/runner-main-options.js", helpers: 'test/browser/runner-main-options.js',
specs: "test/browser/runner-main-spec.js", specs: 'test/browser/runner-main-spec.js',
outfile: "tmp/browser/test-runner-main.html" outfile: 'tmp/browser/test-runner-main.html'
} }
}, },
legacy: { legacy: {
src: [`${lessFolder}/legacy/*.less`], src: [`${lessFolder}/legacy/*.less`],
options: { options: {
helpers: "test/browser/runner-legacy-options.js", helpers: 'test/browser/runner-legacy-options.js',
specs: "test/browser/runner-legacy-spec.js", specs: 'test/browser/runner-legacy-spec.js',
outfile: "tmp/browser/test-runner-legacy.html" outfile: 'tmp/browser/test-runner-legacy.html'
} }
}, },
strictUnits: { strictUnits: {
src: [`${lessFolder}/strict-units/*.less`], src: [`${lessFolder}/strict-units/*.less`],
options: { options: {
helpers: "test/browser/runner-strict-units-options.js", helpers: 'test/browser/runner-strict-units-options.js',
specs: "test/browser/runner-strict-units-spec.js", specs: 'test/browser/runner-strict-units-spec.js',
outfile: "tmp/browser/test-runner-strict-units.html" outfile: 'tmp/browser/test-runner-strict-units.html'
} }
}, },
errors: { errors: {
src: [ src: [
`${lessFolder}/errors/*.less`, `${lessFolder}/errors/*.less`,
`${testFolder}/errors/javascript-error.less`, `${testFolder}/errors/javascript-error.less`,
"test/browser/less/errors/*.less" 'test/browser/less/errors/*.less'
], ],
options: { options: {
timeout: 20000, timeout: 20000,
helpers: "test/browser/runner-errors-options.js", helpers: 'test/browser/runner-errors-options.js',
specs: "test/browser/runner-errors-spec.js", specs: 'test/browser/runner-errors-spec.js',
outfile: "tmp/browser/test-runner-errors.html" outfile: 'tmp/browser/test-runner-errors.html'
} }
}, },
noJsErrors: { noJsErrors: {
src: [`${lessFolder}/no-js-errors/*.less`], src: [`${lessFolder}/no-js-errors/*.less`],
options: { options: {
helpers: "test/browser/runner-no-js-errors-options.js", helpers: 'test/browser/runner-no-js-errors-options.js',
specs: "test/browser/runner-no-js-errors-spec.js", specs: 'test/browser/runner-no-js-errors-spec.js',
outfile: "tmp/browser/test-runner-no-js-errors.html" outfile: 'tmp/browser/test-runner-no-js-errors.html'
} }
}, },
browser: { browser: {
src: [ src: [
"test/browser/less/*.less", 'test/browser/less/*.less',
"test/browser/less/plugin/*.less" 'test/browser/less/plugin/*.less'
], ],
options: { options: {
helpers: "test/browser/runner-browser-options.js", helpers: 'test/browser/runner-browser-options.js',
specs: "test/browser/runner-browser-spec.js", specs: 'test/browser/runner-browser-spec.js',
outfile: "tmp/browser/test-runner-browser.html" outfile: 'tmp/browser/test-runner-browser.html'
} }
}, },
relativeUrls: { relativeUrls: {
src: ["test/browser/less/relative-urls/*.less"], src: ['test/browser/less/relative-urls/*.less'],
options: { options: {
helpers: "test/browser/runner-relative-urls-options.js", helpers: 'test/browser/runner-relative-urls-options.js',
specs: "test/browser/runner-relative-urls-spec.js", specs: 'test/browser/runner-relative-urls-spec.js',
outfile: "tmp/browser/test-runner-relative-urls.html" outfile: 'tmp/browser/test-runner-relative-urls.html'
} }
}, },
rewriteUrls: { rewriteUrls: {
src: ["test/browser/less/rewrite-urls/*.less"], src: ['test/browser/less/rewrite-urls/*.less'],
options: { options: {
helpers: "test/browser/runner-rewrite-urls-options.js", helpers: 'test/browser/runner-rewrite-urls-options.js',
specs: "test/browser/runner-rewrite-urls-spec.js", specs: 'test/browser/runner-rewrite-urls-spec.js',
outfile: "tmp/browser/test-runner-rewrite-urls.html" outfile: 'tmp/browser/test-runner-rewrite-urls.html'
} }
}, },
rootpath: { rootpath: {
src: ["test/browser/less/rootpath/*.less"], src: ['test/browser/less/rootpath/*.less'],
options: { options: {
helpers: "test/browser/runner-rootpath-options.js", helpers: 'test/browser/runner-rootpath-options.js',
specs: "test/browser/runner-rootpath-spec.js", specs: 'test/browser/runner-rootpath-spec.js',
outfile: "tmp/browser/test-runner-rootpath.html" outfile: 'tmp/browser/test-runner-rootpath.html'
} }
}, },
rootpathRelative: { rootpathRelative: {
src: ["test/browser/less/rootpath-relative/*.less"], src: ['test/browser/less/rootpath-relative/*.less'],
options: { options: {
helpers: "test/browser/runner-rootpath-relative-options.js", helpers: 'test/browser/runner-rootpath-relative-options.js',
specs: "test/browser/runner-rootpath-relative-spec.js", specs: 'test/browser/runner-rootpath-relative-spec.js',
outfile: "tmp/browser/test-runner-rootpath-relative.html" outfile: 'tmp/browser/test-runner-rootpath-relative.html'
} }
}, },
rootpathRewriteUrls: { rootpathRewriteUrls: {
src: ["test/browser/less/rootpath-rewrite-urls/*.less"], src: ['test/browser/less/rootpath-rewrite-urls/*.less'],
options: { options: {
helpers: helpers:
"test/browser/runner-rootpath-rewrite-urls-options.js", 'test/browser/runner-rootpath-rewrite-urls-options.js',
specs: "test/browser/runner-rootpath-rewrite-urls-spec.js", specs: 'test/browser/runner-rootpath-rewrite-urls-spec.js',
outfile: outfile:
"tmp/browser/test-runner-rootpath-rewrite-urls.html" 'tmp/browser/test-runner-rootpath-rewrite-urls.html'
} }
}, },
production: { production: {
src: ["test/browser/less/production/*.less"], src: ['test/browser/less/production/*.less'],
options: { options: {
helpers: "test/browser/runner-production-options.js", helpers: 'test/browser/runner-production-options.js',
specs: "test/browser/runner-production-spec.js", specs: 'test/browser/runner-production-spec.js',
outfile: "tmp/browser/test-runner-production.html" outfile: 'tmp/browser/test-runner-production.html'
} }
}, },
modifyVars: { modifyVars: {
src: ["test/browser/less/modify-vars/*.less"], src: ['test/browser/less/modify-vars/*.less'],
options: { options: {
helpers: "test/browser/runner-modify-vars-options.js", helpers: 'test/browser/runner-modify-vars-options.js',
specs: "test/browser/runner-modify-vars-spec.js", specs: 'test/browser/runner-modify-vars-spec.js',
outfile: "tmp/browser/test-runner-modify-vars.html" outfile: 'tmp/browser/test-runner-modify-vars.html'
} }
}, },
globalVars: { globalVars: {
src: ["test/browser/less/global-vars/*.less"], src: ['test/browser/less/global-vars/*.less'],
options: { options: {
helpers: "test/browser/runner-global-vars-options.js", helpers: 'test/browser/runner-global-vars-options.js',
specs: "test/browser/runner-global-vars-spec.js", specs: 'test/browser/runner-global-vars-spec.js',
outfile: "tmp/browser/test-runner-global-vars.html" outfile: 'tmp/browser/test-runner-global-vars.html'
} }
}, },
postProcessorPlugin: { postProcessorPlugin: {
src: [`${lessFolder}/postProcessorPlugin/*.less`], src: [`${lessFolder}/postProcessorPlugin/*.less`],
options: { options: {
helpers: [ helpers: [
`test/plugins/postprocess/index.js`, 'test/plugins/postprocess/index.js',
"test/browser/runner-postProcessorPlugin-options.js" 'test/browser/runner-postProcessorPlugin-options.js'
], ],
specs: "test/browser/runner-postProcessorPlugin.js", specs: 'test/browser/runner-postProcessorPlugin.js',
outfile: outfile:
"tmp/browser/test-runner-post-processor-plugin.html" 'tmp/browser/test-runner-post-processor-plugin.html'
} }
}, },
preProcessorPlugin: { preProcessorPlugin: {
src: [`${lessFolder}/preProcessorPlugin/*.less`], src: [`${lessFolder}/preProcessorPlugin/*.less`],
options: { options: {
helpers: [ helpers: [
`test/plugins/preprocess/index.js`, 'test/plugins/preprocess/index.js',
"test/browser/runner-preProcessorPlugin-options.js" 'test/browser/runner-preProcessorPlugin-options.js'
], ],
specs: "test/browser/runner-preProcessorPlugin.js", specs: 'test/browser/runner-preProcessorPlugin.js',
outfile: "tmp/browser/test-runner-pre-processor-plugin.html" outfile: 'tmp/browser/test-runner-pre-processor-plugin.html'
} }
}, },
visitorPlugin: { visitorPlugin: {
src: [`${lessFolder}/visitorPlugin/*.less`], src: [`${lessFolder}/visitorPlugin/*.less`],
options: { options: {
helpers: [ helpers: [
`test/plugins/visitor/index.js`, 'test/plugins/visitor/index.js',
"test/browser/runner-VisitorPlugin-options.js" 'test/browser/runner-VisitorPlugin-options.js'
], ],
specs: "test/browser/runner-VisitorPlugin.js", specs: 'test/browser/runner-VisitorPlugin.js',
outfile: "tmp/browser/test-runner-visitor-plugin.html" outfile: 'tmp/browser/test-runner-visitor-plugin.html'
} }
}, },
filemanagerPlugin: { filemanagerPlugin: {
src: [`${lessFolder}/filemanagerPlugin/*.less`], src: [`${lessFolder}/filemanagerPlugin/*.less`],
options: { options: {
helpers: [ helpers: [
`test/plugins/filemanager/index.js`, 'test/plugins/filemanager/index.js',
"test/browser/runner-filemanagerPlugin-options.js" 'test/browser/runner-filemanagerPlugin-options.js'
], ],
specs: "test/browser/runner-filemanagerPlugin.js", specs: 'test/browser/runner-filemanagerPlugin.js',
outfile: "tmp/browser/test-runner-filemanager-plugin.html" 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(); testLessEqualsInDocument();
}); });

View File

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

View File

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

View File

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

View File

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