eslint 14 and fixes

This commit is contained in:
ido 2015-02-12 10:04:36 +02:00
parent 4d52b03be1
commit 7ae3e11262
7 changed files with 108 additions and 99 deletions

View File

@ -128,7 +128,8 @@
"no-multi-spaces": 1,
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
"comma-spacing": 1,
"space-unary-ops": [1, { "words": true, "nonwords": false }]
"space-unary-ops": [1, { "words": true, "nonwords": false }],
"indent": [2, 4]
},
"env": {
"browser": false,

View File

@ -67,6 +67,15 @@ module.exports = function (grunt) {
options: {
spawn: false
}
},
test: {
files: [
'src/**/*.*', 'test/**/*.*'
],
tasks: ['test'],
options: {
spawn: false
}
}
},
uglify: {

View File

@ -23,26 +23,26 @@
"dependencies": {
"chalk": "^0.5.1",
"cheerio": "^0.18.0",
"escodegen": "^1.6.0",
"esprima": "^1.2.3",
"lodash": "^2.4.1",
"escodegen": "^1.6.1",
"esprima": "^2.0.0",
"lodash": "^3.1.0",
"optionator": "^0.5.0",
"text-table": "^0.2.0"
},
"devDependencies": {
"brace": "^0.4.0",
"brfs": "^1.2.0",
"brfs": "^1.3.0",
"coveralls": "^2.11.2",
"grunt": "^0.4.5",
"grunt-browserify": "^3.3.0",
"grunt-contrib-requirejs": "^0.4.4",
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^5.1.0",
"grunt-eslint": "^6.0.0",
"grunt-node-tap": "^0.1.61",
"istanbul": "^0.3.5",
"react": "^0.12.2",
"tape": "^3.4.0"
"tape": "^3.5.0"
},
"keywords": [
"templates",

View File

@ -5,58 +5,57 @@
/*global ace:true*/
define(['react', 'lodash'/*, 'ace'*/], function (React, _/*, ace*/) {
var editor = React.createClass({
displayName: 'BraceEditor',
getInitialState: function () {
return {
editorId: _.uniqueId()
};
},
componentWillMount: function () {
},
render: function () {
var props = _.omit(this.props, ['ref', 'key', 'value', 'valueLink', 'onChange']);
props.id = this.props.id || this.state.editorId;
return React.DOM.div(props);
},
componentWillUpdate: function (nextProps/*, nextState*/) {
var value = nextProps.valueLink ? nextProps.valueLink() : nextProps.value;
if (this.editor && this.editor.getValue() !== value) {
this.editor.setValue(value, 0);
}
},
componentDidMount: function () {
this.editor = ace.edit(this.props.id || this.state.editorId);
var editor = React.createClass({
displayName: 'BraceEditor',
getInitialState: function () {
return {
editorId: _.uniqueId()
};
},
componentWillMount: function () {
},
render: function () {
var props = _.omit(this.props, ['ref', 'key', 'value', 'valueLink', 'onChange']);
props.id = this.props.id || this.state.editorId;
return React.DOM.div(props);
},
componentWillUpdate: function (nextProps/*, nextState*/) {
var value = nextProps.valueLink ? nextProps.valueLink() : nextProps.value;
if (this.editor && this.editor.getValue() !== value) {
this.editor.setValue(value, 0);
}
},
componentDidMount: function () {
this.editor = ace.edit(this.props.id || this.state.editorId);
// this.editor.setTheme('ace/theme/monokai');
this.editor.setTheme('ace/theme/solarized_light');
if (this.props.mode !== 'html') {
this.editor.getSession().setMode('ace/mode/javascript');
} else {
this.editor.getSession().setMode('ace/mode/html');
}
this.editor.getSession().setUseWorker(false);
this.editor.setTheme('ace/theme/solarized_light');
if (this.props.mode !== 'html') {
this.editor.getSession().setMode('ace/mode/javascript');
} else {
this.editor.getSession().setMode('ace/mode/html');
}
this.editor.getSession().setUseWorker(false);
var value = this.props.valueLink ? this.props.valueLink() : this.props.value;
this.editor.setValue(value, 0);
if (this.props.readOnly) {
this.editor.setReadOnly(true);
} else {
this.editor.setReadOnly(false);
this.editor.on('change', function (/*e*/) {
if (this.props.valueLink) {
this.props.valueLink(this.editor.getValue());
} else if (this.props.onChange) {
this.props.onChange({target: {value: this.editor.getValue()}});
}
}.bind(this));
var value = this.props.valueLink ? this.props.valueLink() : this.props.value;
this.editor.setValue(value, 0);
if (this.props.readOnly) {
this.editor.setReadOnly(true);
} else {
this.editor.setReadOnly(false);
this.editor.on('change', function (/*e*/) {
if (this.props.valueLink) {
this.props.valueLink(this.editor.getValue());
} else if (this.props.onChange) {
this.props.onChange({target: {value: this.editor.getValue()}});
}
}.bind(this));
}
this.editor.clearSelection();
},
componentWillUnmount: function () {
this.editor.destroy();
}
this.editor.clearSelection();
},
componentWillUnmount: function () {
this.editor.destroy();
}
});
});
return editor;
return editor;
});

View File

@ -1,34 +1,34 @@
requirejs.config({
// baseUrl: '/',
paths: {
lodash: '//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min',
jquery: '//code.jquery.com/jquery-1.11.0.min',
firebase: 'https://cdn.firebase.com/js/client/2.0.5/firebase',
react: '//fb.me/react-with-addons-0.12.2',
text: 'libs/requirejs-plugins/text',
json: 'libs/requirejs-plugins/json'
//ace: '../ace-builds-1.1.8/src-min/ace',
//'react/addons': '//fb.me/react-with-addons-0.12.1'
},
shim: {
lodash: { exports: '_' },
firebase: { exports: 'Firebase' },
//ace: { exports: 'ace' },
jquery: { exports: '$' },
react: { exports: 'React' }
},
map: {
'*': {
'react/addons': 'react'
paths: {
lodash: '//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min',
jquery: '//code.jquery.com/jquery-1.11.0.min',
firebase: 'https://cdn.firebase.com/js/client/2.0.5/firebase',
react: '//fb.me/react-with-addons-0.12.2',
text: 'libs/requirejs-plugins/text',
json: 'libs/requirejs-plugins/json'
//ace: '../ace-builds-1.1.8/src-min/ace',
//'react/addons': '//fb.me/react-with-addons-0.12.1'
},
shim: {
lodash: {exports: '_'},
firebase: {exports: 'Firebase'},
//ace: { exports: 'ace' },
jquery: {exports: '$'},
react: {exports: 'React'}
},
map: {
'*': {
'react/addons': 'react'
}
}
}
});
requirejs(['jquery', 'react', './examples'], function ($, React, Examples) {
'use strict';
/*eslint new-cap:0*/
var elem = React.createElement(Examples);
React.render(elem, document.getElementById('home-section'));
//window.fiddle = React.render(fiddle(), document.getElementById('container'));
'use strict';
/*eslint new-cap:0*/
var elem = React.createElement(Examples);
React.render(elem, document.getElementById('home-section'));
//window.fiddle = React.render(fiddle(), document.getElementById('container'));
});

View File

@ -23,7 +23,7 @@ function executeOptions(currentOptions) {
if (currentOptions.version) {
console.log('v' + pkg.version);
} else if (currentOptions.help) {
if (files.length) {
if (files.length) {
console.log(options.generateHelpForOption(files[0]));
} else {
console.log(options.generateHelp());

View File

@ -312,21 +312,21 @@ function isTag(node) {
}
function handleSelfClosingHtmlTags(nodes) {
return _(nodes)
.map(function (node) {
var externalNodes = [];
node.children = handleSelfClosingHtmlTags(node.children);
if (node.type === 'tag' && _.contains(htmlSelfClosingTags, node.name)) {
externalNodes = _.filter(node.children, isTag);
_.forEach(externalNodes, function (child) {
child.parent = node;
});
node.children = _.reject(node.children, isTag);
}
return [node].concat(externalNodes);
})
.flatten()
.value();
return _(nodes)
.map(function (node) {
var externalNodes = [];
node.children = handleSelfClosingHtmlTags(node.children);
if (node.type === 'tag' && _.contains(htmlSelfClosingTags, node.name)) {
externalNodes = _.filter(node.children, isTag);
_.forEach(externalNodes, function (child) {
child.parent = node;
});
node.children = _.reject(node.children, isTag);
}
return [node].concat(externalNodes);
})
.flatten()
.value();
}
/**