Skip to content

Commit

Permalink
Switch from jshint to eslint, fix linting errors and intent by 2 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Jan 16, 2018
1 parent a6be16d commit 989a7ee
Show file tree
Hide file tree
Showing 51 changed files with 29,953 additions and 26,124 deletions.
File renamed without changes.
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
'extends': 'eslint:recommended',
'parserOptions': {
'sourceType': 'module',
'ecmaVersion': 2017
},
'env': {
'node': true,
'es6': true,
'mocha': true,
'browser': true
},
'rules': {
'indent': ['error', 2, { 'SwitchCase': 1 }],
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
'semi': [2, 'always'],
'brace-style': ['error', '1tbs'],
'comma-style': ['error', 'last'],
'comma-spacing': ['error', {'after': true, 'before': false}],
'eol-last': ['error', 'always'],
'func-call-spacing': ['error', 'never'],
'semi-spacing': ['error', {'before': false, 'after': true}],
'keyword-spacing': ['error', {'before': true, 'after': true}],
'no-useless-escape': 'off',
'no-constant-condition': 'off'
},
'globals': {
'nunjucks': false
}
};
31 changes: 0 additions & 31 deletions .jshintrc

This file was deleted.

122 changes: 61 additions & 61 deletions bin/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,78 @@ var MINIFIED = false;
var TARGET = '';

var args = process.argv.slice(2);
while(args.length > 0) {
if(args.length === 1) {
TARGET = args[0];
while (args.length > 0) {
if (args.length === 1) {
TARGET = args[0];
} else {
switch (args[0]) {
case '-s':
SLIM = true;
TYPE = '(slim, only works with precompiled templates)';
break;
case '-m':
MINIFIED = true;
break;
}
else {
switch(args[0]) {
case '-s':
SLIM = true;
TYPE = '(slim, only works with precompiled templates)';
break;
case '-m':
MINIFIED = true;
break;
}
}
args.shift();
}
args.shift();
}

var config = {
entry: './index.js',
output: {
path: path.join(__dirname, '../browser'),
filename: TARGET,
library: 'nunjucks',
libraryTarget: 'umd'
},
node: {
process: 'empty'
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/(path|precompile)$/,
'node-libs-browser/mock/empty'),
new webpack.BannerPlugin(
'Browser bundle of nunjucks ' + VERSION + ' ' + TYPE
),
new webpack.DefinePlugin({
'process.env': {
IS_BROWSER: true
}
})
]
entry: './index.js',
output: {
path: path.join(__dirname, '../browser'),
filename: TARGET,
library: 'nunjucks',
libraryTarget: 'umd'
},
node: {
process: 'empty'
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/(path|precompile)$/,
'node-libs-browser/mock/empty'),
new webpack.BannerPlugin(
'Browser bundle of nunjucks ' + VERSION + ' ' + TYPE
),
new webpack.DefinePlugin({
'process.env': {
IS_BROWSER: true
}
})
]
};

if(SLIM) {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/(nodes|lexer|parser|transformer|compiler|loaders)$/,
'node-libs-browser/mock/empty'
)
);
}
else {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/loaders\.js$/,
'./web-loaders.js')
);
if (SLIM) {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/(nodes|lexer|parser|transformer|compiler|loaders)$/,
'node-libs-browser/mock/empty'
)
);
} else {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/loaders\.js$/,
'./web-loaders.js')
);
}

if(MINIFIED) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({ sourceMap: false })
);
if (MINIFIED) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: false
})
);
}

var outputOptions = {
cached: false,
cachedAssets: false
cached: false,
cachedAssets: false
};

