Skip to content

Commit

Permalink
Change from JSHint to ESLint. Refs #520.
Browse files Browse the repository at this point in the history
  • Loading branch information
wkeese committed Mar 19, 2020
1 parent 72a6cf0 commit 0ac5366
Show file tree
Hide file tree
Showing 63 changed files with 1,698 additions and 747 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/**/*.js
Gruntfile.js
145 changes: 145 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"env": {
"browser": true,
"amd": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 7
},
"globals": {
"intern": "readonly",
"module": "readonly",
"Promise": "readonly",
"requirejs": "readonly"
},
"rules": {
"semi": [
"error",
"always"
],
"no-bitwise": 0,
"no-cond-assign": 0,
"camelcase": 2,
"curly": 2,
"no-debugger": 2,
"eqeqeq": 2,
"no-eq-null": 2,
"no-eval": 0,
"no-unused-expressions": 2,
"guard-for-in": 0,
"block-scoped-var": 2,
"strict": 0,
"comma-dangle": [
"error",
"never"
],
"lines-around-directive": [
"error",
{
"before": "never",
"after": "always"
}
],
"object-curly-newline": [
"error",
{
"consistent": true
}
],
"object-property-newline": [
"error",
{
"allowAllPropertiesOnSameLine": true
}
],
"wrap-iife": [
2,
"any"
],
"keyword-spacing": [
"error",
{
"before": true
}
],
"key-spacing": [
"error",
{
"beforeColon": false
}
],
"no-iterator": 0,
"no-use-before-define": 0,
"comma-style": [
2,
"last"
],
"space-before-blocks": [
2,
"always"
],
"space-before-function-paren": [
2,
"always"
],
"no-trailing-spaces": [
2,
{
"skipBlankLines": true
}
],
"space-infix-ops": [
2,
{
"int32Hint": false
}
],
"no-mixed-spaces-and-tabs": 2,
"no-loop-func": 2,
"no-multi-str": 0,
"new-cap": 2,
"no-caller": 2,
"no-empty": 0,
"no-new": 2,
"no-plusplus": 0,
"no-proto": 0,
"no-script-url": 2,
"no-shadow": 2,
"dot-notation": 2,
"no-new-func": 0,
"no-new-wrappers": 0,
"no-undef": 2,
"no-unused-vars": 2,
"no-with": 0,
"max-len": [
2,
{
"code": 120,
"ignoreComments": true
}
],
"indent": [
"error",
"tab"
],
"quotes": [
"error",
"double",
{
"avoidEscape": true
}
],
"quote-props": [
"error",
"consistent-as-needed",
{
"keywords": true
}
],
"complexity": [
2,
20
]
}
}
72 changes: 0 additions & 72 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ install:
- npm install

script:
- grunt jshint
- grunt eslint
- npx intern config=@sauce

