chore: change eslint-rules for tasks/

- use es2017 rules as NodeJS supports it today
- add "prefer-const"
This commit is contained in:
Nils Knappmeier
2019-12-11 23:44:43 +01:00
committed by Nils Knappmeier
parent d1fb07b32b
commit dc5495216d
8 changed files with 49 additions and 53 deletions
-16
View File
@@ -1,16 +0,0 @@
{
"globals": {
"require": true
},
"rules": {
// Disabling for tests, for now.
"no-path-concat": 0,
"no-var": 0,
"no-shadow": 0,
"handle-callback-err": 0,
"no-console": 0,
"no-process-env": 0,
"dot-notation": [2, {"allowKeywords": true}]
}
}
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
extends: ['../.eslintrc.js'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2017,
ecmaFeatures: {}
},
rules: {
'no-process-env': 'off',
'prefer-const': 'warn'
}
};
+2 -2
View File
@@ -1,10 +1,10 @@
var _ = require('underscore'),
const _ = require('underscore'),
async = require('neo-async'),
metrics = require('../bench');
module.exports = function(grunt) {
grunt.registerTask('metrics', function() {
var done = this.async(),
const done = this.async(),
execName = grunt.option('name'),
events = {};
+6 -6
View File
@@ -1,16 +1,16 @@
var childProcess = require('child_process');
const childProcess = require('child_process');
module.exports = function(grunt) {
grunt.registerTask('parser', 'Generate jison parser.', function() {
var done = this.async();
const done = this.async();
var cmd = './node_modules/.bin/jison';
let cmd = './node_modules/.bin/jison';
if (process.platform === 'win32') {
cmd = 'node_modules\\.bin\\jison.cmd';
}
var child = childProcess.spawn(
const child = childProcess.spawn(
cmd,
['-m', 'js', 'src/handlebars.yy', 'src/handlebars.l'],
{ stdio: 'inherit' }
@@ -22,14 +22,14 @@ module.exports = function(grunt) {
return;
}
var src = [
const src = [
'src/parser-prefix.js',
'handlebars.js',
'src/parser-suffix.js'
]
.map(grunt.file.read)
.join('');
grunt.file.delete('handlebars.js');
grunt.file['delete']('handlebars.js');
grunt.file.write('lib/handlebars/compiler/parser.js', src);
grunt.log.writeln('Parser "lib/handlebars/compiler/parser.js" created.');
+8 -8
View File
@@ -1,4 +1,4 @@
var _ = require('underscore'),
const _ = require('underscore'),
async = require('neo-async'),
AWS = require('aws-sdk'),
git = require('./util/git'),
@@ -6,7 +6,7 @@ var _ = require('underscore'),
module.exports = function(grunt) {
grunt.registerTask('publish:latest', function() {
var done = this.async();
const done = this.async();
git.debug(function(remotes, branches) {
grunt.log.writeln('remotes: ' + remotes);
@@ -15,7 +15,7 @@ module.exports = function(grunt) {
git.commitInfo(function(err, info) {
grunt.log.writeln('tag: ' + info.tagName);
var files = [];
const files = [];
// Publish the master as "latest" and with the commit-id
if (info.isMaster) {
@@ -40,7 +40,7 @@ module.exports = function(grunt) {
});
});
grunt.registerTask('publish:version', function() {
var done = this.async();
const done = this.async();
initSDK();
git.commitInfo(function(err, info) {
@@ -52,7 +52,7 @@ module.exports = function(grunt) {
});
function initSDK() {
var bucket = process.env.S3_BUCKET_NAME,
const bucket = process.env.S3_BUCKET_NAME,
key = process.env.S3_ACCESS_KEY_ID,
secret = process.env.S3_SECRET_ACCESS_KEY;
@@ -63,13 +63,13 @@ module.exports = function(grunt) {
AWS.config.update({ accessKeyId: key, secretAccessKey: secret });
}
function publish(files, callback) {
var s3 = new AWS.S3(),
const s3 = new AWS.S3(),
bucket = process.env.S3_BUCKET_NAME;
async.each(
_.keys(files),
function(file, callback) {
var params = {
const params = {
Bucket: bucket,
Key: file,
Body: grunt.file.read(files[file])
@@ -87,7 +87,7 @@ module.exports = function(grunt) {
);
}
function fileMap(suffixes) {
var map = {};
const map = {};
_.each(
[
'handlebars.js',
+15 -15
View File
@@ -1,13 +1,13 @@
var childProcess = require('child_process'),
const childProcess = require('child_process'),
fs = require('fs'),
os = require('os');
module.exports = function(grunt) {
grunt.registerTask('test:bin', function() {
var done = this.async();
const done = this.async();
var cmd = './bin/handlebars';
var args = ['-a', 'spec/artifacts/empty.handlebars'];
let cmd = './bin/handlebars';
const args = ['-a', 'spec/artifacts/empty.handlebars'];
// On Windows, the executable handlebars.js file cannot be run directly
if (os.platform() === 'win32') {
@@ -19,7 +19,7 @@ module.exports = function(grunt) {
throw err;
}
var expected = fs
const expected = fs
.readFileSync('./spec/expected/empty.amd.js')
.toString()
.replace(/\r\n/g, '\n');
@@ -38,9 +38,9 @@ module.exports = function(grunt) {
});
});
grunt.registerTask('test:mocha', function() {
var done = this.async();
const done = this.async();
var runner = childProcess.fork('./spec/env/runner', [], {
const runner = childProcess.fork('./spec/env/runner', [], {
stdio: 'inherit'
});
runner.on('close', function(code) {
@@ -51,24 +51,24 @@ module.exports = function(grunt) {
});
});
grunt.registerTask('test:cov', function() {
var done = this.async();
const done = this.async();
var runner = childProcess.fork(
const runner = childProcess.spawn(
'node_modules/istanbul/lib/cli.js',
['cover', '--source-map', '--', './spec/env/runner.js'],
{ stdio: 'inherit' }
);
runner.on('close', function(code) {
if (code != 0) {
runner.on('exit', function(code) {
if (code !== 0) {
grunt.fatal(code + ' tests failed');
}
done();
});
});
grunt.registerTask('test:min', function() {
var done = this.async();
const done = this.async();
var runner = childProcess.fork('./spec/env/runner', ['--min'], {
const runner = childProcess.fork('./spec/env/runner', ['--min'], {
stdio: 'inherit'
});
runner.on('close', function(code) {
@@ -80,9 +80,9 @@ module.exports = function(grunt) {
});
grunt.registerTask('test:check-cov', function() {
var done = this.async();
const done = this.async();
var runner = childProcess.fork(
const runner = childProcess.fork(
'node_modules/istanbul/lib/cli.js',
[
'check-coverage',
+3 -3
View File
@@ -1,4 +1,4 @@
var childProcess = require('child_process');
const childProcess = require('child_process');
module.exports = {
debug: function(callback) {
@@ -99,13 +99,13 @@ module.exports = {
throw new Error('git.tagName: ' + err.message);
}
var tags = stdout.trim().split(/\n/);
let tags = stdout.trim().split(/\n/);
tags = tags.filter(function(info) {
info = info.split('-');
return info.length == 1;
});
var versionTags = tags.filter(function(info) {
const versionTags = tags.filter(function(info) {
return /^v/.test(info[0]);
});
+3 -3
View File
@@ -1,4 +1,4 @@
var async = require('neo-async'),
const async = require('neo-async'),
git = require('./util/git'),
semver = require('semver');
@@ -7,7 +7,7 @@ module.exports = function(grunt) {
'version',
'Updates the current release version',
function() {
var done = this.async(),
const done = this.async(),
pkg = grunt.config('pkg'),
version = grunt.option('ver');
@@ -61,7 +61,7 @@ module.exports = function(grunt) {
);
function replace(path, regex, value) {
var content = grunt.file.read(path);
let content = grunt.file.read(path);
content = content.replace(regex, value);
grunt.file.write(path, content);
}