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

Commit 6e425c4

Browse files
Splaktarjosephperrott
authored andcommitted
build: configure ESLint coverage for gulp, scripts, docs, config (#11064)
1 parent cc73422 commit 6e425c4

Some content is hidden

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

48 files changed

+551
-550
lines changed

.eslintignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ignore miscellaneous folders
2+
.github/
3+
.idea/
4+
node_modules/
5+
dist/
6+
tmp/
7+
bower-material/
8+
code.material.angularjs.org/
9+
10+
# Ignore certain project files
11+
# TODO Remove test/ at some point when the files there are fit for linting
12+
test/
13+
src/core/services/compiler/compiler.spec.js
14+
docs/config/template/*.js
15+
docs/app/js/highlight.pack.js

.eslintrc.json

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "eslint:recommended",
33
"parserOptions": {
4-
"ecmaVersion": 8
4+
"ecmaVersion": 8
55
},
66
"rules": {
77
"accessor-pairs": "error",
@@ -10,7 +10,10 @@
1010
"array-callback-return": "error",
1111
"array-element-newline": "off",
1212
"arrow-body-style": "error",
13-
"arrow-parens": "error",
13+
"arrow-parens": [
14+
"error",
15+
"as-needed"
16+
],
1417
"arrow-spacing": "error",
1518
"block-scoped-var": "off",
1619
"block-spacing": "off",
@@ -42,7 +45,7 @@
4245
"func-style": "off",
4346
"generator-star-spacing": "error",
4447
"getter-return": "error",
45-
"global-require": "error",
48+
"global-require": "off",
4649
"guard-for-in": "off",
4750
"handle-callback-err": "error",
4851
"id-blacklist": "error",
@@ -78,14 +81,17 @@
7881
"no-caller": "error",
7982
"no-catch-shadow": "error",
8083
"no-confusing-arrow": "error",
84+
"no-console": [
85+
"off"
86+
],
8187
"no-constant-condition": [
8288
"error",
8389
{
8490
"checkLoops": false
8591
}
8692
],
8793
"no-continue": "off",
88-
"no-div-regex": "error",
94+
"no-div-regex": "off",
8995
"no-duplicate-imports": "error",
9096
"no-else-return": "off",
9197
"no-empty-function": "off",
@@ -138,7 +144,7 @@
138144
"no-param-reassign": "off",
139145
"no-path-concat": "error",
140146
"no-plusplus": "off",
141-
"no-process-env": "error",
147+
"no-process-env": "off",
142148
"no-process-exit": "error",
143149
"no-proto": "error",
144150
"no-prototype-builtins": "off",
@@ -155,7 +161,7 @@
155161
"no-shadow": "off",
156162
"no-shadow-restricted-names": "error",
157163
"no-spaced-func": "off",
158-
"no-sync": "error",
164+
"no-sync": "off",
159165
"no-tabs": "off",
160166
"no-template-curly-in-string": "error",
161167
"no-ternary": "off",
@@ -240,15 +246,50 @@
240246
"no-unexpected-multiline": "off"
241247
},
242248
"env": {
243-
"browser": true
249+
"node": true
244250
},
245251
"globals": {
246-
"angular": true,
247-
"CryptoJS": true
252+
"angular": true
248253
},
249254
"overrides": [
250255
{
251-
"files": ["**/*.spec.js"],
256+
"files": [
257+
"docs/app/js/**/*",
258+
"src/**/*"
259+
],
260+
"parserOptions": {
261+
"ecmaVersion": 5
262+
},
263+
"env": {
264+
"browser": true
265+
},
266+
"rules": {
267+
"arrow-parens": "error",
268+
"global-require": "error",
269+
"no-console": [
270+
"error"
271+
],
272+
"no-process-env": "error",
273+
"no-sync": "error"
274+
},
275+
"globals": {
276+
"angular": true,
277+
"CryptoJS": true,
278+
"hljs": true
279+
}
280+
},
281+
{
282+
"files": [
283+
"scripts/**/*"
284+
],
285+
"rules": {
286+
"no-process-env": "off"
287+
}
288+
},
289+
{
290+
"files": [
291+
"**/*.spec.js"
292+
],
252293
"env": {
253294
"jasmine": true
254295
},

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ dist
66
.nvmrc
77
tmp/
88
.editorconfig
9+
bower-material/
10+
code.material.angularjs.org/

committers.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

config/build.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
var pkg = require('../package.json');
2-
var fs = require('fs');
3-
var versionFile = __dirname + '/../dist/commit';
1+
const pkg = require('../package.json');
42

53
module.exports = {
64
ngVersion: '1.5.5',

config/karma-ci.conf.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var baseKarma = require('./karma.conf.js');
1+
const baseKarma = require('./karma.conf.js');
22

33
module.exports = function(config) {
44
baseKarma(config);
55

66
// Override defaults with custom CI settings
77
config.set({
88
colors: false,
9-
singleRun:true,
9+
singleRun: true,
1010
autoWatch: false,
1111
logLevel: config.LOG_DEBUG,
1212

@@ -17,7 +17,7 @@ module.exports = function(config) {
1717

1818
client: {
1919
// Do not clear the context as this can cause reload failures with Jasmine
20-
clearContext:false
20+
clearContext: false
2121
},
2222

2323
// This is the new content for your travis-ci configuration test
@@ -30,7 +30,7 @@ module.exports = function(config) {
3030
}
3131
});
3232

33-
var browsers = process.env.TRAVIS ? ['Chrome_travis_ci'] : [];
33+
const browsers = process.env.TRAVIS ? ['Chrome_travis_ci'] : [];
3434
config.browsers = browsers.concat(config.browsers);
3535

3636
};

config/karma-docs.conf.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
const path = require('path');
2+
13
// Used for running unit tests against the docs site
24
// Unit tests can be run using gulp docs-karma
35
module.exports = function(config) {
46

5-
var UNCOMPILED_SRC = [
7+
// releaseMode is a custom configuration option.
8+
const testSrc = [
69
'docs/spec/**/*.spec.js'
710
];
8-
9-
// releaseMode is a custom configuration option.
10-
var testSrc = UNCOMPILED_SRC;
11-
var dependencies = process.env.KARMA_TEST_JQUERY ?
11+
let dependencies = process.env.KARMA_TEST_JQUERY ?
1212
['node_modules/jquery/dist/jquery.js'] : [];
1313

1414
dependencies = dependencies.concat([
@@ -26,7 +26,7 @@ module.exports = function(config) {
2626

2727
config.set({
2828

29-
basePath: __dirname + '/..',
29+
basePath: path.join(__dirname, '/..'),
3030
frameworks: ['jasmine'],
3131
files: dependencies.concat(testSrc),
3232

config/karma-sauce.conf.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var baseKarma = require('./karma.conf.js');
1+
const baseKarma = require('./karma.conf.js');
2+
const sauceBrowsers = require('./sauce-browsers.json');
23

34
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
4-
console.log('Environment variables SAUCE_USERNAME and SAUCE_ACCESS_KEY must be set to run saucelabs with Karma.');
5-
process.exit(1);
5+
throw new Error('Environment variables SAUCE_USERNAME and SAUCE_ACCESS_KEY must be set to run saucelabs with Karma.');
66
}
77

88
process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
@@ -17,7 +17,7 @@ module.exports = function(config) {
1717
// Those pre-configured browsers will always run in the CI Release Mode to confirm, that all
1818
// previous jobs have passed.
1919
browsers: ['SL_CHROME'], //, 'SL_FIREFOX', 'SL_IE11'],
20-
customLaunchers: require('./sauce-browsers.json'),
20+
customLaunchers: sauceBrowsers,
2121

2222
captureTimeout: 180 * 1000,
2323
browserDisconnectTimeout: 180 * 1000,

config/karma.conf.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
const sauceBrowsers = require('./sauce-browsers.json');
2+
const path = require('path');
13

24
module.exports = function(config) {
35

4-
var UNCOMPILED_SRC = [
6+
const UNCOMPILED_SRC = [
57

68
// To enabled use of `gulp karma-watch`,
79
// don't use the dist/angular-material.js
@@ -23,13 +25,13 @@ module.exports = function(config) {
2325
'src/**/*.spec.js'
2426
];
2527

26-
var COMPILED_SRC = [
28+
const COMPILED_SRC = [
2729
'dist/angular-material.min.css',
2830
'dist/angular-material.min.js', // Minified source
2931
'src/**/*.spec.js'
3032
];
3133

32-
var dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : [];
34+
let dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : [];
3335
dependencies = dependencies.concat([
3436
'node_modules/angular/angular.js',
3537
'node_modules/angular-animate/angular-animate.js',
@@ -42,14 +44,14 @@ module.exports = function(config) {
4244
'test/angular-material-spec.js'
4345
]);
4446

45-
var testSrc = process.env.KARMA_TEST_COMPRESSED ? COMPILED_SRC : UNCOMPILED_SRC;
47+
const testSrc = process.env.KARMA_TEST_COMPRESSED ? COMPILED_SRC : UNCOMPILED_SRC;
4648

4749
config.set({
4850

49-
basePath: __dirname + '/..',
51+
basePath: path.join(__dirname, '/..'),
5052
frameworks: ['jasmine'],
5153
files: dependencies.concat(testSrc),
52-
customLaunchers: require('./sauce-browsers.json'),
54+
customLaunchers: sauceBrowsers,
5355

5456
browserDisconnectTimeout:500,
5557

config/ngModuleData.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313
// Define patterns for AngularJS Module definitions
1414

15-
var MATERIAL_ONLY = /\.module\(['|"](material\.[a-zA-Z\-\.]*)['|"]\s*,(\s*\[([^\]]*)\])/;
16-
var ANY = /\.module\(('[^']*'|"[^"]*")\s*,(?:\s*\[([^\]]+)\])?/;
15+
const MATERIAL_ONLY = /\.module\(['|"](material\.[a-zA-Z\-.]*)['|"]\s*,(\s*\[([^\]]*)])/;
16+
const ANY = /\.module\(('[^']*'|"[^"]*")\s*,(?:\s*\[([^\]]+)])?/;
1717

1818
/**
1919
* Find module definition s that match the module definition pattern
2020
*/
2121
function buildScanner(pattern) {
2222

2323
return function findPatternIn(content) {
24-
var dependencies;
25-
var match = pattern.exec(content || '');
26-
var moduleName = match ? match[1].replace(/\'/gi,'') : null;
27-
var depsMatch = match && match[2] && match[2].trim();
24+
let dependencies;
25+
const match = pattern.exec(content || '');
26+
const moduleName = match ? match[1].replace(/'/gi,'') : null;
27+
const depsMatch = match && match[2] && match[2].trim();
2828

2929
if (depsMatch) {
3030
dependencies = depsMatch.split(/\s*,\s*/).map(function(dep) {
@@ -38,11 +38,10 @@ function buildScanner(pattern) {
3838
module : moduleName || '',
3939
dependencies : dependencies || [ ]
4040
} : null;
41-
}
41+
};
4242
}
4343

4444
module.exports = {
4545
material : buildScanner( MATERIAL_ONLY ),
4646
any : buildScanner( ANY )
4747
};
48-

0 commit comments

Comments
 (0)