webpack(config).run(function (err, stats) {
if(err) {
throw new Error(err);
}
console.log(stats.toString(outputOptions));
webpack(config).run(function(err, stats) {
if (err) {
throw new Error(err);
}
console.log(stats.toString(outputOptions)); // eslint-disable-line no-console
});
24 changes: 9 additions & 15 deletions browser/nunjucks-slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ return /******/ (function(modules) { // webpackBootstrap
var exports = module.exports = {};

exports.prettifyError = function(path, withInternals, err) {
// jshint -W022
// http://jslinterrors.com/do-not-assign-to-the-exception-parameter
if (!err.Update) {
if (!err.Update) {
// not one of ours, cast it
err = new exports.TemplateError(err);
}
Expand Down Expand Up @@ -1369,7 +1367,6 @@ return /******/ (function(modules) { // webpackBootstrap
F.prototype = cls.prototype;
var prototype = new F();

// jshint undef: false
var fnTest = /xyz/.test(function(){ xyz; }) ? /\bparent\b/ : /.*/;
props = props || {};

Expand All @@ -1380,8 +1377,7 @@ return /******/ (function(modules) { // webpackBootstrap
if(typeof parent === 'function' &&
typeof src === 'function' &&
fnTest.test(src)) {
/*jshint -W083 */
prototype[k] = (function (src, parent) {
prototype[k] = (function (src, parent) {
return function() {
// Save the current parent method
var tmp = this.parent;
Expand Down Expand Up @@ -2272,7 +2268,6 @@ return /******/ (function(modules) { // webpackBootstrap
throw new Error('Unable to call `' + name + '`, which is not a function');
}

// jshint validthis: true
return obj.apply(context, args);
}

Expand Down Expand Up @@ -2345,7 +2340,6 @@ return /******/ (function(modules) { // webpackBootstrap
case 3: func(item[0], item[1], item[2], i, len, done); break;
default:
item.push(i, done);
// jshint validthis: true
func.apply(this, item);
}
}
Expand Down Expand Up @@ -2899,12 +2893,12 @@ return /******/ (function(modules) { // webpackBootstrap

// This must be called like `nunjucks.installCompat` so that `this`
// references the nunjucks instance
var runtime = this.runtime; // jshint ignore:line
var lib = this.lib; // jshint ignore:line
var Compiler = this.compiler.Compiler; // jshint ignore:line
var Parser = this.parser.Parser; // jshint ignore:line
var nodes = this.nodes; // jshint ignore:line
var lexer = this.lexer; // jshint ignore:line
var runtime = this.runtime;
var lib = this.lib;
var Compiler = this.compiler.Compiler;
var Parser = this.parser.Parser;
var nodes = this.nodes;
var lexer = this.lexer;

var orig_contextOrFrameLookup = runtime.contextOrFrameLookup;
var orig_Compiler_assertType = Compiler.prototype.assertType;
Expand Down Expand Up @@ -3175,7 +3169,7 @@ return /******/ (function(modules) { // webpackBootstrap
OBJECT_MEMBERS.iteritems = OBJECT_MEMBERS.items;
OBJECT_MEMBERS.itervalues = OBJECT_MEMBERS.values;
OBJECT_MEMBERS.iterkeys = OBJECT_MEMBERS.keys;
runtime.memberLookup = function(obj, val, autoescape) { // jshint ignore:line
runtime.memberLookup = function(obj, val, autoescape) {
if (arguments.length === 4) {
return sliceLookup.apply(this, arguments);
}
Expand Down
8 changes: 2 additions & 6 deletions browser/nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ return /******/ (function(modules) { // webpackBootstrap
var exports = module.exports = {};

exports.prettifyError = function(path, withInternals, err) {
// jshint -W022
// http://jslinterrors.com/do-not-assign-to-the-exception-parameter
if (!err.Update) {
if (!err.Update) {
// not one of ours, cast it
err = new exports.TemplateError(err);
}
Expand Down Expand Up @@ -1369,7 +1367,6 @@ return /******/ (function(modules) { // webpackBootstrap
F.prototype = cls.prototype;
var prototype = new F();

// jshint undef: false
var fnTest = /xyz/.test(function(){ xyz; }) ? /\bparent\b/ : /.*/;
props = props || {};

Expand All @@ -1380,8 +1377,7 @@ return /******/ (function(modules) { // webpackBootstrap
if(typeof parent === 'function' &&
typeof src === 'function' &&
fnTest.test(src)) {
/*jshint -W083 */
prototype[k] = (function (src, parent) {
prototype[k] = (function (src, parent) {
return function() {
// Save the current parent method
var tmp = this.parent;
Expand Down

0 comments on commit 989a7ee

Please sign in to comment.