Ticket #43731: jshint.patch
File jshint.patch, 7.9 KB (added by , 7 years ago) |
---|
-
new file .jshintignore
diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000000..de37fcc6ab
- + 1 tests/qunit/vendor/* 2 tests/qunit/editor/** 3 4 src/wp-content/themes/twenty{eleven,twelve,thirteen}/** 5 src/wp-content/themes/twenty{fourteen,fifteen,sixteen}/js/html5.js 6 src/wp-content/themes/twentyseventeen/assets/js/html5.js 7 src/wp-content/themes/twentyseventeen/assets/js/jquery.scrollTo.js 8 9 src/wp-includes/js/media-* 10 11 src/wp-includes/js/codemirror/*.js 12 src/wp-admin/js/farbtastic.js 13 src/wp-includes/js/backbone*.js 14 src/wp-includes/js/swfobject.js 15 src/wp-includes/js/underscore*.js 16 src/wp-includes/js/colorpicker.js 17 src/wp-includes/js/hoverIntent.js 18 src/wp-includes/js/json2.js 19 src/wp-includes/js/tw-sack.js 20 src/wp-includes/js/twemoji.js 21 src/**/*.min.js 22 23 src/wp-content/plugins/**/*.min.js -
.jshintrc
diff --git a/.jshintrc b/.jshintrc index 1b7387f4a2..decf2015c7 100644
a b 1 1 { 2 2 "boss": true, 3 "curly": true,4 "eqeqeq": true,3 "curly": false, 4 "eqeqeq": false, 5 5 "eqnull": true, 6 6 "es3": true, 7 7 "expr": true, -
Gruntfile.js
diff --git a/Gruntfile.js b/Gruntfile.js index a551b308be..c03480414e 100644
a b module.exports = function(grunt) { 316 316 src: [] 317 317 } 318 318 }, 319 jshint: {320 options: grunt.file.readJSON('.jshintrc'),321 grunt: {322 src: ['Gruntfile.js']323 },324 tests: {325 src: [326 'tests/qunit/**/*.js',327 '!tests/qunit/vendor/*',328 '!tests/qunit/editor/**'329 ],330 options: grunt.file.readJSON('tests/qunit/.jshintrc')331 },332 themes: {333 expand: true,334 cwd: SOURCE_DIR + 'wp-content/themes',335 src: [336 'twenty*/**/*.js',337 '!twenty{eleven,twelve,thirteen}/**',338 // Third party scripts339 '!twenty{fourteen,fifteen,sixteen}/js/html5.js',340 '!twentyseventeen/assets/js/html5.js',341 '!twentyseventeen/assets/js/jquery.scrollTo.js'342 ]343 },344 media: {345 src: [346 SOURCE_DIR + 'wp-includes/js/media/**/*.js'347 ]348 },349 core: {350 expand: true,351 cwd: SOURCE_DIR,352 src: [353 'wp-admin/js/**/*.js',354 'wp-includes/js/*.js',355 // Built scripts.356 '!wp-includes/js/media-*',357 // WordPress scripts inside directories358 'wp-includes/js/jquery/jquery.table-hotkeys.js',359 'wp-includes/js/mediaelement/mediaelement-migrate.js',360 'wp-includes/js/mediaelement/wp-mediaelement.js',361 'wp-includes/js/mediaelement/wp-playlist.js',362 'wp-includes/js/plupload/handlers.js',363 'wp-includes/js/plupload/wp-plupload.js',364 'wp-includes/js/tinymce/plugins/wordpress/plugin.js',365 'wp-includes/js/tinymce/plugins/wp*/plugin.js',366 // Third party scripts367 '!wp-includes/js/codemirror/*.js',368 '!wp-admin/js/farbtastic.js',369 '!wp-includes/js/backbone*.js',370 '!wp-includes/js/swfobject.js',371 '!wp-includes/js/underscore*.js',372 '!wp-includes/js/colorpicker.js',373 '!wp-includes/js/hoverIntent.js',374 '!wp-includes/js/json2.js',375 '!wp-includes/js/tw-sack.js',376 '!wp-includes/js/twemoji.js',377 '!**/*.min.js'378 ],379 // Remove once other JSHint errors are resolved380 options: {381 curly: false,382 eqeqeq: false383 },384 // Limit JSHint's run to a single specified file:385 //386 // grunt jshint:core --file=filename.js387 //388 // Optionally, include the file path:389 //390 // grunt jshint:core --file=path/to/filename.js391 //392 filter: function( filepath ) {393 var index, file = grunt.option( 'file' );394 395 // Don't filter when no target file is specified396 if ( ! file ) {397 return true;398 }399 400 // Normalize filepath for Windows401 filepath = filepath.replace( /\\/g, '/' );402 index = filepath.lastIndexOf( '/' + file );403 404 // Match only the filename passed from cli405 if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {406 return true;407 }408 409 return false;410 }411 },412 plugins: {413 expand: true,414 cwd: SOURCE_DIR + 'wp-content/plugins',415 src: [416 '**/*.js',417 '!**/*.min.js'418 ],419 // Limit JSHint's run to a single specified plugin directory:420 //421 // grunt jshint:plugins --dir=foldername422 //423 filter: function( dirpath ) {424 var index, dir = grunt.option( 'dir' );425 426 // Don't filter when no target folder is specified427 if ( ! dir ) {428 return true;429 }430 431 dirpath = dirpath.replace( /\\/g, '/' );432 index = dirpath.lastIndexOf( '/' + dir );433 434 // Match only the folder name passed from cli435 if ( -1 !== index ) {436 return true;437 }438 439 return false;440 }441 }442 },443 319 jsdoc : { 444 320 dist : { 445 321 dest: 'jsdoc', … … module.exports = function(grunt) { 761 637 files: [ '**/*.php' ], 762 638 tasks: [ 'phpunit:default' ] 763 639 } 640 }, 641 exec: { 642 jshint: 'npm run jshint' 764 643 } 765 644 }); 766 645 … … module.exports = function(grunt) { 775 654 776 655 // Register tasks. 777 656 657 // Exec task. 658 grunt.loadNpmTasks('grunt-exec'); 659 778 660 // Webpack task. 779 661 grunt.loadNpmTasks( 'grunt-webpack' ); 780 662 … … module.exports = function(grunt) { 785 667 grunt.registerTask('colors', ['sass:colors', 'postcss:colors']); 786 668 787 669 // JSHint task. 788 grunt.registerTask( 'jshint:corejs', [ 789 'jshint:grunt', 790 'jshint:tests', 791 'jshint:themes', 792 'jshint:core', 793 'jshint:media' 794 ] ); 670 grunt.registerTask( 'jshint:corejs', ['exec:jshint'] ); 795 671 796 672 grunt.registerTask( 'restapi-jsclient', [ 797 673 'phpunit:restapi-jsclient', -
package.json
diff --git a/package.json b/package.json index 3a289ee1c7..a1afa3c8b2 100644
a b 9 9 "engines": { 10 10 "node": "8.9.3" 11 11 }, 12 "scripts": { 13 "jshint": "jshint Gruntfile.js tests/qunit src/wp-content/themes/twenty* src/wp-includes/js/media src/wp-includes/js/*.js src/wp-admin/js/**/*.js" 14 }, 12 15 "author": "The WordPress Contributors", 13 16 "license": "GPL-2.0-or-later", 14 17 "devDependencies": { … … 21 24 "grunt-contrib-copy": "~1.0.0", 22 25 "grunt-contrib-cssmin": "~1.0.2", 23 26 "grunt-contrib-imagemin": "~1.0.0", 24 "grunt-contrib-jshint": "~1.0.0",25 27 "grunt-contrib-qunit": "^1.2.0", 26 28 "grunt-contrib-uglify": "~2.0.0", 27 29 "grunt-contrib-watch": "~1.0.0", 30 "grunt-exec": "^3.0.0", 28 31 "grunt-includes": "~0.5.1", 29 32 "grunt-jsdoc": "^2.1.0", 30 33 "grunt-jsvalidate": "~0.2.2", … … 34 37 "grunt-replace": "~1.0.1", 35 38 "grunt-rtlcss": "~2.0.1", 36 39 "grunt-sass": "2.0.0", 37 "ink-docstrap": "^1.3.0",38 40 "grunt-webpack": "^3.0.2", 41 "ink-docstrap": "^1.3.0", 42 "jshint": "^2.9.5", 39 43 "matchdep": "~1.0.0", 40 44 "webpack": "^3.6.0", 41 45 "webpack-dev-server": "^2.9.1" -
tests/qunit/wp-admin/js/nav-menu.js
diff --git a/tests/qunit/wp-admin/js/nav-menu.js b/tests/qunit/wp-admin/js/nav-menu.js index de99e3d6f7..a7e1f37b3e 100644
a b 9 9 setTimeout( function() { 10 10 // QUnit may load this file without running it, in which case `assert` 11 11 // will never be set to `assertPassed` below. 12 assert && assert.equal( 13 eventsFired, 14 eventsExpected, 15 eventsExpected + ' wpNavMenu events should fire.' 16 ); 12 if ( assert ) { 13 assert.equal( 14 eventsFired, 15 eventsExpected, 16 eventsExpected + ' wpNavMenu events should fire.' 17 ); 18 } 17 19 }, 3000 ); 18 20 19 21 QUnit.test( 'Testing wpNavMenu event triggers.', function( assertPassed ) { -
tests/qunit/wp-includes/js/tinymce/tinymce-obsolete.js
diff --git a/tests/qunit/wp-includes/js/tinymce/tinymce-obsolete.js b/tests/qunit/wp-includes/js/tinymce/tinymce-obsolete.js index 9db1f9ac9d..d26ff2dddb 100644
a b 58 58 } 59 59 60 60 for ( tagName in attr ) { 61 if ( tags = html.match( new RegExp( '<' + tagName + ' [^>]+>', 'g' ) ) ) { 61 tags = html.match( new RegExp( '<' + tagName + ' [^>]+>', 'g' ) ); 62 if ( tags ) { 62 63 for ( tag in tags ) { 63 64 array = attr[tagName].split(' '); 64 65