Comparing version 1.2.2 to 1.2.3
@@ -33,2 +33,6 @@ module.exports = { | ||
], | ||
"object-curly-spacing": [ | ||
"error", | ||
"always" | ||
], | ||
"comma-dangle": "error", | ||
@@ -35,0 +39,0 @@ "comma-spacing": "error", |
# Changelog | ||
## 1.2.3 () | ||
- Added support for `solium-disable-previous-line` comment directive. | ||
- Added support for `solium-enable` comment directive. See [configuring with comments](https://ethlint.readthedocs.io/en/latest/user-guide.html#configuring-with-comments). This feature currently has a limitation which has been documented in [Known Issues](https://ethlint.readthedocs.io/en/latest/known-issues.html). | ||
- Added Pull Request template. | ||
- Fixed rule `no-empty-blocks` to report function declarations with empty bodies. Fallback and `payable` functions and `payable` constructors are not reported if their body is empty. See [#254](https://github.com/duaraghav8/Ethlint/issues/254). | ||
- Fixed rule `quotes` to stop reporting false positives due to brackets enclosing strings (see [#240](https://github.com/duaraghav8/Ethlint/issues/240)). | ||
- Modified rule `uppercase` to allow up to 2 leading and trailing underscores for a constant's name. | ||
## 1.2.2 (2019-01-13) | ||
@@ -4,0 +12,0 @@ - Added support for parsing function declarations inside Inline Assembly blocks. |
@@ -55,3 +55,3 @@ /** | ||
function insertTextAt(index, text) { | ||
validateArgs({index, text}); | ||
validateArgs({ index, text }); | ||
@@ -70,3 +70,3 @@ return { | ||
insertTextAfter(node, text) { | ||
validateArgs({node: node, text: text}); | ||
validateArgs({ node: node, text: text }); | ||
return this.insertTextAfterRange([node.start, node.end], text); | ||
@@ -76,3 +76,3 @@ }, | ||
insertTextBefore(node, text) { | ||
validateArgs({node: node, text: text}); | ||
validateArgs({ node: node, text: text }); | ||
return this.insertTextBeforeRange([node.start, node.end], text); | ||
@@ -86,3 +86,3 @@ }, | ||
replaceText(node, text) { | ||
validateArgs({node: node, text: text}); | ||
validateArgs({ node: node, text: text }); | ||
return this.replaceTextRange([node.start, node.end], text); | ||
@@ -92,3 +92,3 @@ }, | ||
insertTextAfterRange(range, text) { | ||
validateArgs({range: range, text: text}); | ||
validateArgs({ range: range, text: text }); | ||
return insertTextAt(range [1], text); | ||
@@ -98,3 +98,3 @@ }, | ||
insertTextBeforeRange(range, text) { | ||
validateArgs({range: range, text: text}); | ||
validateArgs({ range: range, text: text }); | ||
return insertTextAt(range [0], text); | ||
@@ -104,3 +104,3 @@ }, | ||
removeRange(range) { | ||
validateArgs({range: range}); | ||
validateArgs({ range: range }); | ||
return this.replaceTextRange(range, ""); | ||
@@ -110,3 +110,3 @@ }, | ||
replaceChar(index, newChar) { | ||
validateArgs({index: index, char: newChar}); | ||
validateArgs({ index: index, char: newChar }); | ||
return this.replaceTextRange([index, index + 1], newChar); | ||
@@ -116,3 +116,3 @@ }, | ||
replaceTextRange(range, text) { | ||
validateArgs({range: range, text: text}); | ||
validateArgs({ range: range, text: text }); | ||
return { | ||
@@ -119,0 +119,0 @@ range: range, |
/** | ||
* @fileoverview Analyzes the given comment token stream for solium configurtion directives | ||
* @fileoverview Analyzes the given comment token stream for configuration directives | ||
* @author Raghav Dua <duaraghav8@gmail.com> | ||
@@ -12,7 +12,2 @@ */ | ||
/** | ||
* Parser can currently detect configuration to | ||
* - Disable linting on the next line | ||
* - Disable linting on the current line | ||
* - Disable linting on entire file | ||
* (all rules or specific ones (comma-separated)) | ||
* NOTE: Constructor & Public functions of this class should have argument validations | ||
@@ -42,3 +37,3 @@ */ | ||
if (typeof ruleName !== "string" || ruleName.length < 1) { | ||
throw new Error("Rule name should be a non-empty string string."); | ||
throw new Error("Rule name should be a non-empty string."); | ||
} | ||
@@ -80,7 +75,43 @@ | ||
_removeRulesFromLineConfig(line, rules) { | ||
if (rules === this.ALL_RULES) { | ||
// delete disabled-rule configuration for this line, since all rules | ||
// are to be enabled. | ||
delete this.lineConfigurations[line]; | ||
return; | ||
} | ||
/** | ||
* A special case arises when the user has disabled all rules | ||
* and then wants to enable a select few. When all rules are disabled, | ||
* the configuration for a line is set to `all`. This means there is no | ||
* array of rules to delete the enabled ones from. | ||
* | ||
* Right now, this edge case is not accounted for. In the below example, | ||
* `throw;` will not be reported, which goes against expectations. | ||
* | ||
* contract Foo { | ||
* // solium-disable | ||
* function b11d() { | ||
* // solium-enable security/no-throw | ||
* throw; | ||
* } | ||
* } | ||
* | ||
* TODO: Account for this edge case. | ||
*/ | ||
if (this.lineConfigurations[line] === this.ALL_RULES) { | ||
return; | ||
} | ||
// Delete rules from line's disabled-rule configuration list | ||
this.lineConfigurations[line] = this.lineConfigurations[line].filter(lc => { return !rules.includes(lc); }); | ||
} | ||
_constructLineConfigurationFromComment(token) { | ||
const SD = "solium-disable", SDL = `${SD}-line`, | ||
SDNL = `${SD}-next-line`, text = this._cleanCommentText(token.text); | ||
const text = this._cleanCommentText(token.text); | ||
const S = "solium", SD = `${S}-disable`, SDL = `${SD}-line`, | ||
SDNL = `${SD}-next-line`, SDPL = `${SD}-previous-line`, SE = `${S}-enable`; | ||
// Important that we check for SDNL & SDL first. If they exist, then includes() will return true for SD anyway. | ||
// Important that we check for SDNL, SDPL & SDL first. If they exist, then includes() will return true for SD anyway. | ||
if (text.includes(SDL)) { | ||
@@ -90,3 +121,14 @@ return this._addRulesToLineConfig(astUtils.getLine(token), this._parseRuleNames(text, SDL)); | ||
// Notice how we use getEndingLine() for SDNL & SD to ensure that in case of block | ||
if (text.includes(SDPL)) { | ||
const targetLine = astUtils.getLine(token) - 1; | ||
// SDPL shouldn't be used on first line of the file. | ||
if (targetLine < 1) { | ||
throw new Error(`Comment directive "${SDPL}" refers to an invalid line number.`); | ||
} | ||
return this._addRulesToLineConfig(targetLine, this._parseRuleNames(text, SDPL)); | ||
} | ||
// Notice how we use getEndingLine() for below directives to ensure that in case of a block | ||
// comment directive spanning over multiple lines, the disabling starts after the comment ends. | ||
@@ -102,7 +144,20 @@ // (SDL should disable on line on which the comment starts, so getLine() is used for it) | ||
// Set desired configuration for all lines below the SD comment directive | ||
// Disable rules for all lines below the SD comment directive | ||
this._toEndOfFile( | ||
currLine + 1, lineNum => { objContext._addRulesToLineConfig(lineNum, rulesToDisable); }); | ||
currLine + 1, | ||
lineNum => { objContext._addRulesToLineConfig(lineNum, rulesToDisable); } | ||
); | ||
} | ||
if (text.includes(SE)) { | ||
const currLine = astUtils.getEndingLine(token), rulesToEnable = this._parseRuleNames(text, SE); | ||
const objContext = this; | ||
// Remove disabled-rule entries for all lines below the SE comment directive | ||
this._toEndOfFile( | ||
currLine + 1, | ||
lineNum => { objContext._removeRulesFromLineConfig(lineNum, rulesToEnable); } | ||
); | ||
} | ||
// If none of the above branches were executed, then the current comment is not a solium directive. | ||
@@ -109,0 +164,0 @@ } |
@@ -9,3 +9,3 @@ /** | ||
const path = require("path"), jsdiff = require("diff"), | ||
sort = require("lodash/sortBy"), Table = require("text-table"), {EOL} = require("os"); | ||
sort = require("lodash/sortBy"), Table = require("text-table"), { EOL } = require("os"); | ||
require("colors"); | ||
@@ -53,3 +53,3 @@ | ||
const {message, type} = issue; | ||
const { message, type } = issue; | ||
process.stdout.write(`${message[colorInternalIssue(type)]}${EOL}`); | ||
@@ -56,0 +56,0 @@ |
@@ -116,3 +116,3 @@ /** | ||
const {node} = emitted, programBody = node.body; | ||
const { node } = emitted, programBody = node.body; | ||
@@ -119,0 +119,0 @@ for (let i = 1; i < programBody.length; i++) { |
@@ -25,3 +25,3 @@ /** | ||
const {node} = emitted, {body} = node; | ||
const { node } = emitted, { body } = node; | ||
@@ -28,0 +28,0 @@ body.filter(child => { |
@@ -23,3 +23,3 @@ /** | ||
function isEvent(expr, eventDeclarations) { | ||
for (let {node, enclosingContract} of eventDeclarations) { | ||
for (let { node, enclosingContract } of eventDeclarations) { | ||
if (expr.callee.name === node.name && sourceCode.isAChildOf(expr, enclosingContract)) { | ||
@@ -36,3 +36,3 @@ return true; | ||
const { node } = emitted; | ||
(!emitted.exit) && events.push({node, enclosingContract: sourceCode.getParent(node)}); | ||
(!emitted.exit) && events.push({ node, enclosingContract: sourceCode.getParent(node) }); | ||
} | ||
@@ -39,0 +39,0 @@ |
@@ -135,3 +135,3 @@ /** | ||
const {node} = emitted, {body} = node; | ||
const { node } = emitted, { body } = node; | ||
let cursor = 0; | ||
@@ -138,0 +138,0 @@ |
@@ -43,3 +43,3 @@ /** | ||
const {node} = emitted, | ||
const { node } = emitted, | ||
programNode = context.getSourceCode().getParent(node), | ||
@@ -46,0 +46,0 @@ indexOfNode = programNode.body.indexOf(node), |
@@ -22,3 +22,3 @@ /** | ||
create: function(context) { | ||
create(context) { | ||
@@ -30,4 +30,31 @@ function report(node, loc) { | ||
let similarNodeTypes = ["ContractStatement", "LibraryStatement", "InterfaceStatement"]; | ||
function isFunc(node) { | ||
return node.type === "FunctionDeclaration"; | ||
} | ||
function isConstructor(node) { | ||
return node.type === "ConstructorDeclaration"; | ||
} | ||
function isFuncOrConstructor(node) { | ||
return isFunc(node) || isConstructor(node); | ||
} | ||
function isFallbackFunc(node) { | ||
return isFunc(node) && node.name === null; | ||
} | ||
function isPayableFuncOrCons(node) { | ||
function isPayable(n) { | ||
for (let m of (n.modifiers || [])) { | ||
if (m.name === "payable") { return true; } | ||
} | ||
return false; | ||
} | ||
return isFuncOrConstructor(node) && isPayable(node); | ||
} | ||
const similarNodeTypes = ["ContractStatement", "LibraryStatement", "InterfaceStatement"]; | ||
function inspectCLI(emitted) { | ||
@@ -47,13 +74,10 @@ let node = emitted.node, | ||
function inspectBlockStatement(emitted) { | ||
const { node } = emitted, { body } = node; | ||
const { node } = emitted, { body } = node, | ||
parent = context.getSourceCode().getParent(node); | ||
// Allow Function & Constructor declarations to have empty bodies. | ||
if ( | ||
emitted.exit || | ||
["FunctionDeclaration", "ConstructorDeclaration"].includes(context.getSourceCode().getParent(node).type) | ||
) { | ||
if (emitted.exit || isFallbackFunc(parent) || isPayableFuncOrCons(parent)) { | ||
return; | ||
} | ||
if (body && body.constructor.name === "Array" && !body.length) { | ||
if (Array.isArray(body) && body.length === 0) { | ||
report(node); | ||
@@ -69,3 +93,3 @@ } | ||
similarNodeTypes.forEach(function(nodeName) { | ||
response [nodeName] = inspectCLI; | ||
response[nodeName] = inspectCLI; | ||
}); | ||
@@ -72,0 +96,0 @@ |
@@ -81,3 +81,3 @@ /** | ||
const {node} = emitted, | ||
const { node } = emitted, | ||
nodesAllowedAbove = ["ExperimentalPragmaStatement", "PragmaStatement"], | ||
@@ -84,0 +84,0 @@ programNode = context.getSourceCode().getParent(node); |
@@ -8,3 +8,3 @@ /** | ||
let jsStringEscape = require("js-string-escape"); | ||
const jsStringEscape = require("js-string-escape"); | ||
@@ -55,3 +55,3 @@ /** | ||
const selectedQuoteStyleLiteralRegExp = new RegExp("^\\" + quote + ".*\\" + quote + "$"); | ||
const selectedQuoteStyleLiteralRegExp = new RegExp("^(\\(\\s*)?\\" + quote + ".*\\" + quote + "(\\s*\\))?$"); | ||
@@ -68,9 +68,14 @@ | ||
if (!selectedQuoteStyleLiteralRegExp.test(nodeText)) { | ||
let fixedString = quote + jsStringEscape(node.value) + quote; | ||
const errorObject = { | ||
node, | ||
fix(fixer) { | ||
return fixer.replaceText(node, fixedString); | ||
const fixedString = quote + jsStringEscape(node.value) + quote, | ||
currentQuote = (quote === "'" ? "\"" : "'"); | ||
const openingQuoteI = nodeText.indexOf(currentQuote), | ||
closingQuoteI = nodeText.lastIndexOf(currentQuote); | ||
const fixedNodeText = nodeText.slice(0, openingQuoteI) + fixedString + nodeText.slice(closingQuoteI+1); | ||
return fixer.replaceText(node, fixedNodeText); | ||
}, | ||
message: `'${node.value}': String literal must be quoted with ${quoteStyle} quotes.` | ||
message: `String literal must be quoted with ${quoteStyle} quotes.` | ||
}; | ||
@@ -84,3 +89,3 @@ | ||
function inspectImportStatement(emitted) { | ||
const {node} = emitted, | ||
const { node } = emitted, | ||
nodeText = sourceCode.getText(node), expectedString = `${quote}${node.from}${quote}`; | ||
@@ -87,0 +92,0 @@ |
@@ -24,3 +24,3 @@ /** | ||
let upperCaseRegEx = /^[A-Z]([A-Z_0-9]*[A-Z0-9])?$/; | ||
let upperCaseRegEx = /^_{0,2}[A-Z]([A-Z_0-9]*[A-Z0-9])?_{0,2}$/; | ||
@@ -30,3 +30,3 @@ function reportNode(node) { | ||
node: node, | ||
message: `Constant name '${node.name}' doesn't follow the UPPER_CASE notation` | ||
message: `"${node.name}" doesn't follow the UPPER_CASE notation` | ||
}); | ||
@@ -33,0 +33,0 @@ } |
{ | ||
"name": "ethlint", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Linter to identify and fix Style & Security issues in Solidity", | ||
@@ -11,3 +11,4 @@ "main": "./lib/solium.js", | ||
"test": "nyc --reporter=text --reporter=html mocha --require should --reporter spec --recursive", | ||
"lint": "eslint lib/ test/ bin/ config/" | ||
"lint": "eslint lib/ test/ bin/ config/", | ||
"lint-fix": "eslint lib/ test/ bin/ config/ --fix" | ||
}, | ||
@@ -14,0 +15,0 @@ "keywords": [ |
@@ -9,3 +9,2 @@ <p align="center"> | ||
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/Solium-linter/Lobby) | ||
[![Latest News](https://img.shields.io/badge/Blog-Medium-yellowgreen.svg)](https://medium.com/solium) | ||
@@ -16,2 +15,4 @@ Ethlint (Formerly Solium) analyzes your Solidity code for style & security issues and fixes them. | ||
Before beginning to work on a contribution, please read the [Guidelines](./CONTRIBUTING.md). | ||
## Install | ||
@@ -45,3 +46,4 @@ ```bash | ||
"quotes": ["error", "double"], | ||
"indentation": ["error", 4] | ||
"indentation": ["error", 4], | ||
"linebreak-style": ["error", "unix"] | ||
} | ||
@@ -51,3 +53,3 @@ } | ||
To know which lint rules Solium applies for you, see [Style rules](http://solium.readthedocs.io/en/latest/user-guide.html#list-of-style-rules) and [Security rules](https://www.npmjs.com/package/solium-plugin-security#list-of-rules). | ||
To know which lint rules Solium applies for you, see [Style rules](http://ethlint.readthedocs.io/en/latest/user-guide.html#list-of-style-rules) and [Security rules](https://www.npmjs.com/package/solium-plugin-security#list-of-rules). | ||
@@ -54,0 +56,0 @@ --- |
@@ -28,6 +28,6 @@ /** | ||
let fixerPackets = [ | ||
rf.insertTextAfter({type: "a", start: 0, end: 3}, "123"), | ||
rf.insertTextBefore({type: "a", start: 4, end: 6}, "@@@"), | ||
rf.replaceText({type: "a", start: 8, end: 11}, "+++"), | ||
rf.remove({type: "a", start: 12, end: 14}), | ||
rf.insertTextAfter({ type: "a", start: 0, end: 3 }, "123"), | ||
rf.insertTextBefore({ type: "a", start: 4, end: 6 }, "@@@"), | ||
rf.replaceText({ type: "a", start: 8, end: 11 }, "+++"), | ||
rf.remove({ type: "a", start: 12, end: 14 }), | ||
rf.insertTextAfterRange([15, 16], "==="), | ||
@@ -83,3 +83,3 @@ rf.insertTextBeforeRange([18, 22], "$$$"), | ||
mfp.bind( | ||
mfp, [{range: [2, 5], text: ""}, {range: [4, 8], text: "%%%"}], "abcdefghijk" | ||
mfp, [{ range: [2, 5], text: "" }, { range: [4, 8], text: "%%%" }], "abcdefghijk" | ||
).should.throw(); | ||
@@ -86,0 +86,0 @@ |
@@ -27,3 +27,3 @@ /** | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9} | ||
node: { type: "Literal", start: 1, end: 9 } | ||
}]; | ||
@@ -37,4 +37,4 @@ | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9}, | ||
fix: {range: [1, 4], text: ""} | ||
node: { type: "Literal", start: 1, end: 9 }, | ||
fix: { range: [1, 4], text: "" } | ||
}]; | ||
@@ -93,3 +93,3 @@ | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9} | ||
node: { type: "Literal", start: 1, end: 9 } | ||
}]; | ||
@@ -137,3 +137,3 @@ | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9} | ||
node: { type: "Literal", start: 1, end: 9 } | ||
}, | ||
@@ -146,4 +146,4 @@ { | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9}, | ||
fix: {range: [3, 8], text: "***"} // replace | ||
node: { type: "Literal", start: 1, end: 9 }, | ||
fix: { range: [3, 8], text: "***" } // replace | ||
}, | ||
@@ -156,3 +156,3 @@ { | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9} | ||
node: { type: "Literal", start: 1, end: 9 } | ||
}, | ||
@@ -165,4 +165,4 @@ { | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9}, | ||
fix: {range: [8, 24], text: ""} // delete | ||
node: { type: "Literal", start: 1, end: 9 }, | ||
fix: { range: [8, 24], text: "" } // delete | ||
} | ||
@@ -203,4 +203,4 @@ ]; | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9}, | ||
fix: {range: [5, 10], text: "^_^"} // shouldn't get applied | ||
node: { type: "Literal", start: 1, end: 9 }, | ||
fix: { range: [5, 10], text: "^_^" } // shouldn't get applied | ||
}, | ||
@@ -213,4 +213,4 @@ { | ||
column: 4, | ||
node: {type: "Literal", start: 1, end: 9}, | ||
fix: {range: [3, 8], text: "***"} | ||
node: { type: "Literal", start: 1, end: 9 }, | ||
fix: { range: [3, 8], text: "***" } | ||
} | ||
@@ -246,3 +246,3 @@ ]; | ||
scf.applyFixes.bind(scf, | ||
[{range: [2, 5], text: ""}, {range: [4, 8], text: "%%%"}], "abcdefghijk" | ||
[{ range: [2, 5], text: "" }, { range: [4, 8], text: "%%%" }], "abcdefghijk" | ||
).should.throw(); | ||
@@ -249,0 +249,0 @@ |
@@ -22,7 +22,11 @@ /** | ||
it("should expose a class to create CDP objects", done => { | ||
function shouldThrow(f, msg) { | ||
try { f(); } catch (e) { e.message.should.equal(msg); } | ||
function shouldThrow(f, msg) { | ||
try { | ||
f(); | ||
} catch (e) { | ||
e.message.should.equal(msg); | ||
} | ||
} | ||
it("should expose a class to create CDP objects", done => { | ||
CommentDirectiveParser.should.be.type("function"); | ||
@@ -60,2 +64,3 @@ | ||
cdp._addRulesToLineConfig.should.be.type("function"); | ||
cdp._removeRulesFromLineConfig.should.type("function"); | ||
cdp._constructLineConfigurationFromComment.should.be.type("function"); | ||
@@ -76,3 +81,3 @@ cdp._cleanCommentText.should.be.type("function"); | ||
cdp.isRuleEnabledOnLine.bind( | ||
cdp, r, 1).should.throw("Rule name should be a non-empty string string."); | ||
cdp, r, 1).should.throw("Rule name should be a non-empty string."); | ||
}); | ||
@@ -88,2 +93,16 @@ | ||
it("should throw when disable-previous-line is used on the first line", done => { | ||
const code = `// solium-disable-previous-line | ||
contract Foo {} | ||
`; | ||
const ast = solidityParser.parse(code, { comment: true }); | ||
shouldThrow( | ||
() => { new CommentDirectiveParser(ast.comments, ast); }, | ||
"Comment directive \"solium-disable-previous-line\" refers to an invalid line number." | ||
); | ||
done(); | ||
}); | ||
it("should work as expected when calling private utility functions", done => { | ||
@@ -116,3 +135,9 @@ const cdp = new CommentDirectiveParser(AST.comments, AST); | ||
["/* solium-disable-line pragma-on-top, indentation*/", " solium-disable-line pragma-on-top, indentation"], | ||
["/* solium-disable-line foorule*/", " solium-disable-line foorule"] | ||
["/* solium-disable-line foorule*/", " solium-disable-line foorule"], | ||
["// solium-disable-previous-line ", " solium-disable-previous-line "], | ||
["/* solium-disable-previous-line\t*/", " solium-disable-previous-line\t"], | ||
["/* solium-disable-previous-line security/no-throw, quotes */", " solium-disable-previous-line security/no-throw, quotes "], | ||
["// solium-enable ", " solium-enable "], | ||
["/* solium-enable\t*/", " solium-enable\t"], | ||
["/* solium-enable security/no-throw, quotes */", " solium-enable security/no-throw, quotes "] | ||
]; | ||
@@ -140,3 +165,7 @@ | ||
[" \tsolium-disable-line pragma-on-top,\t\tindentation", "pragma-on-top,indentation", "solium-disable-line"], | ||
[" \tsolium-disable-line foorule", "foorule", "solium-disable-line"] | ||
[" \tsolium-disable-line foorule", "foorule", "solium-disable-line"], | ||
["\t\tsolium-disable-previous-line \t ", "all", "solium-disable-previous-line"], | ||
[" solium-disable-previous-line security/no-throw, quotes \t ", "security/no-throw,quotes", "solium-disable-previous-line"], | ||
["\t\tsolium-enable \t ", "all", "solium-enable"], | ||
[" solium-enable security/no-throw, quotes \t ", "security/no-throw,quotes", "solium-enable"] | ||
]; | ||
@@ -143,0 +172,0 @@ |
@@ -97,35 +97,35 @@ /** | ||
rcObject.report.bind(rcObject, {}).should.throw(); | ||
rcObject.report.bind(rcObject, {message: 91072}).should.throw(); | ||
rcObject.report.bind(rcObject, {message: "hello", node: true}).should.throw(); | ||
rcObject.report.bind(rcObject, { message: 91072 }).should.throw(); | ||
rcObject.report.bind(rcObject, { message: "hello", node: true }).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, randomAttr: {}} | ||
{ message: "hello", node: sampleNode, randomAttr: {} } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, location: {randomAttr: 1908}} | ||
{ message: "hello", node: sampleNode, location: { randomAttr: 1908 } } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, location: {line: 90.1897}} | ||
{ message: "hello", node: sampleNode, location: { line: 90.1897 } } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, location: {column: null}} | ||
{ message: "hello", node: sampleNode, location: { column: null } } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, location: {line: 0}} | ||
{ message: "hello", node: sampleNode, location: { line: 0 } } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, location: {column: -1}} | ||
{ message: "hello", node: sampleNode, location: { column: -1 } } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, location: NaN} | ||
{ message: "hello", node: sampleNode, location: NaN } | ||
).should.throw(); | ||
rcObject.report.bind( | ||
rcObject, | ||
{message: "hello", node: sampleNode, fix: "this is a fix!!"} | ||
{ message: "hello", node: sampleNode, fix: "this is a fix!!" } | ||
).should.throw(); | ||
@@ -136,3 +136,3 @@ | ||
rcObject, | ||
{message: "hello", node: sampleNode} | ||
{ message: "hello", node: sampleNode } | ||
).should.not.throw(); | ||
@@ -162,3 +162,3 @@ | ||
rcObject.report({ | ||
node: {type: "TestNode", start: 0, end: 2}, | ||
node: { type: "TestNode", start: 0, end: 2 }, | ||
message: "test run" | ||
@@ -165,0 +165,0 @@ }); |
@@ -61,3 +61,3 @@ /** | ||
//specified rule is neither pre-defined nor custom | ||
rules.loadUsingDeprecatedConfigFormat.bind(rules, {"NON_EXISTANT_RULE_1": true}).should.throw(); | ||
rules.loadUsingDeprecatedConfigFormat.bind(rules, { "NON_EXISTANT_RULE_1": true }).should.throw(); | ||
@@ -149,3 +149,3 @@ done(); | ||
rules.getRuleSeverity.bind(rules, "arbitrary").should.throw(); | ||
rules.getRuleSeverity.bind(rules, {a: true, b: "c"}).should.throw(); | ||
rules.getRuleSeverity.bind(rules, { a: true, b: "c" }).should.throw(); | ||
rules.getRuleSeverity.bind(rules, []).should.throw(); | ||
@@ -186,3 +186,3 @@ rules.getRuleSeverity.bind(rules, [null]).should.throw(); | ||
"operator-whitespace": ["off", "double"], | ||
"lbrace": ["warning", 1, 2, {a: 100, h: "world"}], | ||
"lbrace": ["warning", 1, 2, { a: 100, h: "world" }], | ||
"mixedcase": ["error"], | ||
@@ -233,3 +233,3 @@ "camelcase": [0, 100, "hello", 9.283], | ||
"operator-whitespace": ["off", "double"], | ||
"lbrace": ["warning", 1, 2, {a: 100, h: "world"}], | ||
"lbrace": ["warning", 1, 2, { a: 100, h: "world" }], | ||
"mixedcase": ["error"], | ||
@@ -236,0 +236,0 @@ "camelcase": [0, 100, "hello", 9.283], |
@@ -339,3 +339,3 @@ /** | ||
const code = fs.readFileSync(path.join(__dirname, "./reject/contract.sol"), "utf8"); | ||
let {errorMessages: errors, fixedSourceCode} = Solium.lintAndFix(addPragma(code), userConfig); | ||
let { errorMessages: errors, fixedSourceCode } = Solium.lintAndFix(addPragma(code), userConfig); | ||
@@ -357,3 +357,3 @@ errors.constructor.name.should.equal("Array"); | ||
let code = fs.readFileSync(path.join(__dirname, "./reject/function.sol"), "utf8"), | ||
{errorMessages: errors, fixedSourceCode} = Solium.lintAndFix(addPragma(code), userConfig); | ||
{ errorMessages: errors, fixedSourceCode } = Solium.lintAndFix(addPragma(code), userConfig); | ||
@@ -468,3 +468,3 @@ errors.constructor.name.should.equal("Array"); | ||
snippets.forEach(code => { | ||
let {errorMessages: errors, fixedSourceCode} = Solium.lintAndFix(code, userConfig); | ||
let { errorMessages: errors, fixedSourceCode } = Solium.lintAndFix(code, userConfig); | ||
errors.should.be.Array(); | ||
@@ -471,0 +471,0 @@ errors.should.have.size(0); |
@@ -151,11 +151,11 @@ /** | ||
const testOptions = [ | ||
{ignore: {constructorFunc: false}}, | ||
{ignore: {fallbackFunc: false}}, | ||
{ignore: {functions: []}}, | ||
{ignore: {visibilities: []}}, | ||
{ignore: {constructorFunc: false, visibilities: [], functions: []}}, | ||
{ignore: {fallbackFunc: false, constructorFunc: false, visibilities: [], functions: []}}, | ||
{ignore: {visibilities: [], functions: []}}, | ||
{ignore: {constructorFunc: false, visibilities: []}}, | ||
{ignore: {constructorFunc: false, functions: []}} | ||
{ ignore: { constructorFunc: false } }, | ||
{ ignore: { fallbackFunc: false } }, | ||
{ ignore: { functions: [] } }, | ||
{ ignore: { visibilities: [] } }, | ||
{ ignore: { constructorFunc: false, visibilities: [], functions: [] } }, | ||
{ ignore: { fallbackFunc: false, constructorFunc: false, visibilities: [], functions: [] } }, | ||
{ ignore: { visibilities: [], functions: [] } }, | ||
{ ignore: { constructorFunc: false, visibilities: [] } }, | ||
{ ignore: { constructorFunc: false, functions: [] } } | ||
]; | ||
@@ -180,3 +180,3 @@ | ||
[ | ||
{constructorFunc: true}, | ||
{ constructorFunc: true }, | ||
` | ||
@@ -188,3 +188,3 @@ function() payable {} | ||
[ | ||
{fallbackFunc: true}, | ||
{ fallbackFunc: true }, | ||
` | ||
@@ -196,3 +196,3 @@ function myFunc(uint x, string bby) external; | ||
[ | ||
{functions: ["mySecondFunc"]}, | ||
{ functions: ["mySecondFunc"] }, | ||
` | ||
@@ -204,3 +204,3 @@ function myFunc(uint x, string bby) internal {} | ||
[ | ||
{visibilities: ["internal", "private"]}, | ||
{ visibilities: ["internal", "private"] }, | ||
` | ||
@@ -289,9 +289,9 @@ function dummy() private; | ||
{}, | ||
{ignore: {}}, | ||
{foobarbaz: {visibilities: []}}, | ||
{ignore: {foobar: []}}, | ||
{ignore: {constructorFunc: "hello", visibilities: [], functions: []}}, | ||
{ignore: {constructorFunc: false, visibilities: 18926, functions: []}}, | ||
{ignore: {constructorFunc: false, visibilities: [], functions: {}}}, | ||
{ignore: {fallbackFunc: null}} | ||
{ ignore: {} }, | ||
{ foobarbaz: { visibilities: [] } }, | ||
{ ignore: { foobar: [] } }, | ||
{ ignore: { constructorFunc: "hello", visibilities: [], functions: [] } }, | ||
{ ignore: { constructorFunc: false, visibilities: 18926, functions: [] } }, | ||
{ ignore: { constructorFunc: false, visibilities: [], functions: {} } }, | ||
{ ignore: { fallbackFunc: null } } | ||
]; | ||
@@ -298,0 +298,0 @@ |
@@ -591,3 +591,3 @@ /** | ||
let code = fs.readFileSync(path.join(__dirname, "./fixes/only-one-error.sol"), "utf8"); | ||
let {errorMessages: errors, fixedSourceCode} = Solium.lintAndFix(code, userConfig); | ||
let { errorMessages: errors, fixedSourceCode } = Solium.lintAndFix(code, userConfig); | ||
@@ -615,3 +615,3 @@ // All errors should've been corrected | ||
let code = fs.readFileSync(path.join(__dirname, "./fixes/before-pragma.sol"), "utf8"); | ||
let {errorMessages: errors, fixedSourceCode} = Solium.lintAndFix(code, userConfig); | ||
let { errorMessages: errors, fixedSourceCode } = Solium.lintAndFix(code, userConfig); | ||
@@ -636,3 +636,3 @@ // There should be no errors | ||
let code = fs.readFileSync(path.join(__dirname, "./fixes/only-one-error.sol"), "utf8"); | ||
let {errorMessages: errors, fixedSourceCode} = Solium.lintAndFix(code, userConfig); | ||
let { errorMessages: errors, fixedSourceCode } = Solium.lintAndFix(code, userConfig); | ||
@@ -639,0 +639,0 @@ // There should be no errors |
@@ -57,24 +57,20 @@ /** | ||
it("should ACCEPT all EMPTY function & constructor declarations (see fallback functions)", function(done) { | ||
let code = "function foo () {}", | ||
errors = Solium.lint(toContract(code), userConfig); | ||
it("should allow fallback and payable functions & payable constructors", done => { | ||
let snippets = [ | ||
"function(string address) {}", | ||
"function foo(string address) payable external {}", | ||
"function(string address) payable public {}", | ||
"constructor(uint x) payable {}", | ||
errors.constructor.name.should.equal("Array"); | ||
errors.length.should.equal(0); | ||
"function(string address) { /* hello world */ }", | ||
"function foo(string address) payable external {\t\t\t\t\t\n\n\t}", | ||
"function(string address) payable public { }", | ||
"constructor(uint x) payable { /* testing */ }" | ||
]; | ||
// new constructor syntax | ||
code = "constructor(uint x, string y, address z) {\n/*hello world*/\n}"; | ||
errors = Solium.lint(toContract(code), userConfig); | ||
snippets.forEach(code => { | ||
let errors = Solium.lint(toContract(code), userConfig); | ||
errors.should.be.empty(); | ||
}); | ||
errors.should.be.Array(); | ||
errors.should.be.empty(); | ||
// fallback func | ||
code = "function(){}"; | ||
errors = Solium.lint(toContract(code), userConfig); | ||
errors.should.be.Array(); | ||
errors.should.be.empty(); | ||
Solium.reset(); | ||
@@ -200,2 +196,24 @@ done(); | ||
it("should reject functions & constructors with empty bodies", done => { | ||
let snippets = [ | ||
"function foo(string address) {}", | ||
"function foo(string address) external {}", | ||
"constructor(uint x) {}", | ||
"constructor(uint x) public {}", | ||
"function foo(string address) { /* hello world */ }", | ||
"function foo(string address) external {\t\t\t\t\t\n\n\t}", | ||
"constructor(uint x) { }", | ||
"constructor(uint x) public { /* testing */ }" | ||
]; | ||
snippets.forEach(code => { | ||
let errors = Solium.lint(toContract(code), userConfig); | ||
errors.should.have.size(1); | ||
}); | ||
Solium.reset(); | ||
done(); | ||
}); | ||
}); |
@@ -125,3 +125,3 @@ /** | ||
fixed.fixesApplied.should.be.Array(); | ||
fixed.fixesApplied.length.should.equal(11); | ||
fixed.fixesApplied.length.should.equal(17); | ||
@@ -193,3 +193,3 @@ Solium.reset(); | ||
fixed.fixesApplied.should.be.Array(); | ||
fixed.fixesApplied.length.should.equal(11); | ||
fixed.fixesApplied.length.should.equal(17); | ||
@@ -196,0 +196,0 @@ Solium.reset(); |
@@ -34,3 +34,13 @@ /** | ||
"string constant HELLO_98_NUMBER = \"number\";", | ||
"address constant H0 = 0x1;" | ||
"address constant H0 = 0x1;", | ||
"string constant _F = \"dd\";", | ||
"string constant D_ = \"dd\";", | ||
"string constant __F = \"dd\";", | ||
"string constant D__ = \"dd\";", | ||
"string constant __F__ = \"dd\";", | ||
"string constant _F00BAR = \"dd\";", | ||
"string constant D9HG8_ = \"dd\";", | ||
"string constant __FJO8 = \"dd\";", | ||
"string constant D891JK9__ = \"dd\";", | ||
"string constant __F9018SJ__ = \"dd\";" | ||
]; | ||
@@ -64,4 +74,8 @@ let errors; | ||
"string constant _ = \"dd\";", | ||
"string constant D_ = \"dd\";", | ||
"string constant _F = \"dd\";" | ||
"string constant ___F = \"dd\";", | ||
"string constant D___ = \"dd\";", | ||
"string constant ___F___ = \"dd\";", | ||
"string constant ___F00BAR = \"dd\";", | ||
"string constant D9HG8___ = \"dd\";", | ||
"string constant ___F9018SJ___ = \"dd\";" | ||
]; | ||
@@ -68,0 +82,0 @@ let errors; |
@@ -115,3 +115,3 @@ /** | ||
ian({type: "TestNode", start: 0, end: 10}).should.equal(true); | ||
ian({ type: "TestNode", start: 0, end: 10 }).should.equal(true); | ||
@@ -125,3 +125,3 @@ done(); | ||
start: 0, end: 190, | ||
parent: {type: "TestParentNode", start: 21, end: 981} | ||
parent: { type: "TestParentNode", start: 21, end: 981 } | ||
}; | ||
@@ -339,4 +339,4 @@ | ||
it("should behave correctly when calling isAChildOf()", done => { | ||
const child = {type: "Blah", start: 10, end: 20}, | ||
parent = {type: "Blah", start: 0, end: 30}, notChild = {type: "Blah", start: 45, end: 80}; | ||
const child = { type: "Blah", start: 10, end: 20 }, | ||
parent = { type: "Blah", start: 0, end: 30 }, notChild = { type: "Blah", start: 45, end: 80 }; | ||
@@ -353,4 +353,4 @@ astUtils.isAChildOf(child, parent).should.be.true(); | ||
it("should reject invalid nodes when calling isAChildOf()", done => { | ||
const validNode = {type: "Blah", start: 10, end: 20}, | ||
invalidNode = {start: 10, end: 20}; | ||
const validNode = { type: "Blah", start: 10, end: 20 }, | ||
invalidNode = { start: 10, end: 20 }; | ||
@@ -357,0 +357,0 @@ astUtils.isAChildOf.bind(astUtils).should.throw(); |
@@ -45,11 +45,11 @@ /** | ||
configInspector.isValid({ extends: [] }).should.equal(false); | ||
configInspector.isValid({ rules: {a: []} }).should.equal(false); | ||
configInspector.isValid({ extends: "lola", options: {randomAttr: true} }).should.equal(false); | ||
configInspector.isValid({ extends: "lola", rules: {}, options: {randomAttr: true} }).should.equal(false); | ||
configInspector.isValid({ rules: { a: [] } }).should.equal(false); | ||
configInspector.isValid({ extends: "lola", options: { randomAttr: true } }).should.equal(false); | ||
configInspector.isValid({ extends: "lola", rules: {}, options: { randomAttr: true } }).should.equal(false); | ||
configInspector.isValid({ rules: {}, randomAttr: {} }).should.equal(false); | ||
configInspector.isValid({ rules: {a: 1}, options: {randomAttr: true} }).should.equal(false); | ||
configInspector.isValid({ rules: {a: 1}, options: {returnInternalIssues: "hello world"} }).should.equal(false); | ||
configInspector.isValid({ rules: {}, options: {randomAttr: true} }).should.equal(false); | ||
configInspector.isValid({ rules: { a: 1 }, options: { randomAttr: true } }).should.equal(false); | ||
configInspector.isValid({ rules: { a: 1 }, options: { returnInternalIssues: "hello world" } }).should.equal(false); | ||
configInspector.isValid({ rules: {}, options: { randomAttr: true } }).should.equal(false); | ||
configInspector.isValid({ rules: {}, randomAttr: {} }).should.equal(false); | ||
configInspector.isValid({ rules: {}, options: {returnInternalIssues: "hello"} }).should.equal(false); | ||
configInspector.isValid({ rules: {}, options: { returnInternalIssues: "hello" } }).should.equal(false); | ||
@@ -61,3 +61,3 @@ configInspector.isValid({ plugins: [""], rules: {} }).should.equal(false); | ||
configInspector.isValid({ plugins: {}, rules: {} }).should.equal(false); | ||
configInspector.isValid({ plugins: {a: "b"}, rules: {} }).should.equal(false); | ||
configInspector.isValid({ plugins: { a: "b" }, rules: {} }).should.equal(false); | ||
configInspector.isValid({ plugins: "myplugin", rules: {} }).should.equal(false); | ||
@@ -69,3 +69,3 @@ configInspector.isValid({ plugins: [""], extends: "a" }).should.equal(false); | ||
configInspector.isValid({ plugins: {}, extends: "a" }).should.equal(false); | ||
configInspector.isValid({ plugins: {a: "b"}, extends: "a" }).should.equal(false); | ||
configInspector.isValid({ plugins: { a: "b" }, extends: "a" }).should.equal(false); | ||
configInspector.isValid({ plugins: "myplugin", extends: "a" }).should.equal(false); | ||
@@ -85,12 +85,12 @@ configInspector.isValid({ plugins: "myplugin" }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": [] }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": 89172, rules: {a: true} }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": 89172, rules: { a: true } }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": {} }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": true }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "" }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "lola", options: {auto: true} }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "lola", options: {autofix: "hello"} }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "lola", options: { auto: true } }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "lola", options: { autofix: "hello" } }).should.equal(false); | ||
configInspector.isValid({ | ||
"custom-rules-filename": "lola", | ||
options: {autofix: true, returnInternalIssues: "hello"} | ||
options: { autofix: true, returnInternalIssues: "hello" } | ||
}).should.equal(false); | ||
@@ -100,3 +100,3 @@ | ||
"custom-rules-filename": "lola", | ||
options: {autofix: true, returnInternalIssue: false} | ||
options: { autofix: true, returnInternalIssue: false } | ||
}).should.equal(false); | ||
@@ -106,4 +106,4 @@ | ||
configInspector.isValid({ "custom-rules-filename": "iuyu", extends: "sss" }).should.equal(false); | ||
configInspector.isValid({ extends: "sss", rules: {a: true} }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "goaka", rules: {a: 1} }).should.equal(false); | ||
configInspector.isValid({ extends: "sss", rules: { a: true } }).should.equal(false); | ||
configInspector.isValid({ "custom-rules-filename": "goaka", rules: { a: 1 } }).should.equal(false); | ||
@@ -114,12 +114,12 @@ done(); | ||
it("isValid() should correctly classify valid config objects", function(done) { | ||
configInspector.isValid({ rules: {a: [1]} }).should.equal(true); | ||
configInspector.isValid({ rules: { a: [1] } }).should.equal(true); | ||
configInspector.isValid({ extends: "blahblah" }).should.equal(true); | ||
configInspector.isValid({ rules: {a: [1]}, extends: "blahblah" }).should.equal(true); | ||
configInspector.isValid({ rules: { a: [1] }, extends: "blahblah" }).should.equal(true); | ||
configInspector.isValid({ rules: {} }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: {} }).should.equal(true); | ||
configInspector.isValid({ rules: {}, extends: "lola", options: {} }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: {autofix: true} }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: {returnInternalIssues: true} }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: {autofix: false, returnInternalIssues: true} }).should.equal(true); | ||
configInspector.isValid({ rules: {a: 1}, options: {autofix: false, returnInternalIssues: true} }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: { autofix: true } }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: { returnInternalIssues: true } }).should.equal(true); | ||
configInspector.isValid({ rules: {}, options: { autofix: false, returnInternalIssues: true } }).should.equal(true); | ||
configInspector.isValid({ rules: { a: 1 }, options: { autofix: false, returnInternalIssues: true } }).should.equal(true); | ||
@@ -136,12 +136,12 @@ configInspector.isValid({ extends: "ab", plugins: [] }).should.equal(true); | ||
// Deprecated | ||
configInspector.isValid({ rules: {a: true} }).should.equal(true); | ||
configInspector.isValid({ rules: {a: false, b: false, c: true} }).should.equal(true); | ||
configInspector.isValid({ "custom-rules-filename": "koala", rules: {a: false} }).should.equal(true); | ||
configInspector.isValid({ "custom-rules-filename": null, rules: {a: true} }).should.equal(true); | ||
configInspector.isValid({ rules: { a: true } }).should.equal(true); | ||
configInspector.isValid({ rules: { a: false, b: false, c: true } }).should.equal(true); | ||
configInspector.isValid({ "custom-rules-filename": "koala", rules: { a: false } }).should.equal(true); | ||
configInspector.isValid({ "custom-rules-filename": null, rules: { a: true } }).should.equal(true); | ||
configInspector.isValid({ "custom-rules-filename": null, rules: {} }).should.equal(true); | ||
configInspector.isValid({ plugins: ["standard"] }).should.equal(true); | ||
configInspector.isValid({ plugins: ["s"], rules: {"s/foo": 1} }).should.equal(true); | ||
configInspector.isValid({ plugins: ["s"], rules: { "s/foo": 1 } }).should.equal(true); | ||
configInspector.isValid({ plugins: ["s"], extends: "blah" }).should.equal(true); | ||
configInspector.isValid({ plugins: ["s"], rules: {"s/foo": 1}, extends: "blah" }).should.equal(true); | ||
configInspector.isValid({ plugins: ["s"], rules: { "s/foo": 1 }, extends: "blah" }).should.equal(true); | ||
@@ -152,13 +152,13 @@ done(); | ||
it("isFormatDeprecated() should correctly classify a deprecated config format", function(done) { | ||
configInspector.isFormatDeprecated({ rules: {a: true} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: {a: false} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: {a: false, b: true, c: true} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: {a: false}, options: {} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: {a: true}, options: {autofix: true} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: { a: true } }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: { a: false } }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: { a: false, b: true, c: true } }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: { a: false }, options: {} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ rules: { a: true }, options: { autofix: true } }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": "koala" }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": "koala", rules: {} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": "koala", rules: {a: true} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": "koala", rules: { a: true } }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": null }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": null, rules: {a: true} }).should.equal(true); | ||
configInspector.isFormatDeprecated({ "custom-rules-filename": null, rules: { a: true } }).should.equal(true); | ||
@@ -171,3 +171,3 @@ done(); | ||
configInspector.isFormatDeprecated({ rules: {}, options: {} }).should.equal(false); | ||
configInspector.isFormatDeprecated({ rules: {}, options: {autofix: true} }).should.equal(false); | ||
configInspector.isFormatDeprecated({ rules: {}, options: { autofix: true } }).should.equal(false); | ||
configInspector.isFormatDeprecated({ extends: "helloworld" }).should.equal(false); | ||
@@ -188,7 +188,7 @@ configInspector.isFormatDeprecated({ rules: {}, extends: "jon-snow" }).should.equal(false); | ||
it("isAValidSharableConfig() should correctly classify a valid sharable config", function(done) { | ||
configInspector.isAValidSharableConfig({rules: {}}).should.equal(true); | ||
configInspector.isAValidSharableConfig({rules: {quotes: [1]}}).should.equal(true); | ||
configInspector.isAValidSharableConfig({rules: {quotes: [1]}}).should.equal(true); | ||
configInspector.isAValidSharableConfig({rules: {quotes: 1}}).should.equal(true); | ||
configInspector.isAValidSharableConfig({rules: {quotes: "error"}}).should.equal(true); | ||
configInspector.isAValidSharableConfig({ rules: {} }).should.equal(true); | ||
configInspector.isAValidSharableConfig({ rules: { quotes: [1] } }).should.equal(true); | ||
configInspector.isAValidSharableConfig({ rules: { quotes: [1] } }).should.equal(true); | ||
configInspector.isAValidSharableConfig({ rules: { quotes: 1 } }).should.equal(true); | ||
configInspector.isAValidSharableConfig({ rules: { quotes: "error" } }).should.equal(true); | ||
@@ -195,0 +195,0 @@ done(); |
@@ -71,3 +71,3 @@ /** | ||
{ type: "string", minLength: 5 }, | ||
{ type: "object", properties: {modifies: {type: "boolean"}} }, | ||
{ type: "object", properties: { modifies: { type: "boolean" } } }, | ||
{ type: "integer", minimum: 0, maximum: 69 } | ||
@@ -221,3 +221,3 @@ ] | ||
}, | ||
"schema": [{"type": "object"}, "think again"], | ||
"schema": [{ "type": "object" }, "think again"], | ||
"fixable": "code" | ||
@@ -315,3 +315,3 @@ }, | ||
"type": "error", | ||
"description": {"cutie": 3.142} | ||
"description": { "cutie": 3.142 } | ||
}, | ||
@@ -495,9 +495,9 @@ "schema": [], | ||
let listItemsSchema = [ | ||
{type: "string", minLength: 3}, | ||
{type: "integer", minimum: 0, maximum: 10}, | ||
{type: "object", properties: { name: {type: "string", minLength: 1} }, additionalProperties: false} | ||
{ type: "string", minLength: 3 }, | ||
{ type: "integer", minimum: 0, maximum: 10 }, | ||
{ type: "object", properties: { name: { type: "string", minLength: 1 } }, additionalProperties: false } | ||
]; | ||
it("should correctly classify when a rule is provided a valid set of options", function(done) { | ||
ruleInspector.areValidOptionsPassed(["hello", 5, {name: "chuck norris"}], listItemsSchema).should.equal(true); | ||
ruleInspector.areValidOptionsPassed(["hello", 5, { name: "chuck norris" }], listItemsSchema).should.equal(true); | ||
done(); | ||
@@ -509,10 +509,10 @@ }); | ||
null, undefined, "", {}, 100, -9, 89.23, 0, function() {}, NaN, | ||
["", 5, {name: "chuck norris"}], | ||
["hello", -189, {name: "chuck norris"}], | ||
["", 5, {name: ""}], | ||
["", 5, { name: "chuck norris" }], | ||
["hello", -189, { name: "chuck norris" }], | ||
["", 5, { name: "" }], | ||
[], | ||
["hello"], | ||
["hell", 9], | ||
[9, {name: "chuck norris"}], | ||
["sss", {name: "chuck norris"}] | ||
[9, { name: "chuck norris" }], | ||
["sss", { name: "chuck norris" }] | ||
]; | ||
@@ -519,0 +519,0 @@ |
@@ -65,3 +65,3 @@ /** | ||
ruleLoader.resolveUpstream.bind(ruleLoader, {}).should.throw(); | ||
ruleLoader.resolveUpstream.bind(ruleLoader, {a: 11}).should.throw(); | ||
ruleLoader.resolveUpstream.bind(ruleLoader, { a: 11 }).should.throw(); | ||
ruleLoader.resolveUpstream.bind(ruleLoader, true).should.throw(); | ||
@@ -68,0 +68,0 @@ ruleLoader.resolveUpstream.bind(ruleLoader, false).should.throw(); |
@@ -138,3 +138,3 @@ /** | ||
(sourceCodeObject.getNextChar( | ||
{type: "LastNode", end: sourceCodeText.length, start: 2} | ||
{ type: "LastNode", end: sourceCodeText.length, start: 2 } | ||
) === null).should.equal(true); | ||
@@ -144,3 +144,3 @@ | ||
(sourceCodeObject.getNextChar( | ||
{type: "LastNode", end: 100000, start: 90} | ||
{ type: "LastNode", end: 100000, start: 90 } | ||
) === null).should.equal(true); | ||
@@ -159,3 +159,3 @@ | ||
(sourceCodeObject.getPrevChar( | ||
{type: "FirstNode", start: 0, end: 90} | ||
{ type: "FirstNode", start: 0, end: 90 } | ||
) === null).should.equal(true); | ||
@@ -162,0 +162,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
940427
191
16343
117