17 changes: 10 additions & 7 deletions ArrayQueryAdapter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** @module delite/ArrayQueryAdapter */
define([
"dcl/dcl",
"ibm-decor/Evented",
"ibm-decor/Evented"
], function (dcl, Evented) {

/**
* Returns a thenable on some static data, but unlike Promise, it executes synchronously.
*/
function syncThenable(data) {
function syncThenable (data) {
return {
then: function (resolve) {
var res = resolve(data);
Expand Down Expand Up @@ -69,7 +69,6 @@ define([
* @returns {Function}
* @private
*/
/* jshint maxcomplexity: 12 */
_compileFilterQuery: function (query) {
var prop = query.args[0];
var value = query.args[1];
Expand Down Expand Up @@ -108,7 +107,6 @@ define([
throw new Error("Unknown filter operation '" + query.type + "'");
}
},
/* jshint maxcomplexity: 10*/

/**
* Test if an array contains all the values in parameter values.
Expand Down Expand Up @@ -145,9 +143,14 @@ define([
var res = this.data.slice(args.start, args.end);
if (res.length < (args.end - args.start)) {
var promise;
var evt = {start: args.start, end: args.end, resLength: res.length, setPromise: function (pro) {
promise = pro;
}};
var evt = {
start: args.start,
end: args.end,
resLength: res.length,
setPromise: function (pro) {
promise = pro;
}
};
this.emit("_new-query-asked", evt);
return promise || syncThenable(res);
} else {
Expand Down
1 change: 1 addition & 0 deletions BackgroundIframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
iframe.style.display = "";
} else {
iframe = document.createElement("iframe");
// eslint-disable-next-line no-script-url
iframe.src = "javascript:''";
iframe.className = "d-background-iframe";
iframe.setAttribute("role", "presentation");
Expand Down
26 changes: 12 additions & 14 deletions CustomElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ define([
* Returns undefined to indicate the object doesn't exist (although that
* could also mean that the object does exist, but its value is "undefined".
*/
function getObject(name) {
function getObject (name) {
if (!name) {
return;
}
Expand Down Expand Up @@ -96,8 +96,8 @@ define([
if (!this.constructor._propCaseMap) {
var pcm = this.constructor._propCaseMap = {};
for (var proto = Object.getPrototypeOf(this);
proto && proto !== this._BaseHTMLElement.prototype;
proto = Object.getPrototypeOf(proto)
proto && proto !== this._BaseHTMLElement.prototype;
proto = Object.getPrototypeOf(proto)
) {
Object.keys(proto).forEach(function (prop) {
pcm[prop.toLowerCase()] = prop;
Expand Down Expand Up @@ -178,24 +178,23 @@ define([
* @private
*/
_parsePrototypeAttr: function (name, value) {
// inner function useful to reduce cyclomatic complexity when using jshint
function stringToObject(value) {
// inner function useful to reduce cyclomatic complexity
function stringToObject (str) {
var obj;

try {
// TODO: remove this code if it isn't being used, so we don't scare people that are afraid of eval.
/* jshint evil:true */
// This will only be executed when complex parameters are used in markup
// <my-tag constraints="max: 3, min: 2"></my-tag>
// This can be avoided by using such complex parameters only programmatically or by not using
// them at all.
// This is harmless if you make sure the JavaScript code that is passed to the attribute
// is harmless.
obj = eval("(" + (value[0] === "{" ? "" : "{") + value + (value[0] === "{" ? "" : "}") + ")");
obj = eval("(" + (str[0] === "{" ? "" : "{") + str + (str[0] === "{" ? "" : "}") + ")");
}
catch (e) {
throw new SyntaxError("Error in attribute conversion to object: " + e.message +
"\nAttribute Value: '" + value + "'");
"\nAttribute Value: '" + str + "'");
}
return obj;
}
Expand Down Expand Up @@ -230,7 +229,6 @@ define([
* @protected
*/
parseFunctionAttribute: function (value, params) {
/* jshint evil:true */
// new Function() will only be executed if you have properties that are of function type in your widget
// and that you use them in your tag attributes as follows:
// <my-tag whatever="console.log(param)"></my-tag>
Expand Down Expand Up @@ -356,12 +354,12 @@ define([
findCustomElements: function (root) {
var outAry = [];

function getChildrenHelper(root) {
for (var node = root.firstChild; node; node = node.nextSibling) {
if (node.nodeType === 1 && /-/.test(node.tagName)) {
outAry.push(node);
function getChildrenHelper (node) {
for (var child = node.firstChild; child; child = child.nextSibling) {
if (child.nodeType === 1 && /-/.test(child.tagName)) {
outAry.push(child);
} else {
getChildrenHelper(node);
getChildrenHelper(child);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions DialogUnderlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ define([
*
* @class module:delite/DialogUnderlay
*/
var DialogUnderlay = register("d-dialog-underlay", [HTMLElement, Widget],
/** @lends module:delite/DialogUnderlay# */ {
// eslint-disable-next-line max-len
var DialogUnderlay = register("d-dialog-underlay", [HTMLElement, Widget], /** @lends module:delite/DialogUnderlay# */ {

baseClass: "d-dialog-underlay",

constructor: dcl.after(function () {
// Automatically append the underlay to <body> on creation.
// Automatically append the underlay to <body> on creation.
this.ownerDocument.body.appendChild(this);

// Prevent scrolling content behind the dialog.
Expand Down
4 changes: 2 additions & 2 deletions DisplayContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ define(["dcl/dcl", "./Container"], function (dcl, Container) {
* @property {Element} child - reference to child element
*/

function mix(a, b) {
function mix (a, b) {
for (var n in b) {
a[n] = b[n];
}
Expand Down Expand Up @@ -165,7 +165,7 @@ define(["dcl/dcl", "./Container"], function (dcl, Container) {
* @returns {Promise} Optionally a promise that will be resolved when the display & transition effect will have
* been performed.
*/
changeDisplay: function (widget, /*jshint unused: vars*/params) {
changeDisplay: function (widget, params) {
if (params.hide === true) {
widget.style.visibility = "hidden";
widget.style.display = "none";
Expand Down
Loading

0 comments on commit 0ac5366

Please sign in to comment.