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

Commit d9eb909

Browse files
graingertandrewseguin
authored andcommitted
chore(eslint): Configure ESLint Fixes #9261 (#10824)
* chore(eslint): add eslint with some small fixes * chore(eslint): fix no-useless escape * chore(eslint): fix no-extra-boolean-cast * build(ci): enable eslint on travis Fixes #9261 * configure eslint to be ES2017
1 parent f1e4fcb commit d9eb909

File tree

27 files changed

+321
-35
lines changed

27 files changed

+321
-35
lines changed

.eslintrc.json

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"parserOptions": {
4+
"ecmaVersion": 8
5+
},
6+
"rules": {
7+
"accessor-pairs": "error",
8+
"array-bracket-newline": "off",
9+
"array-bracket-spacing": "off",
10+
"array-callback-return": "error",
11+
"array-element-newline": "off",
12+
"arrow-body-style": "error",
13+
"arrow-parens": "error",
14+
"arrow-spacing": "error",
15+
"block-scoped-var": "off",
16+
"block-spacing": "off",
17+
"brace-style": "off",
18+
"callback-return": "off",
19+
"camelcase": "off",
20+
"capitalized-comments": "off",
21+
"class-methods-use-this": "error",
22+
"comma-dangle": "off",
23+
"comma-spacing": "off",
24+
"comma-style": [
25+
"error",
26+
"last"
27+
],
28+
"complexity": "off",
29+
"computed-property-spacing": "off",
30+
"consistent-return": "off",
31+
"consistent-this": "off",
32+
"curly": "off",
33+
"default-case": "off",
34+
"dot-location": "off",
35+
"dot-notation": "off",
36+
"eol-last": "off",
37+
"eqeqeq": "off",
38+
"for-direction": "error",
39+
"func-call-spacing": "off",
40+
"func-name-matching": "off",
41+
"func-names": "off",
42+
"func-style": "off",
43+
"generator-star-spacing": "error",
44+
"getter-return": "error",
45+
"global-require": "error",
46+
"guard-for-in": "off",
47+
"handle-callback-err": "error",
48+
"id-blacklist": "error",
49+
"id-length": "off",
50+
"id-match": "error",
51+
"indent": "off",
52+
"indent-legacy": "off",
53+
"init-declarations": "off",
54+
"jsx-quotes": "error",
55+
"key-spacing": "off",
56+
"keyword-spacing": "off",
57+
"line-comment-position": "off",
58+
"linebreak-style": "off",
59+
"lines-around-comment": "off",
60+
"lines-around-directive": "off",
61+
"max-depth": "error",
62+
"max-len": "off",
63+
"max-lines": "off",
64+
"max-nested-callbacks": "error",
65+
"max-params": "off",
66+
"max-statements": "off",
67+
"max-statements-per-line": "off",
68+
"multiline-ternary": "off",
69+
"new-parens": "error",
70+
"newline-after-var": "off",
71+
"newline-before-return": "off",
72+
"newline-per-chained-call": "off",
73+
"no-alert": "off",
74+
"no-array-constructor": "error",
75+
"no-await-in-loop": "error",
76+
"no-bitwise": "off",
77+
"no-buffer-constructor": "error",
78+
"no-caller": "error",
79+
"no-catch-shadow": "error",
80+
"no-confusing-arrow": "error",
81+
"no-constant-condition": [
82+
"error",
83+
{
84+
"checkLoops": false
85+
}
86+
],
87+
"no-continue": "off",
88+
"no-div-regex": "error",
89+
"no-duplicate-imports": "error",
90+
"no-else-return": "off",
91+
"no-empty-function": "off",
92+
"no-eq-null": "off",
93+
"no-eval": "error",
94+
"no-extend-native": "off",
95+
"no-extra-bind": "off",
96+
"no-extra-label": "error",
97+
"no-extra-parens": "off",
98+
"no-floating-decimal": "error",
99+
"no-implicit-coercion": [
100+
"error",
101+
{
102+
"boolean": false,
103+
"number": false,
104+
"string": false
105+
}
106+
],
107+
"no-implicit-globals": "off",
108+
"no-implied-eval": "error",
109+
"no-inline-comments": "off",
110+
"no-inner-declarations": [
111+
"error",
112+
"functions"
113+
],
114+
"no-invalid-this": "off",
115+
"no-iterator": "error",
116+
"no-label-var": "error",
117+
"no-labels": "error",
118+
"no-lone-blocks": "error",
119+
"no-lonely-if": "off",
120+
"no-loop-func": "error",
121+
"no-magic-numbers": "off",
122+
"no-mixed-operators": "off",
123+
"no-mixed-requires": "error",
124+
"no-multi-assign": "off",
125+
"no-multi-spaces": "off",
126+
"no-multi-str": "off",
127+
"no-multiple-empty-lines": "off",
128+
"no-native-reassign": "error",
129+
"no-negated-condition": "off",
130+
"no-negated-in-lhs": "error",
131+
"no-nested-ternary": "off",
132+
"no-new": "error",
133+
"no-new-func": "error",
134+
"no-new-object": "error",
135+
"no-new-require": "error",
136+
"no-new-wrappers": "error",
137+
"no-octal-escape": "error",
138+
"no-param-reassign": "off",
139+
"no-path-concat": "error",
140+
"no-plusplus": "off",
141+
"no-process-env": "error",
142+
"no-process-exit": "error",
143+
"no-proto": "error",
144+
"no-prototype-builtins": "off",
145+
"no-restricted-globals": "error",
146+
"no-restricted-imports": "error",
147+
"no-restricted-modules": "error",
148+
"no-restricted-properties": "error",
149+
"no-restricted-syntax": "error",
150+
"no-return-assign": "off",
151+
"no-return-await": "error",
152+
"no-script-url": "error",
153+
"no-self-compare": "error",
154+
"no-sequences": "off",
155+
"no-shadow": "off",
156+
"no-shadow-restricted-names": "error",
157+
"no-spaced-func": "off",
158+
"no-sync": "error",
159+
"no-tabs": "off",
160+
"no-template-curly-in-string": "error",
161+
"no-ternary": "off",
162+
"no-throw-literal": "off",
163+
"no-trailing-spaces": "off",
164+
"no-undef-init": "error",
165+
"no-undefined": "off",
166+
"no-underscore-dangle": "off",
167+
"no-unmodified-loop-condition": "error",
168+
"no-unneeded-ternary": "off",
169+
"no-unused-expressions": "off",
170+
"no-use-before-define": "off",
171+
"no-useless-call": "error",
172+
"no-useless-computed-key": "error",
173+
"no-useless-concat": "off",
174+
"no-useless-constructor": "error",
175+
"no-useless-rename": "error",
176+
"no-useless-return": "error",
177+
"no-var": "off",
178+
"no-void": "off",
179+
"no-warning-comments": "off",
180+
"no-whitespace-before-property": "error",
181+
"no-with": "error",
182+
"nonblock-statement-body-position": [
183+
"error",
184+
"any"
185+
],
186+
"object-curly-newline": "off",
187+
"object-curly-spacing": "off",
188+
"object-property-newline": "off",
189+
"object-shorthand": "off",
190+
"one-var": "off",
191+
"one-var-declaration-per-line": "off",
192+
"operator-assignment": "off",
193+
"operator-linebreak": "off",
194+
"padded-blocks": "off",
195+
"padding-line-between-statements": "error",
196+
"prefer-arrow-callback": "off",
197+
"prefer-const": "error",
198+
"prefer-destructuring": "off",
199+
"prefer-numeric-literals": "error",
200+
"prefer-promise-reject-errors": "error",
201+
"prefer-reflect": "off",
202+
"prefer-rest-params": "off",
203+
"prefer-spread": "off",
204+
"prefer-template": "off",
205+
"quote-props": "off",
206+
"quotes": "off",
207+
"radix": "off",
208+
"require-await": "error",
209+
"require-jsdoc": "off",
210+
"rest-spread-spacing": "error",
211+
"semi": "off",
212+
"semi-spacing": "off",
213+
"semi-style": "off",
214+
"sort-imports": "error",
215+
"sort-keys": "off",
216+
"sort-vars": "off",
217+
"space-before-blocks": "off",
218+
"space-before-function-paren": "off",
219+
"space-in-parens": "off",
220+
"space-infix-ops": "off",
221+
"space-unary-ops": "off",
222+
"spaced-comment": "off",
223+
"strict": "off",
224+
"switch-colon-spacing": "off",
225+
"symbol-description": "error",
226+
"template-curly-spacing": "error",
227+
"template-tag-spacing": "error",
228+
"unicode-bom": [
229+
"error",
230+
"never"
231+
],
232+
"valid-jsdoc": "off",
233+
"vars-on-top": "off",
234+
"wrap-iife": "off",
235+
"wrap-regex": "off",
236+
"yield-star-spacing": "error",
237+
"yoda": "off",
238+
"no-unused-vars": "off",
239+
"no-cond-assign": "off",
240+
"no-unexpected-multiline": "off"
241+
},
242+
"env": {
243+
"browser": true
244+
},
245+
"globals": {
246+
"angular": true,
247+
"CryptoJS": true
248+
},
249+
"overrides": [
250+
{
251+
"files": ["**/*.spec.js"],
252+
"env": {
253+
"jasmine": true
254+
},
255+
"rules": {
256+
"no-native-reassign": "off",
257+
"no-global-assign": "off"
258+
},
259+
"globals": {
260+
"module": true,
261+
"inject": true,
262+
"disableAnimations": true,
263+
"createMockStyleSheet": true,
264+
"$mdUtil": false,
265+
"$timeout": false,
266+
"$animate": false,
267+
"$material": false
268+
}
269+
}
270+
]
271+
}

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- env: "NG_VERSION=1.5"
2929
- env: "NG_VERSION=1.6"
3030
- env: "NG_VERSION=snapshot"
31+
- env: "RUN_LINT=true"
3132
- stage: Deploy
3233
script: ./scripts/travis-build-init.sh --sha=$TRAVIS_COMMIT
3334
env: "MODE=release"

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"dgeni": "^0.4.1",
3838
"dgeni-packages": "^0.13.0",
3939
"github": "^12.0.5",
40+
"eslint": "^4.3.0",
4041
"github-contributors-list": "^1.2.1",
4142
"glob": "~7.0.5",
4243
"gulp": "^3.9.1",
@@ -84,6 +85,7 @@
8485
"docs:build": "gulp docs",
8586
"docs:watch": "gulp watch site --dev",
8687
"test:fast": "gulp karma-fast",
87-
"test:full": "gulp karma"
88+
"test:full": "gulp karma",
89+
"lint": "eslint src"
8890
}
8991
}

