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

build: configure ESLint coverage for gulp, scripts, docs, config #11064

Merged
merged 1 commit into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ignore miscellaneous folders
.github/
.idea/
node_modules/
dist/
tmp/
bower-material/
code.material.angularjs.org/

# Ignore certain project files
# TODO Remove test/ at some point when the files there are fit for linting
test/
src/core/services/compiler/compiler.spec.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could probably do these with the 'overrides' feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to add them to an excludedFiles array, but that didn't work. Most of them cause ESLint to actually throw a parsing error if the file is evaluated at all. Adding them to the ignore file avoided this issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/ doesn't seem to have that much wrong with it. I suspect they can be added to the overrides.2.files array.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started into cleaning those up and getting them passing, but there were a number of things that I am not comfortable changing at this time. I'd like to keep that as part of a separate PR since those files are actually used to test the library and changing them would make this PR no longer 'merge safe'.

docs/config/template/*.js
docs/app/js/highlight.pack.js
61 changes: 51 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": 8
},
"rules": {
"accessor-pairs": "error",
Expand All @@ -10,7 +10,10 @@
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": "error",
"block-scoped-var": "off",
"block-spacing": "off",
Expand Down Expand Up @@ -42,7 +45,7 @@
"func-style": "off",
"generator-star-spacing": "error",
"getter-return": "error",
"global-require": "error",
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "error",
"id-blacklist": "error",
Expand Down Expand Up @@ -78,14 +81,17 @@
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-console": [
"off"
],
"no-constant-condition": [
"error",
{
"checkLoops": false
}
],
"no-continue": "off",
"no-div-regex": "error",
"no-div-regex": "off",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "off",
Expand Down Expand Up @@ -138,7 +144,7 @@
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-env": "off",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
Expand All @@ -155,7 +161,7 @@
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "off",
"no-sync": "error",
"no-sync": "off",
"no-tabs": "off",
"no-template-curly-in-string": "error",
"no-ternary": "off",
Expand Down Expand Up @@ -240,15 +246,50 @@
"no-unexpected-multiline": "off"
},
"env": {
"browser": true
"node": true
},
"globals": {
"angular": true,
"CryptoJS": true
"angular": true
},
"overrides": [
{
"files": ["**/*.spec.js"],
"files": [
"docs/app/js/**/*",
"src/**/*"
],
"parserOptions": {
"ecmaVersion": 5
},
"env": {
"browser": true
},
"rules": {
"arrow-parens": "error",
"global-require": "error",
"no-console": [
"error"
],
"no-process-env": "error",
"no-sync": "error"
},
"globals": {
"angular": true,
"CryptoJS": true,
"hljs": true
}
},
{
"files": [
"scripts/**/*"
],
"rules": {
"no-process-env": "off"
}
},
{
"files": [
"**/*.spec.js"
],
"env": {
"jasmine": true
},
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dist
.nvmrc
tmp/
.editorconfig
bower-material/
code.material.angularjs.org/
1 change: 0 additions & 1 deletion committers.json

This file was deleted.

4 changes: 1 addition & 3 deletions config/build.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
var pkg = require('../package.json');
var fs = require('fs');
var versionFile = __dirname + '/../dist/commit';
const pkg = require('../package.json');

module.exports = {
ngVersion: '1.5.5',
Expand Down
8 changes: 4 additions & 4 deletions config/karma-ci.conf.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var baseKarma = require('./karma.conf.js');
const baseKarma = require('./karma.conf.js');

module.exports = function(config) {
baseKarma(config);

// Override defaults with custom CI settings
config.set({
colors: false,
singleRun:true,
singleRun: true,
autoWatch: false,
logLevel: config.LOG_DEBUG,

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

client: {
// Do not clear the context as this can cause reload failures with Jasmine
clearContext:false
clearContext: false
},

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

var browsers = process.env.TRAVIS ? ['Chrome_travis_ci'] : [];
const browsers = process.env.TRAVIS ? ['Chrome_travis_ci'] : [];
config.browsers = browsers.concat(config.browsers);

};
12 changes: 6 additions & 6 deletions config/karma-docs.conf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const path = require('path');

// Used for running unit tests against the docs site
// Unit tests can be run using gulp docs-karma
module.exports = function(config) {

var UNCOMPILED_SRC = [
// releaseMode is a custom configuration option.
const testSrc = [
'docs/spec/**/*.spec.js'
];

// releaseMode is a custom configuration option.
var testSrc = UNCOMPILED_SRC;
var dependencies = process.env.KARMA_TEST_JQUERY ?
let dependencies = process.env.KARMA_TEST_JQUERY ?
['node_modules/jquery/dist/jquery.js'] : [];

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

config.set({

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

Expand Down
8 changes: 4 additions & 4 deletions config/karma-sauce.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var baseKarma = require('./karma.conf.js');
const baseKarma = require('./karma.conf.js');
const sauceBrowsers = require('./sauce-browsers.json');

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

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

captureTimeout: 180 * 1000,
browserDisconnectTimeout: 180 * 1000,
Expand Down
14 changes: 8 additions & 6 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const sauceBrowsers = require('./sauce-browsers.json');
const path = require('path');

module.exports = function(config) {

var UNCOMPILED_SRC = [
const UNCOMPILED_SRC = [

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

var COMPILED_SRC = [
const COMPILED_SRC = [
'dist/angular-material.min.css',
'dist/angular-material.min.js', // Minified source
'src/**/*.spec.js'
];

var dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : [];
let dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : [];
dependencies = dependencies.concat([
'node_modules/angular/angular.js',
'node_modules/angular-animate/angular-animate.js',
Expand All @@ -42,14 +44,14 @@ module.exports = function(config) {
'test/angular-material-spec.js'
]);

var testSrc = process.env.KARMA_TEST_COMPRESSED ? COMPILED_SRC : UNCOMPILED_SRC;
const testSrc = process.env.KARMA_TEST_COMPRESSED ? COMPILED_SRC : UNCOMPILED_SRC;

config.set({

basePath: __dirname + '/..',
basePath: path.join(__dirname, '/..'),
frameworks: ['jasmine'],
files: dependencies.concat(testSrc),
customLaunchers: require('./sauce-browsers.json'),
customLaunchers: sauceBrowsers,

browserDisconnectTimeout:500,

Expand Down
15 changes: 7 additions & 8 deletions config/ngModuleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@

// Define patterns for AngularJS Module definitions

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

/**
* Find module definition s that match the module definition pattern
*/
function buildScanner(pattern) {

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

if (depsMatch) {
dependencies = depsMatch.split(/\s*,\s*/).map(function(dep) {
Expand All @@ -38,11 +38,10 @@ function buildScanner(pattern) {
module : moduleName || '',
dependencies : dependencies || [ ]
} : null;
}
};
}

module.exports = {
material : buildScanner( MATERIAL_ONLY ),
any : buildScanner( ANY )
};

2 changes: 1 addition & 1 deletion docs/app/js/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
function MdAnchorDirective($mdUtil, $compile) {

/** @const @type {RegExp} */
var unsafeCharRegex = /[&\s+$,:;=?@"#{}|^~[`%!'\].\/()*\\]/g;
var unsafeCharRegex = /[&\s+$,:;=?@"#{}|^~[`%!'\]./()*\\]/g;

return {
restrict: 'E',
Expand Down
22 changes: 11 additions & 11 deletions docs/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,28 +272,28 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, $location, $rootScope, $http, $wind
name: 'Introduction',
id: 'layoutIntro',
url: 'layout/introduction'
}
,{
},
{
name: 'Layout Containers',
id: 'layoutContainers',
url: 'layout/container'
}
,{
},
{
name: 'Layout Children',
id: 'layoutGrid',
url: 'layout/children'
}
,{
},
{
name: 'Child Alignment',
id: 'layoutAlign',
url: 'layout/alignment'
}
,{
},
{
name: 'Extra Options',
id: 'layoutOptions',
url: 'layout/options'
}
,{
},
{
name: 'Troubleshooting',
id: 'layoutTips',
url: 'layout/tips'
Expand Down Expand Up @@ -398,7 +398,7 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, $location, $rootScope, $http, $wind
function getVersionIdFromPath () {
var path = $window.location.pathname;
if (path.length < 2) path = 'HEAD';
return path.match(/[^\/]+/)[0].toLowerCase();
return path.match(/[^/]+/)[0].toLowerCase();
}
});

Expand Down
6 changes: 3 additions & 3 deletions docs/app/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

function allAngularScripts() {
return scripts.map(fullPathToScript);
};
}

function fullPathToScript(script) {
return "https://ajax.googleapis.com/ajax/libs/angularjs/" + BUILDCONFIG.ngVersion + "/" + script;
};
};
}
}
})();
Loading