mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
add lodash3 rules
This commit is contained in:
parent
020d66126b
commit
a0f39e3435
@ -1,5 +1,5 @@
|
||||
{
|
||||
"plugins": ["react"],
|
||||
"plugins": ["react", "lodash3"],
|
||||
"rules": {
|
||||
"no-array-constructor": 2,
|
||||
"no-catch-shadow": 2,
|
||||
@ -156,7 +156,12 @@
|
||||
"react/react-in-jsx-scope": 1,
|
||||
"react/self-closing-comp": 1,
|
||||
"react/wrap-multilines": 1,
|
||||
"react/sort-comp": 1
|
||||
"react/sort-comp": 1,
|
||||
|
||||
"lodash3/prop-shorthand": 2,
|
||||
"lodash3/matches-prop-shorthand": 2,
|
||||
"lodash3/prefer-chain": 1,
|
||||
"lodash3/preferred-alias": 2
|
||||
},
|
||||
"env": {
|
||||
"browser": false,
|
||||
|
@ -15,13 +15,6 @@ module.exports = function (grunt) {
|
||||
'!playground/dist/**/*.js',
|
||||
'!playground/**/*.rt.js'
|
||||
]
|
||||
},
|
||||
teamcity: {
|
||||
options: {
|
||||
format: 'checkstyle',
|
||||
'output-file': 'target/eslint.xml'
|
||||
},
|
||||
src: ['<%= eslint.all.src %>']
|
||||
}
|
||||
},
|
||||
jasmine_node: {
|
||||
@ -116,8 +109,6 @@ module.exports = function (grunt) {
|
||||
grunt.registerTask('default', ['eslint:all']);
|
||||
grunt.registerTask('test', ['node_tap']);
|
||||
|
||||
grunt.registerTask('teamcity', ['eslint:teamcity']);
|
||||
|
||||
grunt.registerTask('rt', function () {
|
||||
var reactTemplates = require('./src/cli');
|
||||
var files = grunt.file.expand('playground/*.rt');
|
||||
|
@ -36,6 +36,7 @@
|
||||
"brace": "^0.5.1",
|
||||
"brfs": "^1.4.0",
|
||||
"coveralls": "^2.11.3",
|
||||
"eslint-plugin-lodash3": "0.0.0",
|
||||
"eslint-plugin-react": "^3.1.0",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-browserify": "^3.8.0",
|
||||
|
@ -19,7 +19,7 @@ define(['lodash', 'react', './examples.rt',
|
||||
//samples = _.map(samples, function (v, k) {
|
||||
// return {name: k, templateProps: _.template(v[0])({name: k}), templateHTML: v[1]};
|
||||
//});
|
||||
_.each(samples, function (v, k) {
|
||||
_.forEach(samples, function (v, k) {
|
||||
samples[k] = {name: k, templateProps: _.template(v[0])({name: k}), templateHTML: v[1]};
|
||||
});
|
||||
|
||||
|
@ -120,7 +120,7 @@ module.exports = function (results) {
|
||||
infos = 0,
|
||||
summaryColor = 'cyan';
|
||||
|
||||
_.each(results, function (result, k) {
|
||||
_.forEach(results, function (result, k) {
|
||||
var messages = result;
|
||||
|
||||
if (messages.length === 0) {
|
||||
|
@ -300,7 +300,7 @@ function generateProps(node, context) {
|
||||
* @return {string}
|
||||
*/
|
||||
function convertTagNameToConstructor(tagName, context) {
|
||||
var isHtmlTag = _.contains(reactDOMSupport[context.options.targetVersion], tagName);
|
||||
var isHtmlTag = _.includes(reactDOMSupport[context.options.targetVersion], tagName);
|
||||
if (shouldUseCreateElement(context)) {
|
||||
isHtmlTag = isHtmlTag || tagName.match(/^\w+(-\w+)$/);
|
||||
return isHtmlTag ? "'" + tagName + "'" : tagName;
|
||||
@ -327,7 +327,7 @@ function defaultContext(html, options) {
|
||||
* @return {boolean}
|
||||
*/
|
||||
function hasNonSimpleChildren(node) {
|
||||
return _.any(node.children, function (child) {
|
||||
return _.some(node.children, function (child) {
|
||||
return child.type === 'tag' && child.attribs[templateAttr];
|
||||
});
|
||||
}
|
||||
@ -353,13 +353,13 @@ function convertHtmlToReact(node, context) {
|
||||
|
||||
// these are variables that were already in scope, unrelated to the ones declared in rt-scope
|
||||
data.outerScopeMapping = {};
|
||||
_.each(context.boundParams, function (boundParam) {
|
||||
_.forEach(context.boundParams, function (boundParam) {
|
||||
data.outerScopeMapping[boundParam] = boundParam;
|
||||
});
|
||||
|
||||
// these are variables declared in the rt-scope attribute
|
||||
data.innerScopeMapping = {};
|
||||
_.each(node.attribs[scopeAttr].split(';'), function (scopePart) {
|
||||
_.forEach(node.attribs[scopeAttr].split(';'), function (scopePart) {
|
||||
if (scopePart.trim().length === 0) {
|
||||
return;
|
||||
}
|
||||
@ -402,7 +402,7 @@ function convertHtmlToReact(node, context) {
|
||||
data.props = propsTemplateSimple({generatedProps: data.props, rtProps: node.attribs[propsAttr]});
|
||||
} else {
|
||||
data.props = propsTemplate({generatedProps: data.props, rtProps: node.attribs[propsAttr]});
|
||||
if (!_.contains(context.injectedFunctions, propsMergeFunction)) {
|
||||
if (!_.includes(context.injectedFunctions, propsMergeFunction)) {
|
||||
context.injectedFunctions.push(propsMergeFunction);
|
||||
}
|
||||
}
|
||||
@ -466,7 +466,7 @@ function handleSelfClosingHtmlTags(nodes) {
|
||||
.map(function (node) {
|
||||
var externalNodes = [];
|
||||
node.children = handleSelfClosingHtmlTags(node.children);
|
||||
if (node.type === 'tag' && _.contains(htmlSelfClosingTags, node.name)) {
|
||||
if (node.type === 'tag' && _.includes(htmlSelfClosingTags, node.name)) {
|
||||
externalNodes = _.filter(node.children, isTag);
|
||||
_.forEach(externalNodes, function (child) {
|
||||
child.parent = node;
|
||||
|
@ -22,7 +22,7 @@ function capitalize(str) {
|
||||
* @param {*} obj
|
||||
*/
|
||||
function addIfMissing(array, obj) {
|
||||
if (!_.contains(array, obj)) {
|
||||
if (!_.includes(array, obj)) {
|
||||
array.push(obj);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user