Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9bb014b

Browse files
committed
[WIP] chore(*): switch from JSHint/JSCS to ESLint
1 parent 6f56b89 commit 9bb014b

File tree

140 files changed

+5384
-4050
lines changed

Some content is hidden

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

140 files changed

+5384
-4050
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bower_components/**
2+
build/**
3+
docs/bower_components/**
4+
node_modules/**
5+
lib/htmlparser/**
6+
src/ngParseExt/ucd.js
7+
tmp/**

.eslintrc.json

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"root": true,
3+
4+
"env": {
5+
"node": true
6+
},
7+
8+
"globals": {},
9+
10+
"rules": {
11+
// Rules are divided into sections from http://eslint.org/docs/rules/
12+
13+
// Possible errors
14+
"comma-dangle": ["error", "never"],
15+
"no-cond-assign": ["error", "except-parens"],
16+
"no-constant-condition": "error",
17+
"no-control-regex": "error",
18+
"no-debugger": "error",
19+
"no-dupe-args": "error",
20+
"no-dupe-keys": "error",
21+
"no-duplicate-case": "error",
22+
"no-empty-character-class": "error",
23+
"no-empty": "error",
24+
"no-ex-assign": "error",
25+
"no-extra-boolean-cast": "error",
26+
"no-extra-semi": "error",
27+
"no-func-assign": "error",
28+
"no-inner-declarations": "error",
29+
"no-invalid-regexp": "error",
30+
"no-irregular-whitespace": "error",
31+
"no-negated-in-lhs": "error",
32+
"no-obj-calls": "error",
33+
"no-regex-spaces": "error",
34+
"no-sparse-arrays": "error",
35+
"no-unreachable": "error",
36+
"use-isnan": "error",
37+
"no-unsafe-finally": "error",
38+
"valid-typeof": "error",
39+
"no-unexpected-multiline": "error",
40+
41+
// Best practices
42+
"accessor-pairs": "error",
43+
"array-callback-return": "error",
44+
"complexity": ["warn", 10],
45+
// "dot-notation": "error", // TODO enable?
46+
// "dot-location": ["error", "property"], // TODO enable?
47+
"eqeqeq": ["error", "allow-null"],
48+
"no-alert": "error",
49+
"no-caller": "error",
50+
"no-case-declarations": "error",
51+
"no-eval": "error",
52+
"no-extend-native": "error",
53+
"no-extra-bind": "error",
54+
"no-extra-label": "error",
55+
"no-fallthrough": "error",
56+
"no-floating-decimal": "error",
57+
"no-implied-eval": "error",
58+
"no-invalid-this": "error",
59+
"no-iterator": "error",
60+
"no-multi-str": "error",
61+
"no-new-func": "error",
62+
"no-new-wrappers": "error",
63+
"no-new": "error",
64+
"no-octal-escape": "error",
65+
"no-octal": "error",
66+
"no-proto": "error",
67+
"no-redeclare": "error",
68+
"no-return-assign": "error",
69+
"no-script-url": "error",
70+
"no-self-assign": "error",
71+
"no-self-compare": "error",
72+
"no-sequences": "error",
73+
"no-throw-literal": "error",
74+
"no-unmodified-loop-condition": "error",
75+
"no-unused-expressions": "error",
76+
"no-unused-labels": "error",
77+
"no-useless-call": "error",
78+
"no-useless-concat": "error",
79+
"no-useless-escape": "error",
80+
"no-void": "error",
81+
"no-with": "error",
82+
"radix": "error",
83+
"wrap-iife": ["error", "inside"],
84+
85+
// Strict mode
86+
"strict": ["error", "global"],
87+
88+
// Variables
89+
"no-delete-var": "error",
90+
"no-label-var": "error",
91+
"no-restricted-globals": ["error", "event"],
92+
"no-shadow-restricted-names": "error",
93+
"no-undef-init": "error",
94+
"no-undef": "error",
95+
"no-unused-vars": ["error", { "vars": "local", "args": "none" }],
96+
97+
// Node.js
98+
"handle-callback-err": "error",
99+
100+
// Stylistic issues
101+
"array-bracket-spacing": ["error", "never"],
102+
// "block-spacing": ["error", "always"], // TODO enable?
103+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
104+
// "comma-spacing": "error", // TODO enable?
105+
"comma-style": ["error", "last"],
106+
"eol-last": "error",
107+
// "id-blacklist": ["error", "event"], // TODO enable?
108+
// "indent": ["error", 2], // TODO enable?
109+
// "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "minimum" }], // TODO enable?
110+
"keyword-spacing": "error",
111+
"linebreak-style": ["error", "unix"],
112+
"max-len": ["error", { "code": 200, "ignoreComments": true, "ignoreUrls": true }],
113+
"new-cap": "error",
114+
"new-parens": "error",
115+
"no-array-constructor": "error",
116+
"no-bitwise": "error",
117+
"no-mixed-spaces-and-tabs": "error",
118+
"no-multiple-empty-lines": ["error", { "max": 3, "maxEOF": 1 }],
119+
"no-whitespace-before-property": "error",
120+
"no-spaced-func": "error",
121+
"no-trailing-spaces": "error",
122+
"no-unneeded-ternary": "error",
123+
// "object-curly-spacing": ["error", "never"], // TODO enable?
124+
// "object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }], // TODO enable?
125+
// "operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" }}], // TODO enable?
126+
// "quotes": ["error", "single"], // TODO enable?
127+
"semi-spacing": "error",
128+
"semi": "error",
129+
"space-before-blocks": ["error", "always"],
130+
"space-before-function-paren": ["error", "never"],
131+
"space-in-parens": ["error", "never"],
132+
"space-infix-ops": "error",
133+
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
134+
"unicode-bom": ["error", "never"]
135+
}
136+
}

.jscsrc

-48
This file was deleted.

.jshintignore

-2
This file was deleted.

.jshintrc

-5
This file was deleted.

.jshintrc-base

-24
This file was deleted.

Gruntfile.js

+13-68
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function(grunt) {
1818

1919
var NG_VERSION = versionInfo.currentVersion;
2020
NG_VERSION.cdn = versionInfo.cdnVersion;
21-
var dist = 'angular-'+ NG_VERSION.full;
21+
var dist = 'angular-' + NG_VERSION.full;
2222

2323
if (versionInfo.cdnVersion == null) {
2424
throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?');
@@ -41,7 +41,7 @@ module.exports = function(grunt) {
4141
hostname: '0.0.0.0',
4242
base: '.',
4343
keepalive: true,
44-
middleware: function(connect, options){
44+
middleware: function(connect, options) {
4545
var base = Array.isArray(options.base) ? options.base[options.base.length - 1] : options.base;
4646
return [
4747
util.conditionalCsp(),
@@ -61,7 +61,7 @@ module.exports = function(grunt) {
6161
// to avoid https://github.com/joyent/libuv/issues/826
6262
port: 8000,
6363
hostname: '0.0.0.0',
64-
middleware: function(connect, options){
64+
middleware: function(connect, options) {
6565
var base = Array.isArray(options.base) ? options.base[options.base.length - 1] : options.base;
6666
return [
6767
function(req, resp, next) {
@@ -115,68 +115,13 @@ module.exports = function(grunt) {
115115
tmp: ['tmp']
116116
},
117117

118-
jshint: {
119-
options: {
120-
jshintrc: true,
121-
},
122-
node: {
123-
files: { src: ['*.js', 'lib/**/*.js'] },
124-
},
125-
tests: {
126-
files: { src: 'test/**/*.js' },
127-
},
128-
ng: {
129-
files: { src: files['angularSrc'].concat('!src/angular.bind.js') },
130-
},
131-
ngAnimate: {
132-
files: { src: 'src/ngAnimate/**/*.js' },
133-
},
134-
ngCookies: {
135-
files: { src: 'src/ngCookies/**/*.js' },
136-
},
137-
ngLocale: {
138-
files: { src: 'src/ngLocale/**/*.js' },
139-
},
140-
ngMessageFormat: {
141-
files: { src: 'src/ngMessageFormat/**/*.js' },
142-
},
143-
ngMessages: {
144-
files: { src: 'src/ngMessages/**/*.js' },
145-
},
146-
ngMock: {
147-
files: { src: 'src/ngMock/**/*.js' },
148-
},
149-
ngParseExt: {
150-
files: { src: 'src/ngParseExt/**/*.js' },
151-
},
152-
ngResource: {
153-
files: { src: 'src/ngResource/**/*.js' },
154-
},
155-
ngRoute: {
156-
files: { src: 'src/ngRoute/**/*.js' },
157-
},
158-
ngSanitize: {
159-
files: { src: 'src/ngSanitize/**/*.js' },
160-
},
161-
ngScenario: {
162-
files: { src: 'src/ngScenario/**/*.js' },
163-
},
164-
ngTouch: {
165-
files: { src: 'src/ngTouch/**/*.js' },
166-
},
167-
ngAria: {
168-
files: {src: 'src/ngAria/**/*.js'},
169-
}
170-
},
171-
172-
jscs: {
173-
src: [
174-
'src/**/*.js',
175-
'test/**/*.js',
176-
'!src/angular.bind.js' // we ignore this file since contains an early return statement
177-
],
178-
options: {
179-
config: '.jscsrc'
118+
eslint: {
119+
all: {
120+
src: [
121+
'*.js',
122+
'src/**/*.js',
123+
'test/**/*.js'
124+
]
180125
}
181126
},
182127

@@ -318,7 +263,7 @@ module.exports = function(grunt) {
318263

319264
compress: {
320265
build: {
321-
options: {archive: 'build/' + dist +'.zip', mode: 'zip'},
266+
options: {archive: 'build/' + dist + '.zip', mode: 'zip'},
322267
src: ['**'],
323268
cwd: 'build',
324269
expand: true,
@@ -366,7 +311,7 @@ module.exports = function(grunt) {
366311

367312

368313
//alias tasks
369-
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']);
314+
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['eslint', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']);
370315
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']);
371316
grunt.registerTask('test:jquery', 'Run the jQuery (latest) unit tests with Karma', ['tests:jquery']);
372317
grunt.registerTask('test:jquery-2.2', 'Run the jQuery 2.2 unit tests with Karma', ['tests:jquery-2.2']);
@@ -383,6 +328,6 @@ module.exports = function(grunt) {
383328
grunt.registerTask('minify', ['bower', 'clean', 'build', 'minall']);
384329
grunt.registerTask('webserver', ['connect:devserver']);
385330
grunt.registerTask('package', ['bower', 'validate-angular-files', 'clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
386-
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']);
331+
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'eslint']);
387332
grunt.registerTask('default', ['package']);
388333
};

angularFiles.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ var angularFiles = {
244244
]
245245
};
246246

247-
['2.1', '2.2'].forEach(function (jQueryVersion) {
247+
['2.1', '2.2'].forEach(function(jQueryVersion) {
248248
angularFiles['karmaJquery' + jQueryVersion] = []
249249
.concat(angularFiles.karmaJquery)
250-
.map(function (path) {
250+
.map(function(path) {
251251
if (path.startsWith('bower_components/jquery')) {
252252
return path.replace(/^bower_components\/jquery/, 'bower_components/jquery-' + jQueryVersion);
253253
}
@@ -276,7 +276,7 @@ if (exports) {
276276
Array.prototype.slice.call(arguments, 0).forEach(function(filegroup) {
277277
angularFiles[filegroup].forEach(function(file) {
278278
// replace @ref
279-
var match = file.match(/^\@(.*)/);
279+
var match = file.match(/^@(.*)/);
280280
if (match) {
281281
files = files.concat(angularFiles[match[1]]);
282282
} else {

0 commit comments

Comments
 (0)