enable rule object-shorthand and fix errors

This commit is contained in:
Omer Ganim 2016-04-27 14:04:35 +03:00
parent 4cb8c4524c
commit 5b664b9904
15 changed files with 53 additions and 55 deletions

View File

@ -3,7 +3,6 @@
"plugins": ["lodash", "wix-editor"],
"rules": {
"semi": [2, "always"],
"object-shorthand": 0,
"prefer-arrow-callback": 0,
"prefer-spread": 0,
"prefer-template": 0,

View File

@ -1,7 +1,8 @@
{
"rules": {
"strict": [2, "function"],
"no-var": 0
"no-var": 0,
"object-shorthand": 0
},
"env": {
"browser": true,

View File

@ -1,7 +1,8 @@
{
"rules": {
"strict": [2, "function"],
"no-var": 0
"no-var": 0,
"object-shorthand": 0
},
"env": {
"browser": true,

View File

@ -121,23 +121,24 @@ function buildError(context, node, msg) {
* @return {{pos:Pos, start:number, end:number}}
*/
function getNodeLoc(context, node) {
const start = node.startIndex;
const pos = getLine(context.html, node);
let end;
if (node.data) {
end = node.startIndex + node.data.length;
end = start + node.data.length;
} else if (node.next) { // eslint-disable-line
end = node.next.startIndex;
} else {
end = context.html.length;
}
return {
pos: pos,
start: node.startIndex,
end: end
pos,
start,
end
};
}
module.exports = {
RTCodeError: RTCodeError,
getNodeLoc: getNodeLoc
RTCodeError,
getNodeLoc
};

View File

@ -47,7 +47,7 @@ function convertFile(source, target, options, context) {
}
module.exports = {
convertFile: convertFile,
convertFile,
context: require('./context'),
_test: {}
};

View File

@ -91,10 +91,10 @@ function execute(args) {
}
module.exports = {
context: context,
execute: execute,
executeOptions: executeOptions,
handleSingleFile: handleSingleFile,
context,
execute,
executeOptions,
handleSingleFile,
convertTemplateToReact: reactTemplates.convertTemplateToReact,
convertStyle: rtStyle.convert
};

View File

@ -31,21 +31,21 @@ const context = {
color: true,
/** @type {string} */
cwd: process.cwd(),
report: function (msg) {
report(msg) {
console.log(msg);
},
verbose: function (msg) {
verbose(msg) {
if (context.options.verbose) {
console.log(msg);
}
},
info: function (msg, file, line, column) {
info(msg, file, line, column) {
context.issue(MESSAGE_LEVEL.INFO, msg, file, line, column);
},
warn: function (msg, file, line, column, startOffset, endOffset) {
warn(msg, file, line, column, startOffset, endOffset) {
context.issue(MESSAGE_LEVEL.WARN, msg, file, line, column, startOffset, endOffset);
},
error: function (msg, file, line, column, startOffset, endOffset) {
error(msg, file, line, column, startOffset, endOffset) {
context.issue(MESSAGE_LEVEL.ERROR, msg, file, line, column, startOffset, endOffset);
},
/**
@ -57,16 +57,16 @@ const context = {
* @param {number=} startOffset
* @param {number=} endOffset
*/
issue: function (level, msg, file, line, column, startOffset, endOffset) {
issue(level, msg, file, line, column, startOffset, endOffset) {
context.messages.push({level, msg, file: file || null, line: norm(line), column: norm(column), index: norm(startOffset), startOffset: norm(startOffset), endOffset: norm(endOffset)});
},
getMessages: function () {
getMessages() {
return context.messages;
},
clear: function () {
clear() {
context.messages = [];
},
hasErrors: function () {
hasErrors() {
return _.some(context.messages, {level: MESSAGE_LEVEL.ERROR});
},
options: {
@ -74,7 +74,7 @@ const context = {
outFile: null,
format: 'stylish'
},
MESSAGE_LEVEL: MESSAGE_LEVEL
MESSAGE_LEVEL
};
module.exports = context;

View File

@ -158,9 +158,7 @@ module.exports = function (results) {
}),
{
align: ['', 'r', 'l'],
stringLength: function (str) {
return chalk.stripColor(str).length;
}
stringLength: str => chalk.stripColor(str).length
}
).split('\n').map(function (el) {
return el.replace(/(\d+)\s+(\d+)/, function (m, p1, p2) {

View File

@ -22,6 +22,6 @@ function createRelativeReadFileSync(baseFile) {
}
module.exports = {
isStale: isStale,
createRelativeReadFileSync: createRelativeReadFileSync
isStale,
createRelativeReadFileSync
};

View File

@ -14,6 +14,6 @@ const native = {
};
module.exports = {
native: native,
native,
dom: {}
};

View File

@ -56,9 +56,9 @@ const templates = {
};
module.exports = {
htmlSelfClosingTags: htmlSelfClosingTags,
attributesMapping: attributesMapping,
classNameProp: classNameProp,
shouldUseCreateElement: shouldUseCreateElement,
templates: templates
htmlSelfClosingTags,
attributesMapping,
classNameProp,
shouldUseCreateElement,
templates
};

View File

@ -317,10 +317,10 @@ function defaultContext(html, options, reportContext) {
return {
boundParams: [],
injectedFunctions: [],
html: html,
options: options,
html,
options,
defines: options.defines ? _.clone(options.defines) : defaultDefines,
reportContext: reportContext
reportContext
};
}
@ -602,12 +602,10 @@ function generate(data, options) {
}
module.exports = {
convertTemplateToReact: convertTemplateToReact,
convertRT: convertRT,
convertJSRTToJS: convertJSRTToJS,
RTCodeError: RTCodeError,
convertTemplateToReact,
convertRT,
convertJSRTToJS,
RTCodeError,
normalizeName: utils.normalizeName,
_test: {
convertText: convertText
}
_test: {convertText}
};

View File

@ -43,6 +43,6 @@ function convertValue(p, v) {
}
module.exports = {
convert: convert,
convertBody: convertBody
convert,
convertBody
};

View File

@ -95,7 +95,7 @@ function errorEqualMessage(err, file) {
endOffset: err.endOffset,
msg: err.message,
level: 'ERROR',
file: file
file
};
}

View File

@ -76,11 +76,11 @@ function codeToHtml(code) {
}
module.exports = {
normalizeHtml: normalizeHtml,
compareAndWrite: compareAndWrite,
readFileNormalized: readFileNormalized,
readFile: readFile,
joinDataPath: joinDataPath,
rtToHtml: rtToHtml,
codeToHtml: codeToHtml
normalizeHtml,
compareAndWrite,
readFileNormalized,
readFile,
joinDataPath,
rtToHtml,
codeToHtml
};