Skip to content

Commit

Permalink
Migrate JSCS and JSHint to ESLint and fix various ESLint styling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-dean committed Jan 1, 2017
1 parent fda4565 commit 49cbe52
Show file tree
Hide file tree
Showing 40 changed files with 224 additions and 230 deletions.
87 changes: 87 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,87 @@
{
"env": {
"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,
"space-before-blocks": [
2,
"always"
],
"indent": [
2,
4,
{
"SwitchCase": 1
}
]
}
}
73 changes: 0 additions & 73 deletions .jscsrc

This file was deleted.

11 changes: 0 additions & 11 deletions .jshintrc

This file was deleted.

71 changes: 31 additions & 40 deletions Gruntfile.js
Expand Up @@ -68,17 +68,17 @@ module.exports = function (grunt) {
var sauceJobs = {};

var browserTests = [ "filemanager-plugin",
"visitor-plugin",
"global-vars",
"modify-vars",
"production",
"rootpath-relative",
"rootpath",
"relative-urls",
"browser",
"no-js-errors",
"legacy"
];
"visitor-plugin",
"global-vars",
"modify-vars",
"production",
"rootpath-relative",
"rootpath",
"relative-urls",
"browser",
"no-js-errors",
"legacy"
];

function makeJob(testName) {
sauceJobs[testName] = {
Expand Down Expand Up @@ -127,15 +127,15 @@ module.exports = function (grunt) {
build: 'build-' + hash
}
}, function (error, response, body) {
if (error) {
console.log(error);
callback(error);
} else if (response.statusCode !== 200) {
console.log(response);
callback(new Error('Unexpected response status'));
} else {
callback(null, result.passed);
}
if (error) {
console.log(error);
callback(error);
} else if (response.statusCode !== 200) {
console.log(response);
callback(new Error('Unexpected response status'));
} else {
callback(null, result.passed);
}
});
});

Expand Down Expand Up @@ -247,24 +247,16 @@ module.exports = function (grunt) {
}
},

jshint: {
options: {jshintrc: '.jshintrc'},
files: {
src: [
'Gruntfile.js',
'lib/less/**/*.js',
'lib/less-node/**/*.js',
'lib/less-browser/**/*.js',
'lib/less-rhino/**/*.js',
'bin/lessc'
]
}
},

jscs: {
src: ["test/**/*.js", "lib/less*/**/*.js", "bin/lessc"],
eslint: {
target: ["Gruntfile.js",
"test/**/*.js",
"lib/less*/**/*.js",
"bin/lessc",
"!test/browser/jasmine-jsreporter.js",
"!test/less/errors/plugin/plugin-error.js"
],
options: {
config: ".jscsrc"
configFile: ".eslintrc.json"
}
},

Expand Down Expand Up @@ -507,8 +499,7 @@ module.exports = function (grunt) {

var testTasks = [
'clean',
'jshint',
'jscs',
'eslint',
'shell:test',
'browsertest'
];
Expand All @@ -525,7 +516,7 @@ module.exports = function (grunt) {
grunt.registerTask('test', testTasks);

// Run all tests
grunt.registerTask('quicktest', testTasks.slice(0, testTasks.length -1));
grunt.registerTask('quicktest', testTasks.slice(0, testTasks.length - 1));

// generate a good test environment for testing sourcemaps
grunt.registerTask('sourcemap-test', [
Expand Down
4 changes: 2 additions & 2 deletions bin/lessc
Expand Up @@ -161,7 +161,7 @@ function render() {
sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
}

if (! input) {
if (!input) {
console.error("lessc: no input files");
console.error("");
printUsage();
Expand All @@ -176,7 +176,7 @@ function render() {
if (!existsSync(dir)) {
if (mkdirp === undefined) {
try {mkdirp = require('mkdirp');}
catch(e) { mkdirp = null; }
catch (e) { mkdirp = null; }
}
cmd = mkdirp && mkdirp.sync || fs.mkdirSync;
cmd(dir);
Expand Down
2 changes: 1 addition & 1 deletion lib/less-browser/cache.js
Expand Up @@ -17,7 +17,7 @@ module.exports = function(window, options, logger) {
if (modifyVars) {
cache.setItem(path + ':vars', JSON.stringify(modifyVars));
}
} catch(e) {
} catch (e) {
//TODO - could do with adding more robust error handling
logger.error('failed to save "' + path + '" to local storage for caching.');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/less-browser/utils.js
Expand Up @@ -16,7 +16,7 @@ module.exports = {
try {
options[opt] = JSON.parse(tag.dataset[opt]);
}
catch(_) {}
catch (_) {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/less-node/file-manager.js
Expand Up @@ -5,7 +5,7 @@ var path = require('path'),

try {
PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
} catch(e) {
} catch (e) {
}

var FileManager = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/less-node/fs.js
Expand Up @@ -3,7 +3,7 @@ try
{
fs = require("graceful-fs");
}
catch(e)
catch (e)
{
fs = require("fs");
}
Expand Down
4 changes: 2 additions & 2 deletions lib/less-node/image-size.js
@@ -1,7 +1,7 @@
module.exports = function(environment) {
var Dimension = require("../less/tree/dimension"),
Expression = require("../less/tree/expression"),
functionRegistry = require("./../less/functions/function-registry");
Expression = require("../less/tree/expression"),
functionRegistry = require("./../less/functions/function-registry");

function imageSize(functionContext, filePathNode) {
var filePath = filePathNode.value;
Expand Down
10 changes: 5 additions & 5 deletions lib/less-node/plugin-loader.js
Expand Up @@ -56,7 +56,7 @@ PluginLoader.prototype.tryLoadFromEnvironment = function(name, basePath, explici
try {
self.require = self.requireRelative(filename);
}
catch(e) {
catch (e) {
callback(e);
}
callback(null, data);
Expand All @@ -78,26 +78,26 @@ PluginLoader.prototype.tryLoadFromEnvironment = function(name, basePath, explici
try {
filename = require.resolve(path.join("../../../", name));
}
catch(e) {
catch (e) {
}
// is installed as a sub dependency of the current folder
try {
filename = require.resolve(path.join(process.cwd(), "node_modules", name));
}
catch(e) {
catch (e) {
}
// is referenced relative to the current directory
try {
filename = require.resolve(path.join(process.cwd(), name));
}
catch(e) {
catch (e) {
}
// unlikely - would have to be a dependency of where this code was running (less.js)...
if (name[0] !== '.') {
try {
filename = require.resolve(name);
}
catch(e) {
catch (e) {
}
}
if (basePath) {
Expand Down
2 changes: 1 addition & 1 deletion lib/less-node/url-file-manager.js
Expand Up @@ -21,7 +21,7 @@ UrlFileManager.prototype.loadFile = function(filename, currentDirectory, options
return new PromiseConstructor(function(fulfill, reject) {
if (request === undefined) {
try { request = require('request'); }
catch(e) { request = null; }
catch (e) { request = null; }
}
if (!request) {
reject({ type: 'File', message: "optional dependency 'request' required to import over http(s)\n" });
Expand Down

0 comments on commit 49cbe52

Please sign in to comment.