-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af1c996
commit 3321154
Showing
11 changed files
with
321 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "solhint:all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.6.0; | ||
|
||
contract Foo { | ||
uint256 public constant test1 = 1; | ||
uint256 TEST2; | ||
|
||
constructor() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.5.8; | ||
|
||
contract Foo { | ||
uint256 public constant test1 = 1; | ||
|
||
constructor() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
const getFormatter = (formatter) => { | ||
try { | ||
return require(`../../../lib/formatters/${formatter}`) | ||
} catch (ex) { | ||
ex.message = `\nThere was a problem loading formatter option: ${formatter} \nError: ${ex.message}` | ||
throw ex | ||
} | ||
} | ||
/* | ||
const foo1Messages = [ | ||
{ | ||
line: 2, | ||
column: 1, | ||
severity: 2, | ||
message: 'Compiler version >=0.6.0 does not satisfy the ^0.5.8 semver requirement', | ||
ruleId: 'compiler-version', | ||
fix: null, | ||
}, | ||
{ | ||
line: 5, | ||
column: 5, | ||
severity: 3, | ||
message: 'Constant name must be in capitalized SNAKE_CASE', | ||
ruleId: 'const-name-snakecase', | ||
fix: null, | ||
}, | ||
{ | ||
line: 6, | ||
column: 5, | ||
severity: 3, | ||
message: 'Explicitly mark visibility of state', | ||
ruleId: 'state-visibility', | ||
fix: null, | ||
}, | ||
{ | ||
line: 6, | ||
column: 5, | ||
severity: 3, | ||
message: "'TEST2' should start with _", | ||
ruleId: 'private-vars-leading-underscore', | ||
fix: null, | ||
}, | ||
{ | ||
line: 6, | ||
column: 5, | ||
severity: 3, | ||
message: 'Variable name must be in mixedCase', | ||
ruleId: 'var-name-mixedcase', | ||
fix: null, | ||
}, | ||
{ | ||
line: 8, | ||
column: 5, | ||
severity: 3, | ||
message: | ||
'Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0)', | ||
ruleId: 'func-visibility', | ||
fix: null, | ||
}, | ||
{ | ||
line: 8, | ||
column: 19, | ||
severity: 3, | ||
message: 'Code contains empty blocks', | ||
ruleId: 'no-empty-blocks', | ||
fix: null, | ||
}, | ||
] | ||
const foo1ExpectedOutput = [ | ||
{ | ||
messages: foo1Messages, | ||
filePath: 'e2e/06-formatters/contracts/Foo.sol', | ||
}, | ||
] | ||
const foo2Messages = [ | ||
{ | ||
line: 5, | ||
column: 5, | ||
severity: 3, | ||
message: 'Constant name must be in capitalized SNAKE_CASE', | ||
ruleId: 'const-name-snakecase', | ||
fix: null, | ||
}, | ||
{ | ||
line: 7, | ||
column: 5, | ||
severity: 3, | ||
message: | ||
'Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0)', | ||
ruleId: 'func-visibility', | ||
fix: null, | ||
}, | ||
{ | ||
line: 7, | ||
column: 19, | ||
severity: 3, | ||
message: 'Code contains empty blocks', | ||
ruleId: 'no-empty-blocks', | ||
fix: null, | ||
}, | ||
] | ||
const foo2Output = [ | ||
{ | ||
messages: foo2Messages, | ||
filePath: 'e2e/06-formatters/contracts/Foo2.sol', | ||
}, | ||
] | ||
*/ | ||
|
||
const foo1UnixExpectedOutput = `contracts/Foo2.sol:5:5: Constant name must be in capitalized SNAKE_CASE [Warning/const-name-snakecase] | ||
contracts/Foo2.sol:7:5: Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0) [Warning/func-visibility] | ||
contracts/Foo2.sol:7:19: Code contains empty blocks [Warning/no-empty-blocks] | ||
3 problems` | ||
|
||
const foo1JsonExpectedOutput = `contracts/Foo2.sol:5:5: Constant name must be in capitalized SNAKE_CASE [Warning/const-name-snakecase] | ||
contracts/Foo2.sol:7:5: Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0) [Warning/func-visibility] | ||
contracts/Foo2.sol:7:19: Code contains empty blocks [Warning/no-empty-blocks] | ||
3 problems` | ||
|
||
|
||
module.exports = { getFormatter, foo1UnixExpectedOutput, foo1JsonExpectedOutput } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
files in this directory are pulled from eslint repository: | ||
|
||
- table.js: eslint v5.6.0 Gajus Kuizinas <[email protected]> | ||
- unix.js: eslint v8.32.0 oshi-shinobu | ||
- tap.js: eslint v8.32.0 Jonathan Kingston | ||
- stylish.js: eslint v8.32.0 by Sindre Sorhus | ||
- json.js: eslint v8.32.0 by Artur Lukianov & Diego Bale | ||
- table.js: eslint - Gajus Kuizinas | ||
- unix.js: eslint - oshi-shinobu | ||
- tap.js: eslint - Jonathan Kingston | ||
- stylish.js: eslint - Sindre Sorhus | ||
- json.js: eslint - Artur Lukianov & Diego Bale | ||
- compact.js: eslint - Nicholas C. Zakas | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @fileoverview Compact reporter | ||
* @author Nicholas C. Zakas | ||
*/ | ||
|
||
//------------------------------------------------------------------------------ | ||
// Helper Functions | ||
//------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Returns the severity of warning or error | ||
* @param {Object} message message object to examine | ||
* @returns {string} severity level | ||
* @private | ||
*/ | ||
function getMessageType(message) { | ||
if (message.fatal || message.severity === 2) { | ||
return 'Error' | ||
} | ||
return 'Warning' | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
// eslint-disable-next-line func-names | ||
module.exports = function (results) { | ||
let output = '' | ||
let total = 0 | ||
|
||
results.forEach((result) => { | ||
const messages = result.messages | ||
|
||
total += messages.length | ||
|
||
messages.forEach((message) => { | ||
output += `${result.filePath}: ` | ||
output += `line ${message.line || 0}` | ||
output += `, col ${message.column || 0}` | ||
output += `, ${getMessageType(message)}` | ||
output += ` - ${message.message}` | ||
output += message.ruleId ? ` (${message.ruleId})` : '' | ||
output += '\n' | ||
}) | ||
}) | ||
|
||
if (total > 0) { | ||
output += `\n${total} problem${total !== 1 ? 's' : ''}` | ||
} | ||
|
||
return output | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.