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

Commit a35c7b1

Browse files
committed
chore(*): switch from JSHint/JSCS to ESLint
Thanks to @Narretz for help in fixing style violations.
1 parent 33d1087 commit a35c7b1

File tree

280 files changed

+5619
-4139
lines changed

Some content is hidden

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

280 files changed

+5619
-4139
lines changed

.eslintignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bower_components/**
2+
build/**
3+
docs/bower_components/**
4+
docs/app/assets/**
5+
docs/config/templates/**
6+
node_modules/**
7+
lib/htmlparser/**
8+
src/angular.bind.js
9+
src/ngParseExt/ucd.js
10+
i18n/closure/**
11+
tmp/**
12+
13+
# TODO start linting those files?
14+
benchmarks/**

.eslintrc-todo.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
// This config contains proposed rules that we'd like to have enabled but haven't
3+
// converted the code to adhere yet. If a decision comes to not enable one of these
4+
// rules, it should be removed from the file. Every rule that got enabled in the
5+
// end should be moved from here to a respective section in .eslintrc.json
6+
7+
"rules": {
8+
// Rules are divided into sections from http://eslint.org/docs/rules/
9+
10+
// Best practices
11+
"complexity": ["error", 10],
12+
"dot-notation": "error",
13+
"dot-location": ["error", "property"],
14+
15+
// Stylistic issues
16+
"block-spacing": ["error", "always"],
17+
"comma-spacing": "error",
18+
"id-blacklist": ["error", "event"],
19+
"indent": ["error", 2],
20+
"key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
21+
"object-curly-spacing": ["error", "never"],
22+
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
23+
"operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" }}],
24+
"quotes": ["error", "single"]
25+
}
26+
}

.eslintrc.json

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
"eqeqeq": ["error", "allow-null"],
45+
"no-alert": "error",
46+
"no-caller": "error",
47+
"no-case-declarations": "error",
48+
"no-eval": "error",
49+
"no-extend-native": "error",
50+
"no-extra-bind": "error",
51+
"no-extra-label": "error",
52+
"no-fallthrough": "error",
53+
"no-floating-decimal": "error",
54+
"no-implied-eval": "error",
55+
"no-invalid-this": "error",
56+
"no-iterator": "error",
57+
"no-multi-str": "error",
58+
"no-new-func": "error",
59+
"no-new-wrappers": "error",
60+
"no-new": "error",
61+
"no-octal-escape": "error",
62+
"no-octal": "error",
63+
"no-proto": "error",
64+
"no-redeclare": "error",
65+
"no-return-assign": "error",
66+
"no-script-url": "error",
67+
"no-self-assign": "error",
68+
"no-self-compare": "error",
69+
"no-sequences": "error",
70+
"no-throw-literal": "error",
71+
"no-unmodified-loop-condition": "error",
72+
"no-unused-expressions": "error",
73+
"no-unused-labels": "error",
74+
"no-useless-call": "error",
75+
"no-useless-concat": "error",
76+
"no-useless-escape": "error",
77+
"no-void": "error",
78+
"no-with": "error",
79+
"radix": "error",
80+
"wrap-iife": ["error", "inside"],
81+
82+
// Strict mode
83+
"strict": ["error", "global"],
84+
85+
// Variables
86+
"no-delete-var": "error",
87+
"no-label-var": "error",
88+
"no-restricted-globals": ["error", "event"],
89+
"no-shadow-restricted-names": "error",
90+
"no-undef-init": "error",
91+
"no-undef": "error",
92+
"no-unused-vars": ["error", { "vars": "local", "args": "none" }],
93+
94+
// Node.js
95+
"handle-callback-err": "error",
96+
97+
// Stylistic issues
98+
"array-bracket-spacing": ["error", "never"],
99+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
100+
"comma-style": ["error", "last"],
101+
"eol-last": "error",
102+
"keyword-spacing": "error",
103+
"linebreak-style": ["error", "unix"],
104+
"max-len": ["error", { "code": 200, "ignoreComments": true, "ignoreUrls": true }],
105+
"new-cap": "error",
106+
"new-parens": "error",
107+
"no-array-constructor": "error",
108+
"no-bitwise": "error",
109+
"no-mixed-spaces-and-tabs": "error",
110+
"no-multiple-empty-lines": ["error", { "max": 3, "maxEOF": 1 }],
111+
"no-whitespace-before-property": "error",
112+
"no-spaced-func": "error",
113+
"no-trailing-spaces": "error",
114+
"no-unneeded-ternary": "error",
115+
"semi-spacing": "error",
116+
"semi": "error",
117+
"space-before-blocks": ["error", "always"],
118+
"space-before-function-paren": ["error", "never"],
119+
"space-in-parens": ["error", "never"],
120+
"space-infix-ops": "error",
121+
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
122+
"unicode-bom": ["error", "never"]
123+
}
124+
}

.jscsrc

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

.jshintignore

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

.jshintrc

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

.jshintrc-base

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

Gruntfile.js

Lines changed: 23 additions & 68 deletions
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,23 @@ 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+
'docs/**/*.js',
123+
'lib/**/*.js',
124+
'scripts/**/*.js',
125+
'src/**/*.js',
126+
'test/**/*.js',
127+
'i18n/**/*.js',
128+
'!docs/app/assets/**',
129+
'!docs/bower_components/**',
130+
'!docs/config/templates/**',
131+
'!src/angular.bind.js',
132+
'!i18n/closure/**',
133+
'!src/ngParseExt/ucd.js'
134+
]
180135
}
181136
},
182137

@@ -318,7 +273,7 @@ module.exports = function(grunt) {
318273

319274
compress: {
320275
build: {
321-
options: {archive: 'build/' + dist +'.zip', mode: 'zip'},
276+
options: {archive: 'build/' + dist + '.zip', mode: 'zip'},
322277
src: ['**'],
323278
cwd: 'build',
324279
expand: true,
@@ -366,7 +321,7 @@ module.exports = function(grunt) {
366321

367322

368323
//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']);
324+
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['eslint', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']);
370325
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']);
371326
grunt.registerTask('test:jquery', 'Run the jQuery (latest) unit tests with Karma', ['tests:jquery']);
372327
grunt.registerTask('test:jquery-2.2', 'Run the jQuery 2.2 unit tests with Karma', ['tests:jquery-2.2']);
@@ -383,6 +338,6 @@ module.exports = function(grunt) {
383338
grunt.registerTask('minify', ['bower', 'clean', 'build', 'minall']);
384339
grunt.registerTask('webserver', ['connect:devserver']);
385340
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']);
341+
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'eslint']);
387342
grunt.registerTask('default', ['package']);
388343
};

0 commit comments

Comments
 (0)