Skip to content

Commit

Permalink
Build: ESLint details
Browse files Browse the repository at this point in the history
Use eslint pragmas, fix new errors, etc

Closes jquerygh-3148
  • Loading branch information
markelog committed Jun 11, 2016
1 parent a4474c9 commit 58c6ca9
Show file tree
Hide file tree
Showing 46 changed files with 349 additions and 457 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 1,6 @@
external
node_modules
dist/jquery.min.js
test/data/jquery-1.9.1.js
test/data/badcall.js
test/data/badjson.js
Expand All @@ -8,5 10,3 @@ test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js
test/node_smoke_tests/lib/ensure_iterability.js
node_modules
dist
146 changes: 4 additions & 142 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,145 1,7 @@
{
"env": {},
"globals": {},
"rules": {
"no-cond-assign": [
"error",
"except-parens"
],
"curly": [
"error",
"all"
],
"object-curly-spacing": [
"error",
"always"
],
"computed-property-spacing": [
"error",
"always"
],
"array-bracket-spacing": [
"error",
"always"
],
"eqeqeq": [
"error",
"smart"
],

// Shows errors where jshint wouldn't (see jshint "expr" rule)
// clarifing this with eslint team
// "no-unused-expressions": "error",
"wrap-iife": [
"error",
"inside"
],
"no-caller": "error",
"quotes": [
"error",
"double",
"avoid-escape"
],
"no-undef": "error",
"no-unused-vars": "error",
"operator-linebreak": [
"error",
"after"
],
"comma-style": [
"error",
"last"
],
"camelcase": [
"error",
{
"properties": "never"
}
],
"dot-notation": [
"error",
{
"allowPattern": "^[a-z] (_[a-z] ) $"
}
],
"max-len": [
"error",
{
"code": 100,
"ignoreComments": true
}
],
"no-mixed-spaces-and-tabs": "error",
"no-trailing-spaces": "error",
"no-multi-str": "error",
"comma-dangle": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"space-before-blocks": [
"error",
"always"
],
"space-in-parens": [
"error",
"always"
],
"keyword-spacing": [
2
],
"semi": [
"error",
"always"
],
"semi-spacing": [
"error",
{
// Because of the `for ( ; ...)` requirement
// "before": true,
"after": true
}
],
"space-infix-ops": "error",
"eol-last": "error",
"lines-around-comment": [
"error",
{
"beforeLineComment": true
}
],
"linebreak-style": [
"error",
"unix"
],
"no-with": "error",
"brace-style": "error",
"space-before-function-paren": [
"error",
"never"
],
"no-loop-func": "error",
"no-spaced-func": "error",
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true
}
],
"space-unary-ops": [
"error",
{
"words": false,
"nonwords": false
}
],
"no-multiple-empty-lines": 2
"extends": "eslint-config-jquery",
"root": true,
"env": {
"node": true
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 10,7 @@

npm-debug.log

/dist
/dist/jquery*
/node_modules

/test/node_smoke_tests/lib/ensure_iterability.js
10 changes: 0 additions & 10 deletions .jshintignore

This file was deleted.

5 changes: 3 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 180,7 @@ module.exports = function( grunt ) {
// Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" );

grunt.registerTask( "lint", [ "jsonlint" ] );
grunt.registerTask( "lint", [ "jsonlint", "eslint:all" ] );

// Don't run Node-related tests in Node.js < 1.0.0 as they require an old
// jsdom version that needs compiling, making it harder for people to compile
Expand All @@ -194,6 194,7 @@ module.exports = function( grunt ) {
// Short list as a high frequency watch task
grunt.registerTask( "dev", [
"build:*:*",
"newer:eslint:dev",
"uglify",
"remove_map_comment",
"dist:*"
Expand All @@ -202,5 203,5 @@ module.exports = function( grunt ) {

grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );

grunt.registerTask( "precommit_lint", [ "newer:jsonlint" ] );
grunt.registerTask( "precommit_lint", [ "newer:jsonlint", "newer:eslint:all" ] );
};
7 changes: 0 additions & 7 deletions build/.eslintrc

This file was deleted.

5 changes: 5 additions & 0 deletions build/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 21,15 @@ module.exports = function( Release ) {
Release.define( {
npmPublish: true,
issueTracker: "github",

/**
* Ensure the repo is in a proper state before release
* @param {Function} callback
*/
checkRepoState: function( callback ) {
ensureSizzle( Release, callback );
},

/**
* Set the version in the src folder for distributing AMD
*/
Expand All @@ -37,6 39,7 @@ module.exports = function( Release ) {
contents = contents.replace( /@VERSION/g, Release.newVersion );
fs.writeFileSync( corePath, contents, "utf8" );
},

/**
* Generates any release artifacts that should be included in the release.
* The callback must be invoked with an array of files that should be
Expand All @@ -54,6 57,7 @@ module.exports = function( Release ) {
Release._setSrcVersion();
callback( files );
},

/**
* Acts as insertion point for restoring Release.dir.repo
* It was changed to reuse npm publish code in jquery-release
Expand All @@ -65,6 69,7 @@ module.exports = function( Release ) {
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
return npmTags();
},

/**
* Publish to distribution repo and npm
* @param {Function} callback
Expand Down
11 changes: 9 additions & 2 deletions build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 38,7 @@ module.exports = function( grunt ) {
// Avoid breaking semicolons inserted by r.js
skipSemiColonInsertion: true,
wrap: {
start: wrapper[ 0 ].replace( /\/\*jshint .* \*\/\n/, "" ),
start: wrapper[ 0 ].replace( /\/\*eslint .* \*\/\n/, "" ),
end: globals.replace(
/\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig,
""
Expand All @@ -64,7 64,12 @@ module.exports = function( grunt ) {
// Convert var modules
if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
contents = contents
.replace( /define\([\w\W]*?return/, "var " ( /var\/([\w-] )/.exec( name )[ 1 ] ) " =" )
.replace(
/define\([\w\W]*?return/,
"var "
( /var\/([\w-] )/.exec( name )[ 1 ] )
" ="
)
.replace( rdefineEnd, "" );

// Sizzle treatment
Expand Down Expand Up @@ -130,6 135,7 @@ module.exports = function( grunt ) {
excluded = [],
included = [],
version = grunt.config( "pkg.version" ),

/**
* Recursively calls the excluder to remove on all modules in the list
* @param {Array} list
Expand Down Expand Up @@ -167,6 173,7 @@ module.exports = function( grunt ) {
} );
}
},

/**
* Adds the specified module to the excluded or included list, depending on the flag
* @param {String} flag A module path relative to
Expand Down
4 changes: 1 addition & 3 deletions build/tasks/lib/spawn_test.js
Original file line number Diff line number Diff line change
@@ -1,5 1,3 @@
/* jshint node: true */

"use strict";

// Run Node with provided parameters: the first one being the Grunt
Expand All @@ -13,4 11,4 @@ module.exports = function spawnTest( done ) {
.on( "close", function( code ) {
done( code === 0 );
} );
} ;
};
17 changes: 17 additions & 0 deletions dist/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 1,17 @@
{
"extends": "../src/.eslintrc",
"rules": {
// That is okay for built version
"no-multiple-empty-lines": "off",

// Because sizze is not compatible to jquery code style
"lines-around-comment": "off",
"space-in-parens": "off",
"camelcase": "off",
"computed-property-spacing": "off",
"max-len": "off",
"dot-notation": "off",
"semi-spacing": "off",
"brace-style": "off"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 29,7 @@
"commitplease": "2.3.1",
"core-js": "2.2.2",
"cross-spawn": "2.2.3",
"eslint-config-jquery": "0.1.2",
"grunt": "1.0.1",
"grunt-babel": "6.0.0",
"grunt-cli": "1.2.0",
Expand Down
29 changes: 16 additions & 13 deletions src/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 1,18 @@
{
"env": {
"browser"
},
"extends": "../.eslintrc",
"root": true,
"globals": {
"window": true,
"JSON": false,
"jQuery": true,
"define": true,
"module": true,
"noGlobal": true
}
// 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,
"jQuery": true,
"define": true,
"module": true,
"noGlobal": true
},
"rules": {
"strict": ["error", "function"]
}
}
1 change: 1 addition & 0 deletions src/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 306,7 @@ jQuery.extend( {
processData: true,
async: true,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",

/*
timeout: 0,
data: null,
Expand Down
5 changes: 5 additions & 0 deletions src/attributes/val.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 143,16 @@ jQuery.extend( {

while ( i-- ) {
option = options[ i ];

/* eslint-disable no-cond-assign */

if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true;
}

/* eslint-enable no-cond-assign */
}

// Force browsers to behave consistently when non-matching value is set
Expand Down
Loading

0 comments on commit 58c6ca9

Please sign in to comment.