scripts/travis-run-script.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ set -xe
66
# Ensure that scripts will run from project dir.
77
cd $(dirname $0)/..
88

9+
if [[ -n "$RUN_LINT" ]]; then
10+
npm run lint
11+
exit
12+
fi
13+
914
# When Travis CI specifies an AngularJS version, try to install those for tests.
1015
if [[ -n "$NG_VERSION" ]]; then
1116
./scripts/fetch-angular-version.sh "$NG_VERSION"

src/components/autocomplete/js/highlightController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ MdHighlightCtrl.prototype.createRegex = function(term, flags) {
109109
if (flags.indexOf('^') >= 0) startFlag = '^';
110110
if (flags.indexOf('$') >= 0) endFlag = '$';
111111

112-
return new RegExp(startFlag + regexTerm + endFlag, flags.replace(/[$\^]/g, ''));
112+
return new RegExp(startFlag + regexTerm + endFlag, flags.replace(/[$^]/g, ''));
113113
};
114114

115115
/** Sanitizes a regex by removing all common RegExp identifiers */
116116
MdHighlightCtrl.prototype.sanitizeRegex = function(term) {
117-
return term && term.toString().replace(/[\\\^\$\*\+\?\.\(\)\|\{}\[\]]/g, '\\$&');
117+
return term && term.toString().replace(/[\\^$*+?.()|{}[\]]/g, '\\$&');
118118
};

