mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
update eslint-plugin-lodash to use the plugin recommended settings and fix errors
This commit is contained in:
parent
6a11cb7f69
commit
4f67fee3b5
24
.eslintrc
24
.eslintrc
@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "wix-editor/node",
|
||||
"extends": ["wix-editor/node", "plugin:lodash/recommended"],
|
||||
"plugins": ["lodash", "wix-editor"],
|
||||
"rules": {
|
||||
"semi": [2, "always"],
|
||||
@ -13,29 +13,13 @@
|
||||
"no-restricted-syntax": [2, "WithStatement", "ContinueStatement", "ForStatement"],
|
||||
"no-negated-condition": 1,
|
||||
|
||||
"lodash/prop-shorthand": 2,
|
||||
"lodash/matches-shorthand": [2, "always"],
|
||||
"lodash/matches-prop-shorthand": [2, "always"],
|
||||
"lodash/prefer-chain": 2,
|
||||
"lodash/preferred-alias": 2,
|
||||
"lodash/no-single-chain": 2,
|
||||
"lodash/prefer-reject": [2, 3],
|
||||
|
||||
"lodash/prefer-filter": 0,
|
||||
"lodash/callback-binding": 2,
|
||||
"lodash/unwrap": 2,
|
||||
"lodash/prefer-lodash-chain": 2,
|
||||
"lodash/prefer-compact": 2,
|
||||
"lodash/no-double-unwrap": 2,
|
||||
|
||||
"lodash/prefer-map": 0,
|
||||
"lodash/prefer-wrapper-method": 2,
|
||||
"lodash/prefer-thru": 2,
|
||||
"lodash/prefer-get": [2, 3],
|
||||
"lodash/collection-return": 2,
|
||||
"lodash/prefer-times": 2,
|
||||
"lodash/chain-style": [2, "as-needed"],
|
||||
"lodash/path-style": 0,
|
||||
"lodash/no-extra-args": 2,
|
||||
"lodash/identity-shorthand": [2, "always"],
|
||||
"lodash/prefer-lodash-method": 0,
|
||||
|
||||
"wix-editor/augmented-assignment": 1,
|
||||
"wix-editor/no-not-not": 1,
|
||||
|
@ -19,8 +19,7 @@ define(['react', 'lodash']/*, 'ace'*/, function (React, _/*, ace*/) {
|
||||
editorId: _.uniqueId()
|
||||
};
|
||||
},
|
||||
componentWillMount: function () {
|
||||
},
|
||||
componentWillMount: _.noop,
|
||||
render: function () {
|
||||
var props = _.omit(this.props, ['ref', 'key', 'value', 'valueLink', 'onChange']);
|
||||
props.id = this.props.id || this.state.editorId;
|
||||
@ -63,4 +62,4 @@ define(['react', 'lodash']/*, 'ace'*/, function (React, _/*, ace*/) {
|
||||
this.editor.destroy();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ define([
|
||||
},
|
||||
|
||||
loadMore: function (done) {
|
||||
done = done || function () {};
|
||||
done = done || _.noop;
|
||||
if (!this.hasMore) {
|
||||
done();
|
||||
return;
|
||||
|
@ -119,7 +119,7 @@ function convertText(node, context, txt) {
|
||||
var res = '';
|
||||
var first = true;
|
||||
var concatChar = node.type === 'text' ? ',' : '+';
|
||||
while (txt.indexOf('{') !== -1) {
|
||||
while (_.includes(txt, '{')) {
|
||||
var start = txt.indexOf('{');
|
||||
var pre = txt.substr(0, start);
|
||||
if (pre) {
|
||||
@ -227,7 +227,7 @@ function generateProps(node, context) {
|
||||
if (props.hasOwnProperty(propKey) && propKey !== reactSupport.classNameProp) {
|
||||
throw RTCodeError.build(context, node, `duplicate definition of ${propKey} ${JSON.stringify(node.attribs)}`);
|
||||
}
|
||||
if (key.indexOf('on') === 0 && !utils.isStringOnlyCode(val)) {
|
||||
if (_.startsWith(key, 'on') && !utils.isStringOnlyCode(val)) {
|
||||
props[propKey] = handleEventHandler(val, context, node, key);
|
||||
} else if (key === 'style' && !utils.isStringOnlyCode(val)) {
|
||||
props[propKey] = handleStyleProp(val, node, context);
|
||||
@ -241,7 +241,7 @@ function generateProps(node, context) {
|
||||
} else if (key === classAttr || key === reactSupport.classNameProp) {
|
||||
props[propKey] = existing + convertText(node, context, val.trim());
|
||||
}
|
||||
} else if (key.indexOf('rt-') !== 0) {
|
||||
} else if (!_.startsWith(key, 'rt-')) {
|
||||
props[propKey] = convertText(node, context, val.trim());
|
||||
}
|
||||
});
|
||||
@ -496,8 +496,7 @@ function isTag(node) {
|
||||
}
|
||||
|
||||
function handleSelfClosingHtmlTags(nodes) {
|
||||
return _(nodes)
|
||||
.map(function (node) {
|
||||
return _.flatMap(nodes, function (node) {
|
||||
var externalNodes = [];
|
||||
node.children = handleSelfClosingHtmlTags(node.children);
|
||||
if (node.type === 'tag' && (_.includes(reactSupport.htmlSelfClosingTags, node.name) ||
|
||||
@ -507,9 +506,7 @@ function handleSelfClosingHtmlTags(nodes) {
|
||||
node.children = _.reject(node.children, isTag);
|
||||
}
|
||||
return [node].concat(externalNodes);
|
||||
})
|
||||
.flatten()
|
||||
.value();
|
||||
});
|
||||
}
|
||||
|
||||
function convertTemplateToReact(html, options) {
|
||||
|
@ -52,7 +52,7 @@ function addIfMissing(array, obj) {
|
||||
function concatChildren(children) {
|
||||
var res = '';
|
||||
_.forEach(children, function (child) {
|
||||
if (child && child.indexOf(' /*') !== 0) {
|
||||
if (child && !_.startsWith(child, ' /*')) {
|
||||
res += ',';
|
||||
}
|
||||
res += child;
|
||||
|
Loading…
x
Reference in New Issue
Block a user