Skip to content

Commit dc54952

Browse files
committedDec 14, 2019
chore: change eslint-rules for tasks/
- use es2017 rules as NodeJS supports it today - add "prefer-const"
1 parent d1fb07b commit dc54952

File tree

8 files changed

+49
-53
lines changed

8 files changed

+49
-53
lines changed
 

Diff for: ‎tasks/.eslintrc

-16
This file was deleted.

Diff for: ‎tasks/.eslintrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
extends: ['../.eslintrc.js'],
3+
parserOptions: {
4+
sourceType: 'module',
5+
ecmaVersion: 2017,
6+
ecmaFeatures: {}
7+
},
8+
rules: {
9+
'no-process-env': 'off',
10+
'prefer-const': 'warn'
11+
}
12+
};

Diff for: ‎tasks/metrics.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var _ = require('underscore'),
1+
const _ = require('underscore'),
22
async = require('neo-async'),
33
metrics = require('../bench');
44

55
module.exports = function(grunt) {
66
grunt.registerTask('metrics', function() {
7-
var done = this.async(),
7+
const done = this.async(),
88
execName = grunt.option('name'),
99
events = {};
1010

Diff for: ‎tasks/parser.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
var childProcess = require('child_process');
1+
const childProcess = require('child_process');
22

33
module.exports = function(grunt) {
44
grunt.registerTask('parser', 'Generate jison parser.', function() {
5-
var done = this.async();
5+
const done = this.async();
66

7-
var cmd = './node_modules/.bin/jison';
7+
let cmd = './node_modules/.bin/jison';
88

99
if (process.platform === 'win32') {
1010
cmd = 'node_modules\\.bin\\jison.cmd';
1111
}
1212

13-
var child = childProcess.spawn(
13+
const child = childProcess.spawn(
1414
cmd,
1515
['-m', 'js', 'src/handlebars.yy', 'src/handlebars.l'],
1616
{ stdio: 'inherit' }
@@ -22,14 +22,14 @@ module.exports = function(grunt) {
2222
return;
2323
}
2424

25-
var src = [
25+
const src = [
2626
'src/parser-prefix.js',
2727
'handlebars.js',
2828
'src/parser-suffix.js'
2929
]
3030
.map(grunt.file.read)
3131
.join('');
32-
grunt.file.delete('handlebars.js');
32+
grunt.file['delete']('handlebars.js');
3333

3434
grunt.file.write('lib/handlebars/compiler/parser.js', src);
3535
grunt.log.writeln('Parser "lib/handlebars/compiler/parser.js" created.');

Diff for: ‎tasks/publish.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var _ = require('underscore'),
1+
const _ = require('underscore'),
22
async = require('neo-async'),
33
AWS = require('aws-sdk'),
44
git = require('./util/git'),
55
semver = require('semver');
66

77
module.exports = function(grunt) {
88
grunt.registerTask('publish:latest', function() {
9-
var done = this.async();
9+
const done = this.async();
1010

1111
git.debug(function(remotes, branches) {
1212
grunt.log.writeln('remotes: ' + remotes);
@@ -15,7 +15,7 @@ module.exports = function(grunt) {
1515
git.commitInfo(function(err, info) {
1616
grunt.log.writeln('tag: ' + info.tagName);
1717

18-
var files = [];
18+
const files = [];
1919

2020
// Publish the master as "latest" and with the commit-id
2121
if (info.isMaster) {
@@ -40,7 +40,7 @@ module.exports = function(grunt) {
4040
});
4141
});
4242
grunt.registerTask('publish:version', function() {
43-
var done = this.async();
43+
const done = this.async();
4444
initSDK();
4545

4646
git.commitInfo(function(err, info) {
@@ -52,7 +52,7 @@ module.exports = function(grunt) {
5252
});
5353

5454
function initSDK() {
55-
var bucket = process.env.S3_BUCKET_NAME,
55+
const bucket = process.env.S3_BUCKET_NAME,
5656
key = process.env.S3_ACCESS_KEY_ID,
5757
secret = process.env.S3_SECRET_ACCESS_KEY;
5858

@@ -63,13 +63,13 @@ module.exports = function(grunt) {
6363
AWS.config.update({ accessKeyId: key, secretAccessKey: secret });
6464
}
6565
function publish(files, callback) {
66-
var s3 = new AWS.S3(),
66+
const s3 = new AWS.S3(),
6767
bucket = process.env.S3_BUCKET_NAME;
6868

6969
async.each(
7070
_.keys(files),
7171
function(file, callback) {
72-
var params = {
72+
const params = {
7373
Bucket: bucket,
7474
Key: file,
7575
Body: grunt.file.read(files[file])
@@ -87,7 +87,7 @@ module.exports = function(grunt) {
8787
);
8888
}
8989
function fileMap(suffixes) {
90-
var map = {};
90+
const map = {};
9191
_.each(
9292
[
9393
'handlebars.js',

Diff for: ‎tasks/test.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var childProcess = require('child_process'),
1+
const childProcess = require('child_process'),
22
fs = require('fs'),
33
os = require('os');
44

55
module.exports = function(grunt) {
66
grunt.registerTask('test:bin', function() {
7-
var done = this.async();
7+
const done = this.async();
88

9-
var cmd = './bin/handlebars';
10-
var args = ['-a', 'spec/artifacts/empty.handlebars'];
9+
let cmd = './bin/handlebars';
10+
const args = ['-a', 'spec/artifacts/empty.handlebars'];
1111

1212
// On Windows, the executable handlebars.js file cannot be run directly
1313
if (os.platform() === 'win32') {
@@ -19,7 +19,7 @@ module.exports = function(grunt) {
1919
throw err;
2020
}
2121

22-
var expected = fs
22+
const expected = fs
2323
.readFileSync('./spec/expected/empty.amd.js')
2424
.toString()
2525
.replace(/\r\n/g, '\n');
@@ -38,9 +38,9 @@ module.exports = function(grunt) {
3838
});
3939
});
4040
grunt.registerTask('test:mocha', function() {
41-
var done = this.async();
41+
const done = this.async();
4242

43-
var runner = childProcess.fork('./spec/env/runner', [], {
43+
const runner = childProcess.fork('./spec/env/runner', [], {
4444
stdio: 'inherit'
4545
});
4646
runner.on('close', function(code) {
@@ -51,24 +51,24 @@ module.exports = function(grunt) {
5151
});
5252
});
5353
grunt.registerTask('test:cov', function() {
54-
var done = this.async();
54+
const done = this.async();
5555

56-
var runner = childProcess.fork(
56+
const runner = childProcess.spawn(
5757
'node_modules/istanbul/lib/cli.js',
5858
['cover', '--source-map', '--', './spec/env/runner.js'],
5959
{ stdio: 'inherit' }
6060
);
61-
runner.on('close', function(code) {
62-
if (code != 0) {
61+
runner.on('exit', function(code) {
62+
if (code !== 0) {
6363
grunt.fatal(code + ' tests failed');
6464
}
6565
done();
6666
});
6767
});
6868
grunt.registerTask('test:min', function() {
69-
var done = this.async();
69+
const done = this.async();
7070

71-
var runner = childProcess.fork('./spec/env/runner', ['--min'], {
71+
const runner = childProcess.fork('./spec/env/runner', ['--min'], {
7272
stdio: 'inherit'
7373
});
7474
runner.on('close', function(code) {
@@ -80,9 +80,9 @@ module.exports = function(grunt) {
8080
});
8181

8282
grunt.registerTask('test:check-cov', function() {
83-
var done = this.async();
83+
const done = this.async();
8484

85-
var runner = childProcess.fork(
85+
const runner = childProcess.fork(
8686
'node_modules/istanbul/lib/cli.js',
8787
[
8888
'check-coverage',

Diff for: ‎tasks/util/git.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var childProcess = require('child_process');
1+
const childProcess = require('child_process');
22

33
module.exports = {
44
debug: function(callback) {
@@ -99,13 +99,13 @@ module.exports = {
9999
throw new Error('git.tagName: ' + err.message);
100100
}
101101

102-
var tags = stdout.trim().split(/\n/);
102+
let tags = stdout.trim().split(/\n/);
103103
tags = tags.filter(function(info) {
104104
info = info.split('-');
105105
return info.length == 1;
106106
});
107107

108-
var versionTags = tags.filter(function(info) {
108+
const versionTags = tags.filter(function(info) {
109109
return /^v/.test(info[0]);
110110
});
111111

Diff for: ‎tasks/version.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var async = require('neo-async'),
1+
const async = require('neo-async'),
22
git = require('./util/git'),
33
semver = require('semver');
44

@@ -7,7 +7,7 @@ module.exports = function(grunt) {
77
'version',
88
'Updates the current release version',
99
function() {
10-
var done = this.async(),
10+
const done = this.async(),
1111
pkg = grunt.config('pkg'),
1212
version = grunt.option('ver');
1313

@@ -61,7 +61,7 @@ module.exports = function(grunt) {
6161
);
6262

6363
function replace(path, regex, value) {
64-
var content = grunt.file.read(path);
64+
let content = grunt.file.read(path);
6565
content = content.replace(regex, value);
6666
grunt.file.write(path, content);
6767
}

0 commit comments

Comments
 (0)
Please sign in to comment.