src/components/datepicker/_demoMomentJs/script.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
angular.module('datepickerMomentJs', ['ngMaterial'])
22
.config(function($mdDateLocaleProvider) {
3-
console.log(window.moment ? 'moment loaded' : 'not loaded');
43
//moment.locale('fr');
54
//$mdDateLocaleProvider.months = moment.months();
65
//$mdDateLocaleProvider.months = moment.monthsShort();

src/components/datepicker/js/calendar.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ describe('md-calendar', function() {
756756
expect(nextMonth.querySelectorAll('tr').length).toBe(1);
757757

758758
var dates = nextMonth.querySelectorAll('.md-calendar-date');
759+
var date;
759760
for (var i = 0; i < dates.length; i++) {
760761
date = dates[i];
761762
if (date.textContent) {

src/components/datepicker/js/dateLocaleProvider.js

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

209209
// Looks for three chunks of content (either numbers or text) separated
210210
// by delimiters.
211-
var re = /^(([a-zA-Z]{3,}|[0-9]{1,4})([ \.,]+|[\/\-])){2}([a-zA-Z]{3,}|[0-9]{1,4})$/;
211+
var re = /^(([a-zA-Z]{3,}|[0-9]{1,4})([ .,]+|[/-])){2}([a-zA-Z]{3,}|[0-9]{1,4})$/;
212212
return re.test(dateString);
213213
}
214214

src/components/dialog/dialog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ function MdDialogProvider($$interimElementProvider) {
813813

814814
// For navigation $destroy events, do a quick, non-animated removal,
815815
// but for normal closes (from clicks, etc) animate the removal
816-
return !!options.$destroy ? detachAndClean() : animateRemoval().then( detachAndClean );
816+
return options.$destroy ? detachAndClean() : animateRemoval().then( detachAndClean );
817817

818818
/**
819819
* For normal closes, animate the removal.
@@ -1048,7 +1048,7 @@ function MdDialogProvider($$interimElementProvider) {
10481048
*/
10491049
options.hideBackdrop = function hideBackdrop($destroy) {
10501050
if (options.backdrop) {
1051-
if ( !!$destroy ) options.backdrop.remove();
1051+
if ( $destroy ) options.backdrop.remove();
10521052
else $animate.leave(options.backdrop);
10531053
}
10541054

src/components/dialog/dialog.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ describe('$mdDialog', function() {
801801

802802
function onShowing(scope, element, options) {
803803
showing = true;
804-
container = angular.element(parent[0].querySelector('.md-dialog-container'));
804+
var container = angular.element(parent[0].querySelector('.md-dialog-container'));
805805
expect(container.length).toBe(0);
806806
}
807807

0 commit comments

Comments
 (0)