Skip to content

Commit

Permalink
change eslint config to extend wix-editor and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ganimomer committed Nov 10, 2015
1 parent 4c6d524 commit 3cb2997
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 156 deletions.
142 changes: 2 additions & 140 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,147 +2,9 @@
"env": {
"node": true
},
"globals": {
},
"plugins": [
],
"extends": "wix-editor",
"rules": {
// Possible Errors
"comma-dangle": [2, "never"],
"no-cond-assign": 2,
"no-console": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-dupe-keys": 2,
"no-empty": 2,
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-regex-spaces": 2,
"no-reserved-keys": 0,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-jsdoc": 0,
"valid-typeof": 2,
// Best Practices
"block-scoped-var": 2,
"complexity": 0,
"consistent-return": 2,
"curly": 2,
"default-case": 2,
"dot-notation": 2,
"eqeqeq": 2,
"guard-for-in": 2,
"no-alert": 2,
"no-caller": 2,
"no-div-regex": 2,
"no-else-return": 2,
"no-empty-label": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 0,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-process-env": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-unused-expressions": 2,
"no-void": 0,
"no-warning-comments": 0,
"no-with": 2,
"radix": 2,
"vars-on-top": 0,
"wrap-iife": 2,
"yoda": 2,
// Strict Mode
"strict": [2, "global"],
// Variables
"no-catch-shadow": 2,
"no-delete-var": 2,
"no-label-var": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-unused-vars": 2,
"no-use-before-define": [2, "nofunc"],
// Stylistic Issues
"indent": [2, 4, {"SwitchCase": 1}],
"brace-style": 2,
"camelcase": 0,
"comma-spacing": 2,
"comma-style": 2,
"consistent-this": 0,
"eol-last": 2,
"func-names": 0,
"func-style": 0,
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"max-nested-callbacks": 0,
"new-cap": 2,
"new-parens": 2,
"no-array-constructor": 2,
"no-inline-comments": 0,
"no-lonely-if": 2,
"no-mixed-spaces-and-tabs": 2,
"no-nested-ternary": 2,
"no-new-object": 2,
"semi-spacing": [2, {"before": false, "after": true}],
"no-spaced-func": 2,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-multiple-empty-lines": 2,
"no-underscore-dangle": 0,
"one-var": 0,
"operator-assignment": [2, "always"],
"padded-blocks": 0,
"quotes": [2, "single", "avoid-escape"],
"quote-props": [2, "as-needed"],
"semi": [2, "always"],
"sort-vars": [2, {"ignoreCase": true}],
"space-after-keywords": 2,
"space-before-blocks": 2,
"object-curly-spacing": [2, "never"],
"array-bracket-spacing": [2, "never"],
"space-in-parens": 2,
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": 2,
"spaced-comment": 0,
"wrap-regex": 0,
// Legacy
"max-depth": 0,
"max-len": [2, 200],
"max-params": 0,
"max-statements": 0,
"no-plusplus": 0
"no-extra-parens": 0
}
}
4 changes: 2 additions & 2 deletions lib/rules/no-double-unwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = function (context) {
return {
CallExpression: function (node) {
var caller = astUtil.getCaller(node);
if (lodashUtil.isChainBreaker(node) && !lodashUtil.isChainable(caller) && !lodashUtil.isExplicitMethodChaining(caller)
&& lodashUtil.isLodashWrapper(astUtil.getCaller(caller))) {
if (lodashUtil.isChainBreaker(node) && !lodashUtil.isChainable(caller) && !lodashUtil.isExplicitMethodChaining(caller) &&
lodashUtil.isLodashWrapper(astUtil.getCaller(caller))) {
context.report(node, 'Do not use .value() after chain-ending method {{method}}', {method: astUtil.getMethodName(caller)});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function (context) {
function isBooleanCastingFunction(func) {
var returnValue = astUtil.getValueReturnedInFirstLine(func);
var paramName = astUtil.getFirstParamName(func);
return (func && func.type === 'Identifier' && func.name === 'Boolean') ||
return func && func.type === 'Identifier' && func.name === 'Boolean' ||
(astUtil.isIdentifierOfParam(returnValue, paramName) ||
isDoubleNegationOfParam(returnValue, paramName) || isCallToBooleanCastOfParam(returnValue, paramName));
}
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/prefer-lodash-typecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ module.exports = function (context) {
}

function isStrictComparison(node) {
return (node.operator === '===' || node.operator === '!==');
return node.operator === '===' || node.operator === '!==';
}

function isCompareTypeOfToLiteral(node) {
return isStrictComparison(node) &&
((isTypeOf(node.left) && isLiteralThatIsNotUndefined(node.right)) || (isTypeOf(node.right) && isLiteralThatIsNotUndefined(node.left)));
(isTypeOf(node.left) && isLiteralThatIsNotUndefined(node.right)) ||
isTypeOf(node.right) && isLiteralThatIsNotUndefined(node.left);
}

var REPORT_MESSAGE = 'Prefer \'_.{{method}}\' over {{actual}}.';
Expand Down
10 changes: 7 additions & 3 deletions lib/rules/unwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@

module.exports = function (context) {
var lodashUtil = require('../util/lodashUtil');

function isExplicitChainWithoutBreaker(node) {
return lodashUtil.isExplicitMethodChaining(node) && !lodashUtil.isChainBreaker(node);
}
function isEvaluatedWhenLazy(node) {
return lodashUtil.isCallToMethod(node, 'commit') || !lodashUtil.isChainable(node);
}
return {
CallExpression: function (node) {
if (lodashUtil.isEndOfChain(node) &&
((lodashUtil.isChainable(node) && !lodashUtil.isCallToMethod(node, 'commit')) || (lodashUtil.isExplicitMethodChaining(node) && !lodashUtil.isChainBreaker(node)))) {
if (lodashUtil.isEndOfChain(node) && (!isEvaluatedWhenLazy(node) || isExplicitChainWithoutBreaker(node))) {
context.report(node, 'Missing unwrapping at end of chain');
}
}
Expand Down
7 changes: 3 additions & 4 deletions lib/util/astUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function getFirstFunctionLine(node) {

function isPropAccess(node) {
return node &&
(node.computed === false) ||
node.computed === false ||
(node.computed === true && node.property.type === 'Literal' && _.isString(node.property.value));
}

Expand All @@ -56,8 +56,7 @@ function isObjectOfMethodCall(node) {
}

function isAnySideArgMemberExp(exp, paramName) {
return (isMemberExpOfArg(exp.left, paramName) ||
isMemberExpOfArg(exp.right, paramName));
return isMemberExpOfArg(exp.left, paramName) || isMemberExpOfArg(exp.right, paramName);
}

function isBinaryExpWithParamMember(operator, exp, paramName) {
Expand Down Expand Up @@ -99,7 +98,7 @@ function isComputed(node) {

function isEquivalentExp(a, b) {

return _.isEqual(a, b, function(left, right, key) {
return _.isEqual(a, b, function (left, right, key) {
if (_.includes(['loc', 'range', 'computed'], key)) {
return true;
}
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
"lodash": "^3.10.1"
},
"devDependencies": {
"coveralls": "2.11.3",
"eslint": "1.0.0",
"istanbul": "0.3.17",
"mocha": "2.2.5"
"coveralls": "2.11.4",
"eslint": "1.9.0",
"eslint-config-wix-editor": "0.0.1",
"istanbul": "0.4.0",
"mocha": "2.3.3"
},
"keywords": [
"eslint",
Expand Down

0 comments on commit 3cb2997

Please sign in to comment.