Skip to content

Commit d27c0b8

Browse files
committed
Manually resolve remaining eslint errors
1 parent 027b25e commit d27c0b8

File tree

5 files changed

+66
-67
lines changed

5 files changed

+66
-67
lines changed

lib/map_old_to_new_file_path.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ const grunt = require( 'grunt' );
33
/**
44
* Replaces file names in the passed filePath with the file names in the fileMappings.
55
*
6-
* @param filePath The path to the file where the filenames should be replaced.
7-
* @param fileMappings The file names to replace and the file names they should be replaced with.
6+
* @param {string} filePath The path to the file where the filenames should be replaced.
7+
* @param {Object} fileMappings The file names to replace and the file names they should be replaced with.
88
*
99
* @return {void}
1010
*/
1111
function mapOldToNewFilePath( filePath, fileMappings ) {
12-
let body = grunt.file.read( filePath ),
13-
newBody,
14-
oldPath;
12+
const body = grunt.file.read( filePath );
13+
let newBody;
14+
let oldPath;
1515
for ( oldPath in fileMappings ) {
1616
// Ensure only own properties are looped over.
1717
if ( ! fileMappings.hasOwnProperty( oldPath ) ) {

lib/patch.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const grunt = require( 'grunt' ),
2-
_ = require( 'underscore' );
1+
const _ = require( 'underscore' );
32

43
_.str = _.str = require( 'underscore.string' );
54
_.mixin( _.str.exports() );
@@ -25,30 +24,31 @@ module.exports = {
2524
},
2625

2726
/**
28-
Check to see if we should apply the diff from the src dir
29-
30-
@return bool true if we should go into src to apply the diff
31-
*/
27+
* Check to see if we should apply the diff from the src dir
28+
*
29+
* @param {string} diff A string diff
30+
* @return {boolean} true if we should go into src to apply the diff
31+
*/
3232
moveToSrc( diff ) {
33-
let src = false,
34-
wpDashExceptions = [
35-
'.editorconfig',
36-
'.gitignore',
37-
'.jshintrc',
38-
'.travis.yml',
39-
'Gruntfile.js',
40-
'package.json',
41-
'phpunit.xml.dist',
42-
'wp-cli.yml',
43-
'wp-config-sample.php',
44-
'wp-tests-config-sample.php',
45-
],
46-
noWpDashExceptions = [
47-
'index.php',
48-
'license.txt',
49-
'readme.html',
50-
'xmlrpc.php',
51-
];
33+
let src = false;
34+
const wpDashExceptions = [
35+
'.editorconfig',
36+
'.gitignore',
37+
'.jshintrc',
38+
'.travis.yml',
39+
'Gruntfile.js',
40+
'package.json',
41+
'phpunit.xml.dist',
42+
'wp-cli.yml',
43+
'wp-config-sample.php',
44+
'wp-tests-config-sample.php',
45+
];
46+
const noWpDashExceptions = [
47+
'index.php',
48+
'license.txt',
49+
'readme.html',
50+
'xmlrpc.php',
51+
];
5252

5353
try {
5454
diff = diff.split( '\n' );

lib/trac.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const url = require( 'url' ),
22
grunt = require( 'grunt' );
33

44
module.exports = {
5-
convertToRaw( parsedUrl, options ) {
5+
convertToRaw( parsedUrl ) {
66
grunt.log.debug( 'convertToRaw: ' + JSON.stringify( parsedUrl ) );
77
parsedUrl.pathname = parsedUrl.pathname.replace( /attachment/, 'raw-attachment' );
88
grunt.log.debug( 'converted_from_raw: ' + url.format( parsedUrl ) );

tasks/patch_wordpress.js

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
* Licensed under the MIT license.
99
*/
1010

11-
const request = require( 'request' ),
12-
exec = require( 'child_process' ).exec,
13-
spawn = require( 'child_process' ).spawn,
14-
inquirer = require( 'inquirer' ),
15-
url = require( 'url' ),
16-
fs = require( 'fs' ),
17-
_ = require( 'underscore' ),
18-
trac = require( '../lib/trac.js' ),
19-
patch = require( '../lib/patch.js' ),
20-
regex = require( '../lib/regex.js' ),
21-
xmlrpc = require( 'xmlrpc' ),
22-
mapOldToNewFilePath = require( '../lib/map_old_to_new_file_path.js' );
11+
const request = require( 'request' );
12+
const exec = require( 'child_process' ).exec;
13+
const spawn = require( 'child_process' ).spawn;
14+
const inquirer = require( 'inquirer' );
15+
const url = require( 'url' );
16+
const fs = require( 'fs' );
17+
const _ = require( 'underscore' );
18+
const trac = require( '../lib/trac.js' );
19+
const patch = require( '../lib/patch.js' );
20+
const regex = require( '../lib/regex.js' );
21+
const xmlrpc = require( 'xmlrpc' );
22+
const mapOldToNewFilePath = require( '../lib/map_old_to_new_file_path.js' );
2323

2424
_.str = _.str = require( 'underscore.string' );
2525
_.mixin( _.str.exports() );
2626

2727
module.exports = function( grunt ) {
28-
let tempFile = 'wppatch.diff',
29-
defaults = {
30-
tracUrl: 'core.trac.wordpress.org',
31-
};
28+
let tempFile = 'wppatch.diff';
29+
const defaults = {
30+
tracUrl: 'core.trac.wordpress.org',
31+
};
3232

3333
function isSvn() {
3434
return fs.existsSync( '.svn' );
@@ -40,13 +40,12 @@ module.exports = function( grunt ) {
4040

4141
function applyPatch( patchUrl, done, options ) {
4242
grunt.verbose.write( patchUrl );
43-
parsedUrl = url.parse( patchUrl );
43+
const parsedUrl = url.parse( patchUrl );
4444

4545
// What to do when either our patch is ready
4646
grunt.event.once( 'fileReady', function( level, moveToSrc ) {
47-
let patchOptions = {},
48-
patchArgs = [],
49-
patchProcess;
47+
const patchOptions = {};
48+
const patchArgs = [];
5049

5150
// Set patch process to use the existing I/O streams, which will output
5251
// the command's results and allow for user input on patch error
@@ -71,7 +70,7 @@ module.exports = function( grunt ) {
7170
mapOldToNewFilePath( tempFile, options.file_mappings );
7271
}
7372

74-
patchProcess = spawn( 'patch', patchArgs, patchOptions );
73+
const patchProcess = spawn( 'patch', patchArgs, patchOptions );
7574

7675
patchProcess.on( 'exit', function( code, signal ) {
7776
if ( signal ) {
@@ -145,11 +144,11 @@ module.exports = function( grunt ) {
145144

146145
grunt.log.debug( 'getPatchFromTicket: ' + patchUrl );
147146
request( patchUrl, function( error, response, body ) {
148-
if ( ! error && 200 == response.statusCode ) {
147+
if ( ! error && 200 === response.statusCode ) {
149148
matches = regex.patchAttachments( body );
150149
grunt.log.debug( 'matches: ' + JSON.stringify( matches ) );
151150

152-
if ( null == matches ) {
151+
if ( null === matches ) {
153152
grunt.event.emit( 'fileFail', patchUrl + '\ncontains no attachments' );
154153
} else if ( 1 === matches.length ) {
155154
matchUrl = options.tracUrl + regex.urlsFromAttachmentList( matches[ 0 ] )[ 1 ];
@@ -197,7 +196,7 @@ module.exports = function( grunt ) {
197196
function getPatch( patchUrl ) {
198197
grunt.log.debug( 'getting patch: ' + patchUrl );
199198
request( patchUrl, function( error, response, body ) {
200-
if ( ! error && 200 == response.statusCode ) {
199+
if ( ! error && 200 === response.statusCode ) {
201200
const level = patch.isAb( body ) ? 1 : 0;
202201
const moveToSrc = patch.moveToSrc( body );
203202

@@ -234,7 +233,7 @@ module.exports = function( grunt ) {
234233

235234
function localFile( error, result, code, done, options ) {
236235
if ( ! error ) {
237-
files = _.filter( result.split( '\n' ), function( file ) {
236+
const files = _.filter( result.split( '\n' ), function( file ) {
238237
return ( _.str.include( file, 'patch' ) || _.str.include( file, 'diff' ) );
239238
} );
240239
grunt.log.debug( 'files: ' + JSON.stringify( files ) );
@@ -302,7 +301,7 @@ module.exports = function( grunt ) {
302301
const uploadPatchWithCredentials = function( username, password ) {
303302
const diffCommand = isSvn() ? 'svn diff --diff-cmd diff' : 'git diff';
304303

305-
exec( diffCommand, function( error, result, code ) {
304+
exec( diffCommand, function( error, result ) {
306305
const client = xmlrpc.createSecureClient( {
307306
hostname: options.tracUrl,
308307
port: 443,
@@ -320,7 +319,7 @@ module.exports = function( grunt ) {
320319
'', // description. empty for now.
321320
new Buffer( new Buffer( result ).toString( 'base64' ), 'base64' ),
322321
false, // never overwrite the old file
323-
], function( err, value ) {
322+
], function( err ) {
324323
if ( null === err ) {
325324
grunt.log.writeln( 'Uploaded patch.' );
326325
done();

test/regex.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const grunt = require( 'grunt' ),
2-
regex = require( '../lib/regex.js' ),
3-
html23988 = grunt.file.read( 'test/fixtures/23988.html' ),
4-
html23989 = grunt.file.read( 'test/fixtures/23989.html' ),
5-
html23994 = grunt.file.read( 'test/fixtures/23994.html' );
1+
const grunt = require( 'grunt' );
2+
const regex = require( '../lib/regex.js' );
3+
const html23988 = grunt.file.read( 'test/fixtures/23988.html' );
4+
const html23989 = grunt.file.read( 'test/fixtures/23989.html' );
5+
const html23994 = grunt.file.read( 'test/fixtures/23994.html' );
66

77
describe( 'regular expressions', function() {
88
it( 'multiple patches on a ticket with non patches as well', function() {
9-
const matches = regex.patchAttachments( html23988 ),
10-
longMatches = regex.longMatches( html23988 ),
11-
possiblePatches = regex.possiblePatches( longMatches );
9+
const matches = regex.patchAttachments( html23988 );
10+
const longMatches = regex.longMatches( html23988 );
11+
const possiblePatches = regex.possiblePatches( longMatches );
1212

1313
expect( matches.length ).toBe( 2 );
1414
expect( longMatches.length ).toBe( 4 );
@@ -23,7 +23,7 @@ describe( 'regular expressions', function() {
2323

2424
it( 'url from a list of attachments', function() {
2525
const matches = regex.patchAttachments( html23994 );
26-
url = 'core.trac.wordpress.org' + regex.urlsFromAttachmentList( matches[ 0 ] )[ 1 ];
26+
const url = 'core.trac.wordpress.org' + regex.urlsFromAttachmentList( matches[ 0 ] )[ 1 ];
2727

2828
expect( url ).toBe( 'core.trac.wordpress.org/attachment/ticket/23994/23994.diff' );
2929
} );

0 commit comments

Comments
 (0)