Permalink
Browse files

Build: Switch from JSHint/JSCS to ESLint

Fixes #236
Closes #238
  • Loading branch information...
mgol committed Nov 2, 2016
1 parent 9cb1ddc commit 1cb2093f4abd5cef29de645875dd397b7521798c
Showing with 136 additions and 138 deletions.
  1. +8 −0 .eslintignore
  2. +8 −0 .eslintrc.json
  3. +6 −2 .gitignore
  4. +0 −5 .jscsrc
  5. +0 −17 .jshintrc
  6. +27 −37 Gruntfile.js
  7. +8 −6 build/release.js
  8. +8 −0 dist/.eslintrc.json
  9. +2 −2 package.json
  10. +25 −0 src/.eslintrc.json
  11. +0 −30 src/.jshintrc
  12. +2 −2 src/core.js
  13. +3 −3 src/event.js
  14. +6 −3 src/intro.js
  15. +5 −2 src/migrate.js
  16. +1 −1 src/offset.js
  17. +1 −1 src/outro.js
  18. +12 −20 test/{.jshintrc → .eslintrc.json}
  19. +6 −2 test/deferred.js
  20. +3 −3 test/event.js
  21. +1 −0 test/migrate.js
  22. +4 −2 test/testinit.js
View
@@ -0,0 +1,8 @@
coverage
external
node_modules
*.min.js
src/intro.js
src/outro.js
test/data/jquery-*.js
test/data/jquery.mobile-*.js
View
@@ -0,0 +1,8 @@
{
"extends": "jquery",
"root": true,
"env": {
"browser": false,
"node": true
}
}
View
@@ -1,4 +1,3 @@
dist
coverage
CDN
.project
@@ -8,4 +7,9 @@ CDN
*.patch
/*.html
.DS_Store
node_modules
# Ignore everything in dist folder except for eslint config
/dist/*
!/dist/.eslintrc.json
node_modules
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View
@@ -3,17 +3,6 @@ module.exports = function( grunt ) {
"use strict";
// The concatenated file won't pass onevar but our modules can
var readOptionalJSON = function( filepath ) {
var data = {};
try {
data = grunt.file.readJSON( filepath );
} catch ( e ) {}
return data;
},
srcHintOptions = readOptionalJSON( "src/.jshintrc" );
delete srcHintOptions.onevar;
// Project configuration.
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
@@ -77,13 +66,24 @@ module.exports = function( grunt ) {
force: true
}
},
jscs: {
src: [
"test/*.js",
"<%= files %>",
"Gruntfile.js",
"build/**/*.js"
]
eslint: {
options: {
// See https://github.com/sindresorhus/grunt-eslint/issues/119
quiet: true
},
dist: {
src: "dist/jquery-migrate.js"
},
dev: {
src: [
"Gruntfile.js",
"build/**/*.js",
"src/**/*.js",
"test/**/*.js"
]
}
},
npmcopy: {
all: {
@@ -97,24 +97,6 @@ module.exports = function( grunt ) {
"qunit/LICENSE.txt": "qunitjs/LICENSE.txt" }
}
},
jshint: {
dist: {
src: [ "dist/jquery-migrate.js" ],
options: srcHintOptions
},
tests: {
src: [ "test/*.js" ],
options: {
jshintrc: "test/.jshintrc"
}
},
grunt: {
src: [ "Gruntfile.js" ],
options: {
jshintrc: ".jshintrc"
}
}
},
uglify: {
all: {
files: {
@@ -144,7 +126,15 @@ module.exports = function( grunt ) {
// Just an alias
grunt.registerTask( "test", [ "qunit" ] );
grunt.registerTask( "lint", [ "jshint", "jscs" ] );
grunt.registerTask( "lint", [
// Running the full eslint task without breaking it down to targets
// would run the dist target first which would point to errors in the built
// file, making it harder to fix them. We want to check the built file only
// if we already know the source files pass the linter.
"eslint:dev",
"eslint:dist"
] );
grunt.registerTask( "build", [ "concat", "uglify", "lint" ] );
grunt.registerTask( "default", [ "build", "test" ] );
View
@@ -24,7 +24,7 @@ var releaseVersion,
// Windows needs the .cmd version but will find the non-.cmd
// On Windows, also ensure the HOME environment variable is set
gruntCmd = process.platform === "win32" ? "grunt.cmd" : "grunt",
npmCmd = process.platform == "win32" ? "npm.cmd" : "npm",
npmCmd = process.platform === "win32" ? "npm.cmd" : "npm",
readmeFile = "README.md",
packageFile = "package.json",
@@ -120,7 +120,7 @@ function initialize( next ) {
// (look for " BRANCH pushes to BRANCH (up to date)")
function checkGitStatus( next ) {
child.execFile( "git", [ "status" ], function( error, stdout, stderr ) {
child.execFile( "git", [ "status" ], function( error, stdout ) {
var onBranch = ( ( stdout || "" ).match( /On branch (\S+)/ ) || [] )[ 1 ];
if ( onBranch !== branch ) {
die( "Branches don't match: Wanted " + branch + ", got " + onBranch );
@@ -151,7 +151,7 @@ function updateVersions( next ) {
}
function gruntBuild( next ) {
exec( gruntCmd, [], function( error, stdout ) {
exec( gruntCmd, [], function( error, stdout, stderr ) {
if ( error ) {
die( error + stderr );
}
@@ -234,7 +234,7 @@ function updateSourceVersion( ver ) {
}
}
function updateReadmeVersion( ver ) {
function updateReadmeVersion() {
var readme = fs.readFileSync( readmeFile, "utf8" );
// Change version references from the old version to the new one.
@@ -243,8 +243,10 @@ function updateReadmeVersion( ver ) {
status( "Skipping " + readmeFile + " update (beta release)" );
} else {
status( "Updating " + readmeFile );
readme = readme
.replace( /jquery-migrate-\d+\.\d+\.\d+(?:-\w+)?/g, "jquery-migrate-" + releaseVersion );
readme = readme.replace(
/jquery-migrate-\d+\.\d+\.\d+(?:-\w+)?/g,
"jquery-migrate-" + releaseVersion
);
if ( !dryrun ) {
fs.writeFileSync( readmeFile, readme );
}
View
@@ -0,0 +1,8 @@
{
"extends": "../src/.eslintrc.json",
"root": true,
"rules": {
// That is okay for the built version
"no-multiple-empty-lines": "off"
}
}
View
@@ -28,15 +28,15 @@
"devDependencies": {
"chalk": "1.1.3",
"commitplease": "2.7.5",
"eslint-config-jquery": "1.0.0",
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-jshint": "1.0.0",
"grunt-contrib-uglify": "2.0.0",
"grunt-contrib-watch": "1.0.0",
"grunt-coveralls": "1.0.1",
"grunt-eslint": "19.0.0",
"grunt-git-authors": "3.2.0",
"grunt-jscs": "2.8.0",
"grunt-npmcopy": "0.1.0",
"grunt-qunit-istanbul": "0.6.0",
"jquery": "3.1.1",
View
@@ -0,0 +1,25 @@
{
"env": {
"browser": false,
"node": false
},
// Support: IE <=9 only, Android <=4.0 only
// The above browsers are failing a lot of tests in the ES5
// test suite at http://test262.ecmascript.org.
"parserOptions": {
"ecmaVersion": 3
},
"globals": {
"window": true,
"define": true,
"module": true,
"jQuery": true,
"migrateWarn": true,
"migrateWarnFunc": true,
"migrateWarnProp": true,
"noGlobal": true
}
}
View

This file was deleted.

Oops, something went wrong.
View
@@ -29,7 +29,7 @@ jQuery.find = function( selector ) {
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
// First see if qS thinks it's a valid selector, if so avoid a false positive
try {
document.querySelector( selector );
window.document.querySelector( selector );
} catch ( err1 ) {
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
@@ -40,7 +40,7 @@ jQuery.find = function( selector ) {
// If the regexp *may* have created an invalid selector, don't update it
// Note that there may be false alarms if selector uses jQuery extensions
try {
document.querySelector( selector );
window.document.querySelector( selector );
migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
args[ 0 ] = selector;
} catch ( err2 ) {
View
@@ -25,7 +25,7 @@ jQuery.event.fix = function( originalEvent ) {
migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
if ( ( props = fixHook.props ) && props.length ) {
while ( props.length ) {
jQuery.event.addProp( props.pop() );
jQuery.event.addProp( props.pop() );
}
}
}
@@ -67,12 +67,12 @@ jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
// Trigger "ready" event only once, on document ready
jQuery( function() {
jQuery( document ).triggerHandler( "ready" );
jQuery( window.document ).triggerHandler( "ready" );
} );
jQuery.event.special.ready = {
setup: function() {
if ( this === document ) {
if ( this === window.document ) {
migrateWarn( "'ready' event is deprecated" );
}
}
View
@@ -1,14 +1,17 @@
;(function( factory ) {
/* jshint browserify:true */
;( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery" ], window, factory );
} else if ( typeof module === "object" && module.exports ) {
// Node/CommonJS
// eslint-disable-next-line no-undef
module.exports = factory( require( "jquery" ), window );
} else {
// Browser globals
factory( jQuery, window );
}
}(function( jQuery, window ) {
} )( function( jQuery, window ) {
"use strict";
View
@@ -1,11 +1,14 @@
/* exported migrateWarn, migrateWarnFunc, migrateWarnProp */
( function() {
// Support: IE9 only
// IE9 only creates console object when dev tools are first opened
// Also, avoid Function#bind here to simplify PhantomJS usage
var log = window.console && window.console.log &&
function() { window.console.log.apply( window.console, arguments ); },
function() {
window.console.log.apply( window.console, arguments );
},
rbadVersions = /^[12]\./;
if ( !log ) {
@@ -79,7 +82,7 @@ function migrateWarnFunc( obj, prop, newFunc, msg ) {
};
}
if ( document.compatMode === "BackCompat" ) {
if ( window.document.compatMode === "BackCompat" ) {
// JQuery has never supported or tested Quirks Mode
migrateWarn( "jQuery is not compatible with Quirks Mode" );
View
@@ -11,7 +11,7 @@ jQuery.fn.offset = function() {
return origin;
}
docElem = ( elem.ownerDocument || document ).documentElement;
docElem = ( elem.ownerDocument || window.document ).documentElement;
if ( !jQuery.contains( docElem, elem ) ) {
migrateWarn( "jQuery.fn.offset() requires an element connected to a document" );
return origin;
View
@@ -1,2 +1,2 @@
return jQuery;
}));
} );
Oops, something went wrong.

0 comments on commit 1cb2093

Please sign in to comment.