enable rule object-shorthand and fix errors
This commit is contained in:
parent
4cb8c4524c
commit
5b664b9904
|
@ -3,7 +3,6 @@
|
||||||
"plugins": ["lodash", "wix-editor"],
|
"plugins": ["lodash", "wix-editor"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"semi": [2, "always"],
|
"semi": [2, "always"],
|
||||||
"object-shorthand": 0,
|
|
||||||
"prefer-arrow-callback": 0,
|
"prefer-arrow-callback": 0,
|
||||||
"prefer-spread": 0,
|
"prefer-spread": 0,
|
||||||
"prefer-template": 0,
|
"prefer-template": 0,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"rules": {
|
"rules": {
|
||||||
"strict": [2, "function"],
|
"strict": [2, "function"],
|
||||||
"no-var": 0
|
"no-var": 0,
|
||||||
|
"object-shorthand": 0
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"rules": {
|
"rules": {
|
||||||
"strict": [2, "function"],
|
"strict": [2, "function"],
|
||||||
"no-var": 0
|
"no-var": 0,
|
||||||
|
"object-shorthand": 0
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
|
|
|
@ -121,23 +121,24 @@ function buildError(context, node, msg) {
|
||||||
* @return {{pos:Pos, start:number, end:number}}
|
* @return {{pos:Pos, start:number, end:number}}
|
||||||
*/
|
*/
|
||||||
function getNodeLoc(context, node) {
|
function getNodeLoc(context, node) {
|
||||||
|
const start = node.startIndex;
|
||||||
const pos = getLine(context.html, node);
|
const pos = getLine(context.html, node);
|
||||||
let end;
|
let end;
|
||||||
if (node.data) {
|
if (node.data) {
|
||||||
end = node.startIndex + node.data.length;
|
end = start + node.data.length;
|
||||||
} else if (node.next) { // eslint-disable-line
|
} else if (node.next) { // eslint-disable-line
|
||||||
end = node.next.startIndex;
|
end = node.next.startIndex;
|
||||||
} else {
|
} else {
|
||||||
end = context.html.length;
|
end = context.html.length;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
pos: pos,
|
pos,
|
||||||
start: node.startIndex,
|
start,
|
||||||
end: end
|
end
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
RTCodeError: RTCodeError,
|
RTCodeError,
|
||||||
getNodeLoc: getNodeLoc
|
getNodeLoc
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ function convertFile(source, target, options, context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
convertFile: convertFile,
|
convertFile,
|
||||||
context: require('./context'),
|
context: require('./context'),
|
||||||
_test: {}
|
_test: {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,10 +91,10 @@ function execute(args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
context: context,
|
context,
|
||||||
execute: execute,
|
execute,
|
||||||
executeOptions: executeOptions,
|
executeOptions,
|
||||||
handleSingleFile: handleSingleFile,
|
handleSingleFile,
|
||||||
convertTemplateToReact: reactTemplates.convertTemplateToReact,
|
convertTemplateToReact: reactTemplates.convertTemplateToReact,
|
||||||
convertStyle: rtStyle.convert
|
convertStyle: rtStyle.convert
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,21 +31,21 @@ const context = {
|
||||||
color: true,
|
color: true,
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
report: function (msg) {
|
report(msg) {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
},
|
},
|
||||||
verbose: function (msg) {
|
verbose(msg) {
|
||||||
if (context.options.verbose) {
|
if (context.options.verbose) {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
info: function (msg, file, line, column) {
|
info(msg, file, line, column) {
|
||||||
context.issue(MESSAGE_LEVEL.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);
|
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);
|
context.issue(MESSAGE_LEVEL.ERROR, msg, file, line, column, startOffset, endOffset);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -57,16 +57,16 @@ const context = {
|
||||||
* @param {number=} startOffset
|
* @param {number=} startOffset
|
||||||
* @param {number=} endOffset
|
* @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)});
|
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;
|
return context.messages;
|
||||||
},
|
},
|
||||||
clear: function () {
|
clear() {
|
||||||
context.messages = [];
|
context.messages = [];
|
||||||
},
|
},
|
||||||
hasErrors: function () {
|
hasErrors() {
|
||||||
return _.some(context.messages, {level: MESSAGE_LEVEL.ERROR});
|
return _.some(context.messages, {level: MESSAGE_LEVEL.ERROR});
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
@ -74,7 +74,7 @@ const context = {
|
||||||
outFile: null,
|
outFile: null,
|
||||||
format: 'stylish'
|
format: 'stylish'
|
||||||
},
|
},
|
||||||
MESSAGE_LEVEL: MESSAGE_LEVEL
|
MESSAGE_LEVEL
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = context;
|
module.exports = context;
|
||||||
|
|
|
@ -158,9 +158,7 @@ module.exports = function (results) {
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
align: ['', 'r', 'l'],
|
align: ['', 'r', 'l'],
|
||||||
stringLength: function (str) {
|
stringLength: str => chalk.stripColor(str).length
|
||||||
return chalk.stripColor(str).length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
).split('\n').map(function (el) {
|
).split('\n').map(function (el) {
|
||||||
return el.replace(/(\d+)\s+(\d+)/, function (m, p1, p2) {
|
return el.replace(/(\d+)\s+(\d+)/, function (m, p1, p2) {
|
||||||
|
|
|
@ -22,6 +22,6 @@ function createRelativeReadFileSync(baseFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isStale: isStale,
|
isStale,
|
||||||
createRelativeReadFileSync: createRelativeReadFileSync
|
createRelativeReadFileSync
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,6 +14,6 @@ const native = {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
native: native,
|
native,
|
||||||
dom: {}
|
dom: {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,9 +56,9 @@ const templates = {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
htmlSelfClosingTags: htmlSelfClosingTags,
|
htmlSelfClosingTags,
|
||||||
attributesMapping: attributesMapping,
|
attributesMapping,
|
||||||
classNameProp: classNameProp,
|
classNameProp,
|
||||||
shouldUseCreateElement: shouldUseCreateElement,
|
shouldUseCreateElement,
|
||||||
templates: templates
|
templates
|
||||||
};
|
};
|
||||||
|
|
|
@ -317,10 +317,10 @@ function defaultContext(html, options, reportContext) {
|
||||||
return {
|
return {
|
||||||
boundParams: [],
|
boundParams: [],
|
||||||
injectedFunctions: [],
|
injectedFunctions: [],
|
||||||
html: html,
|
html,
|
||||||
options: options,
|
options,
|
||||||
defines: options.defines ? _.clone(options.defines) : defaultDefines,
|
defines: options.defines ? _.clone(options.defines) : defaultDefines,
|
||||||
reportContext: reportContext
|
reportContext
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,12 +602,10 @@ function generate(data, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
convertTemplateToReact: convertTemplateToReact,
|
convertTemplateToReact,
|
||||||
convertRT: convertRT,
|
convertRT,
|
||||||
convertJSRTToJS: convertJSRTToJS,
|
convertJSRTToJS,
|
||||||
RTCodeError: RTCodeError,
|
RTCodeError,
|
||||||
normalizeName: utils.normalizeName,
|
normalizeName: utils.normalizeName,
|
||||||
_test: {
|
_test: {convertText}
|
||||||
convertText: convertText
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,6 @@ function convertValue(p, v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
convert: convert,
|
convert,
|
||||||
convertBody: convertBody
|
convertBody
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,7 +95,7 @@ function errorEqualMessage(err, file) {
|
||||||
endOffset: err.endOffset,
|
endOffset: err.endOffset,
|
||||||
msg: err.message,
|
msg: err.message,
|
||||||
level: 'ERROR',
|
level: 'ERROR',
|
||||||
file: file
|
file
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,11 @@ function codeToHtml(code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
normalizeHtml: normalizeHtml,
|
normalizeHtml,
|
||||||
compareAndWrite: compareAndWrite,
|
compareAndWrite,
|
||||||
readFileNormalized: readFileNormalized,
|
readFileNormalized,
|
||||||
readFile: readFile,
|
readFile,
|
||||||
joinDataPath: joinDataPath,
|
joinDataPath,
|
||||||
rtToHtml: rtToHtml,
|
rtToHtml,
|
||||||
codeToHtml: codeToHtml
|
codeToHtml
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue