-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Upgrade ESLint and fix lint errors
- Loading branch information
Showing
15 changed files
with
1,257 additions
and
1,759 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,69 +1,69 @@ | ||
/** | ||
* Tries to detect buffer read / write calls that use noAssert set to true | ||
* @author Adam Baldwin | ||
* @author Adam Baldwin | ||
*/ | ||
|
||
'use strict'; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Rule Definition | ||
//------------------------------------------------------------------------------ | ||
|
||
var names = []; | ||
const names = []; | ||
|
||
module.exports = function(context) { | ||
|
||
"use strict"; | ||
const read = [ | ||
'readUInt8', | ||
'readUInt16LE', | ||
'readUInt16BE', | ||
'readUInt32LE', | ||
'readUInt32BE', | ||
'readInt8', | ||
'readInt16LE', | ||
'readInt16BE', | ||
'readInt32LE', | ||
'readInt32BE', | ||
'readFloatLE', | ||
'readFloatBE', | ||
'readDoubleL', | ||
'readDoubleBE' | ||
]; | ||
|
||
var read = [ | ||
"readUInt8", | ||
"readUInt16LE", | ||
"readUInt16BE", | ||
"readUInt32LE", | ||
"readUInt32BE", | ||
"readInt8", | ||
"readInt16LE", | ||
"readInt16BE", | ||
"readInt32LE", | ||
"readInt32BE", | ||
"readFloatLE", | ||
"readFloatBE", | ||
"readDoubleL", | ||
"readDoubleBE" | ||
]; | ||
const write = [ | ||
'writeUInt8', | ||
'writeUInt16LE', | ||
'writeUInt16BE', | ||
'writeUInt32LE', | ||
'writeUInt32BE', | ||
'writeInt8', | ||
'writeInt16LE', | ||
'writeInt16BE', | ||
'writeInt32LE', | ||
'writeInt32BE', | ||
'writeFloatLE', | ||
'writeFloatBE', | ||
'writeDoubleLE', | ||
'writeDoubleBE' | ||
]; | ||
|
||
var write = [ | ||
"writeUInt8", | ||
"writeUInt16LE", | ||
"writeUInt16BE", | ||
"writeUInt32LE", | ||
"writeUInt32BE", | ||
"writeInt8", | ||
"writeInt16LE", | ||
"writeInt16BE", | ||
"writeInt32LE", | ||
"writeInt32BE", | ||
"writeFloatLE", | ||
"writeFloatBE", | ||
"writeDoubleLE", | ||
"writeDoubleBE" | ||
]; | ||
return { | ||
'MemberExpression': function (node) { | ||
let index; | ||
if (read.indexOf(node.property.name) !== -1) { | ||
index = 1; | ||
} | ||
else if (write.indexOf(node.property.name) !== -1) { | ||
index = 2; | ||
} | ||
|
||
return { | ||
"MemberExpression": function (node) { | ||
var index; | ||
if (read.indexOf(node.property.name) !== -1) { | ||
index = 1; | ||
} else if (write.indexOf(node.property.name) !== -1) { | ||
index = 2; | ||
} | ||
if (index && node.parent && node.parent.arguments && node.parent.arguments[index] && node.parent.arguments[index].value) { | ||
const token = context.getTokens(node)[0]; | ||
return context.report(node, `Found Buffer.${ node.property.name } with noAssert flag set true`); | ||
|
||
if (index && node.parent && node.parent.arguments && node.parent.arguments[index] && node.parent.arguments[index].value) { | ||
var token = context.getTokens(node)[0]; | ||
return context.report(node, 'Found Buffer.' + node.property.name + ' with noAssert flag set true'); | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
}; | ||
}; | ||
|
||
}; | ||
|
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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
|
||
'use strict'; | ||
|
||
module.exports = function(context) { | ||
|
||
"use strict"; | ||
return { | ||
"AssignmentExpression": function(node) { | ||
if (node.operator === '=') { | ||
if (node.left.property) { | ||
if (node.left.property.name == 'escapeMarkup') { | ||
if (node.right.value == false) { | ||
context.report(node, 'Markup escaping disabled.') | ||
} | ||
} | ||
} | ||
return { | ||
'AssignmentExpression': function(node) { | ||
if (node.operator === '=') { | ||
if (node.left.property) { | ||
if (node.left.property.name === 'escapeMarkup') { | ||
if (node.right.value === false) { | ||
context.report(node, 'Markup escaping disabled.'); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
} | ||
}; |
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 |
---|---|---|
@@ -1,19 +1,21 @@ | ||
'use strict'; | ||
|
||
|
||
module.exports = function (context) { | ||
// Detects instances of new Buffer(argument) | ||
// where argument is any non literal value. | ||
return { | ||
"NewExpression": function (node) { | ||
if (node.callee.name === 'Buffer' && | ||
// Detects instances of new Buffer(argument) | ||
// where argument is any non literal value. | ||
return { | ||
'NewExpression': function (node) { | ||
if (node.callee.name === 'Buffer' && | ||
node.arguments[0] && | ||
node.arguments[0].type != 'Literal') { | ||
|
||
return context.report(node, "Found new Buffer"); | ||
} | ||
node.arguments[0].type !== 'Literal') { | ||
|
||
return context.report(node, 'Found new Buffer'); | ||
} | ||
|
||
|
||
} | ||
}; | ||
|
||
} | ||
} | ||
}; | ||
|
||
}; |
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.