eslint 14 and fixes
This commit is contained in:
parent
4d52b03be1
commit
7ae3e11262
|
@ -128,7 +128,8 @@
|
||||||
"no-multi-spaces": 1,
|
"no-multi-spaces": 1,
|
||||||
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
|
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
|
||||||
"comma-spacing": 1,
|
"comma-spacing": 1,
|
||||||
"space-unary-ops": [1, { "words": true, "nonwords": false }]
|
"space-unary-ops": [1, { "words": true, "nonwords": false }],
|
||||||
|
"indent": [2, 4]
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": false,
|
"browser": false,
|
||||||
|
|
|
@ -67,6 +67,15 @@ module.exports = function (grunt) {
|
||||||
options: {
|
options: {
|
||||||
spawn: false
|
spawn: false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
files: [
|
||||||
|
'src/**/*.*', 'test/**/*.*'
|
||||||
|
],
|
||||||
|
tasks: ['test'],
|
||||||
|
options: {
|
||||||
|
spawn: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
uglify: {
|
uglify: {
|
||||||
|
|
12
package.json
12
package.json
|
@ -23,26 +23,26 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^0.5.1",
|
"chalk": "^0.5.1",
|
||||||
"cheerio": "^0.18.0",
|
"cheerio": "^0.18.0",
|
||||||
"escodegen": "^1.6.0",
|
"escodegen": "^1.6.1",
|
||||||
"esprima": "^1.2.3",
|
"esprima": "^2.0.0",
|
||||||
"lodash": "^2.4.1",
|
"lodash": "^3.1.0",
|
||||||
"optionator": "^0.5.0",
|
"optionator": "^0.5.0",
|
||||||
"text-table": "^0.2.0"
|
"text-table": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"brace": "^0.4.0",
|
"brace": "^0.4.0",
|
||||||
"brfs": "^1.2.0",
|
"brfs": "^1.3.0",
|
||||||
"coveralls": "^2.11.2",
|
"coveralls": "^2.11.2",
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^0.4.5",
|
||||||
"grunt-browserify": "^3.3.0",
|
"grunt-browserify": "^3.3.0",
|
||||||
"grunt-contrib-requirejs": "^0.4.4",
|
"grunt-contrib-requirejs": "^0.4.4",
|
||||||
"grunt-contrib-uglify": "^0.7.0",
|
"grunt-contrib-uglify": "^0.7.0",
|
||||||
"grunt-contrib-watch": "^0.6.1",
|
"grunt-contrib-watch": "^0.6.1",
|
||||||
"grunt-eslint": "^5.1.0",
|
"grunt-eslint": "^6.0.0",
|
||||||
"grunt-node-tap": "^0.1.61",
|
"grunt-node-tap": "^0.1.61",
|
||||||
"istanbul": "^0.3.5",
|
"istanbul": "^0.3.5",
|
||||||
"react": "^0.12.2",
|
"react": "^0.12.2",
|
||||||
"tape": "^3.4.0"
|
"tape": "^3.5.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"templates",
|
"templates",
|
||||||
|
|
|
@ -5,58 +5,57 @@
|
||||||
/*global ace:true*/
|
/*global ace:true*/
|
||||||
define(['react', 'lodash'/*, 'ace'*/], function (React, _/*, ace*/) {
|
define(['react', 'lodash'/*, 'ace'*/], function (React, _/*, ace*/) {
|
||||||
|
|
||||||
var editor = React.createClass({
|
var editor = React.createClass({
|
||||||
displayName: 'BraceEditor',
|
displayName: 'BraceEditor',
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
return {
|
return {
|
||||||
editorId: _.uniqueId()
|
editorId: _.uniqueId()
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
componentWillMount: function () {
|
componentWillMount: function () {
|
||||||
|
},
|
||||||
},
|
render: function () {
|
||||||
render: function () {
|
var props = _.omit(this.props, ['ref', 'key', 'value', 'valueLink', 'onChange']);
|
||||||
var props = _.omit(this.props, ['ref', 'key', 'value', 'valueLink', 'onChange']);
|
props.id = this.props.id || this.state.editorId;
|
||||||
props.id = this.props.id || this.state.editorId;
|
return React.DOM.div(props);
|
||||||
return React.DOM.div(props);
|
},
|
||||||
},
|
componentWillUpdate: function (nextProps/*, nextState*/) {
|
||||||
componentWillUpdate: function (nextProps/*, nextState*/) {
|
var value = nextProps.valueLink ? nextProps.valueLink() : nextProps.value;
|
||||||
var value = nextProps.valueLink ? nextProps.valueLink() : nextProps.value;
|
if (this.editor && this.editor.getValue() !== value) {
|
||||||
if (this.editor && this.editor.getValue() !== value) {
|
this.editor.setValue(value, 0);
|
||||||
this.editor.setValue(value, 0);
|
}
|
||||||
}
|
},
|
||||||
},
|
componentDidMount: function () {
|
||||||
componentDidMount: function () {
|
this.editor = ace.edit(this.props.id || this.state.editorId);
|
||||||
this.editor = ace.edit(this.props.id || this.state.editorId);
|
|
||||||
// this.editor.setTheme('ace/theme/monokai');
|
// this.editor.setTheme('ace/theme/monokai');
|
||||||
this.editor.setTheme('ace/theme/solarized_light');
|
this.editor.setTheme('ace/theme/solarized_light');
|
||||||
if (this.props.mode !== 'html') {
|
if (this.props.mode !== 'html') {
|
||||||
this.editor.getSession().setMode('ace/mode/javascript');
|
this.editor.getSession().setMode('ace/mode/javascript');
|
||||||
} else {
|
} else {
|
||||||
this.editor.getSession().setMode('ace/mode/html');
|
this.editor.getSession().setMode('ace/mode/html');
|
||||||
}
|
}
|
||||||
this.editor.getSession().setUseWorker(false);
|
this.editor.getSession().setUseWorker(false);
|
||||||
|
|
||||||
var value = this.props.valueLink ? this.props.valueLink() : this.props.value;
|
var value = this.props.valueLink ? this.props.valueLink() : this.props.value;
|
||||||
this.editor.setValue(value, 0);
|
this.editor.setValue(value, 0);
|
||||||
if (this.props.readOnly) {
|
if (this.props.readOnly) {
|
||||||
this.editor.setReadOnly(true);
|
this.editor.setReadOnly(true);
|
||||||
} else {
|
} else {
|
||||||
this.editor.setReadOnly(false);
|
this.editor.setReadOnly(false);
|
||||||
this.editor.on('change', function (/*e*/) {
|
this.editor.on('change', function (/*e*/) {
|
||||||
if (this.props.valueLink) {
|
if (this.props.valueLink) {
|
||||||
this.props.valueLink(this.editor.getValue());
|
this.props.valueLink(this.editor.getValue());
|
||||||
} else if (this.props.onChange) {
|
} else if (this.props.onChange) {
|
||||||
this.props.onChange({target: {value: this.editor.getValue()}});
|
this.props.onChange({target: {value: this.editor.getValue()}});
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}
|
||||||
|
this.editor.clearSelection();
|
||||||
|
},
|
||||||
|
componentWillUnmount: function () {
|
||||||
|
this.editor.destroy();
|
||||||
}
|
}
|
||||||
this.editor.clearSelection();
|
});
|
||||||
},
|
|
||||||
componentWillUnmount: function () {
|
|
||||||
this.editor.destroy();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
});
|
});
|
|
@ -1,34 +1,34 @@
|
||||||
requirejs.config({
|
requirejs.config({
|
||||||
// baseUrl: '/',
|
// baseUrl: '/',
|
||||||
paths: {
|
paths: {
|
||||||
lodash: '//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min',
|
lodash: '//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min',
|
||||||
jquery: '//code.jquery.com/jquery-1.11.0.min',
|
jquery: '//code.jquery.com/jquery-1.11.0.min',
|
||||||
firebase: 'https://cdn.firebase.com/js/client/2.0.5/firebase',
|
firebase: 'https://cdn.firebase.com/js/client/2.0.5/firebase',
|
||||||
react: '//fb.me/react-with-addons-0.12.2',
|
react: '//fb.me/react-with-addons-0.12.2',
|
||||||
text: 'libs/requirejs-plugins/text',
|
text: 'libs/requirejs-plugins/text',
|
||||||
json: 'libs/requirejs-plugins/json'
|
json: 'libs/requirejs-plugins/json'
|
||||||
//ace: '../ace-builds-1.1.8/src-min/ace',
|
//ace: '../ace-builds-1.1.8/src-min/ace',
|
||||||
//'react/addons': '//fb.me/react-with-addons-0.12.1'
|
//'react/addons': '//fb.me/react-with-addons-0.12.1'
|
||||||
},
|
},
|
||||||
shim: {
|
shim: {
|
||||||
lodash: { exports: '_' },
|
lodash: {exports: '_'},
|
||||||
firebase: { exports: 'Firebase' },
|
firebase: {exports: 'Firebase'},
|
||||||
//ace: { exports: 'ace' },
|
//ace: { exports: 'ace' },
|
||||||
jquery: { exports: '$' },
|
jquery: {exports: '$'},
|
||||||
react: { exports: 'React' }
|
react: {exports: 'React'}
|
||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
'*': {
|
'*': {
|
||||||
'react/addons': 'react'
|
'react/addons': 'react'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
requirejs(['jquery', 'react', './examples'], function ($, React, Examples) {
|
requirejs(['jquery', 'react', './examples'], function ($, React, Examples) {
|
||||||
'use strict';
|
'use strict';
|
||||||
/*eslint new-cap:0*/
|
/*eslint new-cap:0*/
|
||||||
var elem = React.createElement(Examples);
|
var elem = React.createElement(Examples);
|
||||||
React.render(elem, document.getElementById('home-section'));
|
React.render(elem, document.getElementById('home-section'));
|
||||||
//window.fiddle = React.render(fiddle(), document.getElementById('container'));
|
//window.fiddle = React.render(fiddle(), document.getElementById('container'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ function executeOptions(currentOptions) {
|
||||||
if (currentOptions.version) {
|
if (currentOptions.version) {
|
||||||
console.log('v' + pkg.version);
|
console.log('v' + pkg.version);
|
||||||
} else if (currentOptions.help) {
|
} else if (currentOptions.help) {
|
||||||
if (files.length) {
|
if (files.length) {
|
||||||
console.log(options.generateHelpForOption(files[0]));
|
console.log(options.generateHelpForOption(files[0]));
|
||||||
} else {
|
} else {
|
||||||
console.log(options.generateHelp());
|
console.log(options.generateHelp());
|
||||||
|
|
|
@ -312,21 +312,21 @@ function isTag(node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelfClosingHtmlTags(nodes) {
|
function handleSelfClosingHtmlTags(nodes) {
|
||||||
return _(nodes)
|
return _(nodes)
|
||||||
.map(function (node) {
|
.map(function (node) {
|
||||||
var externalNodes = [];
|
var externalNodes = [];
|
||||||
node.children = handleSelfClosingHtmlTags(node.children);
|
node.children = handleSelfClosingHtmlTags(node.children);
|
||||||
if (node.type === 'tag' && _.contains(htmlSelfClosingTags, node.name)) {
|
if (node.type === 'tag' && _.contains(htmlSelfClosingTags, node.name)) {
|
||||||
externalNodes = _.filter(node.children, isTag);
|
externalNodes = _.filter(node.children, isTag);
|
||||||
_.forEach(externalNodes, function (child) {
|
_.forEach(externalNodes, function (child) {
|
||||||
child.parent = node;
|
child.parent = node;
|
||||||
});
|
});
|
||||||
node.children = _.reject(node.children, isTag);
|
node.children = _.reject(node.children, isTag);
|
||||||
}
|
}
|
||||||
return [node].concat(externalNodes);
|
return [node].concat(externalNodes);
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
.value();
|
.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue