Skip to content

Commit 58c6ca9

Browse files
committed
Build: ESLint details
Use eslint pragmas, fix new errors, etc Closes gh-3148
1 parent a4474c9 commit 58c6ca9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+349
-457
lines changed

.eslintignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
external
2+
node_modules
3+
dist/jquery.min.js
24
test/data/jquery-1.9.1.js
35
test/data/badcall.js
46
test/data/badjson.js
@@ -8,5 +10,3 @@ test/data/readywaitloader.js
810
test/data/support/csp.js
911
test/data/support/getComputedSupport.js
1012
test/node_smoke_tests/lib/ensure_iterability.js
11-
node_modules
12-
dist

.eslintrc

Lines changed: 4 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,7 @@
11
{
2-
"env": {},
3-
"globals": {},
4-
"rules": {
5-
"no-cond-assign": [
6-
"error",
7-
"except-parens"
8-
],
9-
"curly": [
10-
"error",
11-
"all"
12-
],
13-
"object-curly-spacing": [
14-
"error",
15-
"always"
16-
],
17-
"computed-property-spacing": [
18-
"error",
19-
"always"
20-
],
21-
"array-bracket-spacing": [
22-
"error",
23-
"always"
24-
],
25-
"eqeqeq": [
26-
"error",
27-
"smart"
28-
],
29-
30-
// Shows errors where jshint wouldn't (see jshint "expr" rule)
31-
// clarifing this with eslint team
32-
// "no-unused-expressions": "error",
33-
"wrap-iife": [
34-
"error",
35-
"inside"
36-
],
37-
"no-caller": "error",
38-
"quotes": [
39-
"error",
40-
"double",
41-
"avoid-escape"
42-
],
43-
"no-undef": "error",
44-
"no-unused-vars": "error",
45-
"operator-linebreak": [
46-
"error",
47-
"after"
48-
],
49-
"comma-style": [
50-
"error",
51-
"last"
52-
],
53-
"camelcase": [
54-
"error",
55-
{
56-
"properties": "never"
57-
}
58-
],
59-
"dot-notation": [
60-
"error",
61-
{
62-
"allowPattern": "^[a-z]+(_[a-z]+)+$"
63-
}
64-
],
65-
"max-len": [
66-
"error",
67-
{
68-
"code": 100,
69-
"ignoreComments": true
70-
}
71-
],
72-
"no-mixed-spaces-and-tabs": "error",
73-
"no-trailing-spaces": "error",
74-
"no-multi-str": "error",
75-
"comma-dangle": [
76-
"error",
77-
"never"
78-
],
79-
"comma-spacing": [
80-
"error",
81-
{
82-
"before": false,
83-
"after": true
84-
}
85-
],
86-
"space-before-blocks": [
87-
"error",
88-
"always"
89-
],
90-
"space-in-parens": [
91-
"error",
92-
"always"
93-
],
94-
"keyword-spacing": [
95-
2
96-
],
97-
"semi": [
98-
"error",
99-
"always"
100-
],
101-
"semi-spacing": [
102-
"error",
103-
{
104-
// Because of the `for ( ; ...)` requirement
105-
// "before": true,
106-
"after": true
107-
}
108-
],
109-
"space-infix-ops": "error",
110-
"eol-last": "error",
111-
"lines-around-comment": [
112-
"error",
113-
{
114-
"beforeLineComment": true
115-
}
116-
],
117-
"linebreak-style": [
118-
"error",
119-
"unix"
120-
],
121-
"no-with": "error",
122-
"brace-style": "error",
123-
"space-before-function-paren": [
124-
"error",
125-
"never"
126-
],
127-
"no-loop-func": "error",
128-
"no-spaced-func": "error",
129-
"key-spacing": [
130-
"error",
131-
{
132-
"beforeColon": false,
133-
"afterColon": true
134-
}
135-
],
136-
"space-unary-ops": [
137-
"error",
138-
{
139-
"words": false,
140-
"nonwords": false
141-
}
142-
],
143-
"no-multiple-empty-lines": 2
2+
"extends": "eslint-config-jquery",
3+
"root": true,
4+
"env": {
5+
"node": true
1446
}
1457
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
npm-debug.log
1212

13-
/dist
13+
/dist/jquery*
1414
/node_modules
1515

1616
/test/node_smoke_tests/lib/ensure_iterability.js

.jshintignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

Gruntfile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ module.exports = function( grunt ) {
180180
// Integrate jQuery specific tasks
181181
grunt.loadTasks( "build/tasks" );
182182

183-
grunt.registerTask( "lint", [ "jsonlint" ] );
183+
grunt.registerTask( "lint", [ "jsonlint", "eslint:all" ] );
184184

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

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

205-
grunt.registerTask( "precommit_lint", [ "newer:jsonlint" ] );
206+
grunt.registerTask( "precommit_lint", [ "newer:jsonlint", "newer:eslint:all" ] );
206207
};

build/.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/release.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ module.exports = function( Release ) {
2121
Release.define( {
2222
npmPublish: true,
2323
issueTracker: "github",
24+
2425
/**
2526
* Ensure the repo is in a proper state before release
2627
* @param {Function} callback
2728
*/
2829
checkRepoState: function( callback ) {
2930
ensureSizzle( Release, callback );
3031
},
32+
3133
/**
3234
* Set the version in the src folder for distributing AMD
3335
*/
@@ -37,6 +39,7 @@ module.exports = function( Release ) {
3739
contents = contents.replace( /@VERSION/g, Release.newVersion );
3840
fs.writeFileSync( corePath, contents, "utf8" );
3941
},
42+
4043
/**
4144
* Generates any release artifacts that should be included in the release.
4245
* The callback must be invoked with an array of files that should be
@@ -54,6 +57,7 @@ module.exports = function( Release ) {
5457
Release._setSrcVersion();
5558
callback( files );
5659
},
60+
5761
/**
5862
* Acts as insertion point for restoring Release.dir.repo
5963
* It was changed to reuse npm publish code in jquery-release
@@ -65,6 +69,7 @@ module.exports = function( Release ) {
6569
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
6670
return npmTags();
6771
},
72+
6873
/**
6974
* Publish to distribution repo and npm
7075
* @param {Function} callback

build/tasks/build.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = function( grunt ) {
3838
// Avoid breaking semicolons inserted by r.js
3939
skipSemiColonInsertion: true,
4040
wrap: {
41-
start: wrapper[ 0 ].replace( /\/\*jshint .* \*\/\n/, "" ),
41+
start: wrapper[ 0 ].replace( /\/\*eslint .* \*\/\n/, "" ),
4242
end: globals.replace(
4343
/\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig,
4444
""
@@ -64,7 +64,12 @@ module.exports = function( grunt ) {
6464
// Convert var modules
6565
if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
6666
contents = contents
67-
.replace( /define\([\w\W]*?return/, "var " + ( /var\/([\w-]+)/.exec( name )[ 1 ] ) + " =" )
67+
.replace(
68+
/define\([\w\W]*?return/,
69+
"var " +
70+
( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
71+
" ="
72+
)
6873
.replace( rdefineEnd, "" );
6974

7075
// Sizzle treatment
@@ -130,6 +135,7 @@ module.exports = function( grunt ) {
130135
excluded = [],
131136
included = [],
132137
version = grunt.config( "pkg.version" ),
138+
133139
/**
134140
* Recursively calls the excluder to remove on all modules in the list
135141
* @param {Array} list
@@ -167,6 +173,7 @@ module.exports = function( grunt ) {
167173
} );
168174
}
169175
},
176+
170177
/**
171178
* Adds the specified module to the excluded or included list, depending on the flag
172179
* @param {String} flag A module path relative to

build/tasks/lib/spawn_test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* jshint node: true */
2-
31
"use strict";
42

53
// Run Node with provided parameters: the first one being the Grunt
@@ -13,4 +11,4 @@ module.exports = function spawnTest( done ) {
1311
.on( "close", function( code ) {
1412
done( code === 0 );
1513
} );
16-
} ;
14+
};

dist/.eslintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "../src/.eslintrc",
3+
"rules": {
4+
// That is okay for built version
5+
"no-multiple-empty-lines": "off",
6+
7+
// Because sizze is not compatible to jquery code style
8+
"lines-around-comment": "off",
9+
"space-in-parens": "off",
10+
"camelcase": "off",
11+
"computed-property-spacing": "off",
12+
"max-len": "off",
13+
"dot-notation": "off",
14+
"semi-spacing": "off",
15+
"brace-style": "off"
16+
}
17+
}

0 commit comments

Comments
 (0)