-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refine rules using selector syntax. Fix edge cases
- Loading branch information
Showing
16 changed files
with
94 additions
and
199 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
FunctionDeclaration(node) { | ||
if (node.async && node.generator) { | ||
context.report( | ||
node, | ||
`Async Generators are not supported in ${badBrowser}` | ||
) | ||
} | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
':function[async=true][generator=true]'(node) { | ||
context.report(node, `Async Generators are not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,14 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
ForOfStatement(node) { | ||
if (node.await) { | ||
context.report( | ||
node, | ||
`Async Iteration is not supported in ${badBrowser}` | ||
) | ||
} | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
'ForOfStatement[await=true]'(node) { | ||
context.report(node, `Async Iteration is not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,12 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
BindExpression(node) { | ||
context.report( | ||
node, | ||
`The Bind Operator is not supported in ${badBrowser}` | ||
) | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
BindExpression(node) { | ||
context.report(node, `The Bind Operator is not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,12 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
DoExpression(node) { | ||
context.report( | ||
node, | ||
`Do Expressions are not supported in ${badBrowser}` | ||
) | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
DoExpression(node) { | ||
context.report(node, `Do Expressions are not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,14 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
BinaryExpression(node) { | ||
if (node.operator === '**') { | ||
context.report( | ||
node, | ||
`Exponentiation Operator is not supported in ${badBrowser}` | ||
) | ||
} | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
'AssignmentExpression[operator="**="], BinaryExpression[operator="**"]'(node) { | ||
context.report(node, `Exponentiation Operator is not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,15 +1,5 @@ | ||
const hasSeparator = RegExp.prototype.test.bind(/^\d+(?:_\d+)+\d*$/) | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
Literal(node) { | ||
if (typeof node.value === 'number' && hasSeparator(node.raw)) { | ||
context.report( | ||
node, | ||
`Numeric Separators are not supported in ${badBrowser}` | ||
) | ||
} | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
'Literal[raw=/_/][value>=0], Literal[raw=/_/][value<=0]'(node) { | ||
context.report(node, `Numeric Separators are not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,34 +1,16 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
SpreadElement(node) { | ||
if (!node.parent || node.parent.type !== 'ObjectExpression') return | ||
context.report( | ||
node, | ||
`Object Rest/Spread is not supported in ${badBrowser}` | ||
) | ||
}, | ||
RestElement(node) { | ||
if (!node.parent || node.parent.type !== 'ObjectPattern') return | ||
context.report( | ||
node, | ||
`Object Rest/Spread is not supported in ${badBrowser}` | ||
) | ||
}, | ||
module.exports = (context, badBrowser) => ({ | ||
'ObjectExpression > SpreadElement'(node) { | ||
context.report(node, `Object Rest/Spread is not supported in ${badBrowser}`) | ||
}, | ||
'ObjectPattern > RestElement'(node) { | ||
context.report(node, `Object Rest/Spread is not supported in ${badBrowser}`) | ||
}, | ||
|
||
// Catch older versions of eslint and babel-eslint | ||
ExperimentalRestProperty(node) { | ||
context.report( | ||
node, | ||
`Object Rest/Spread is not supported in ${badBrowser}` | ||
) | ||
}, | ||
ExperimentalSpreadProperty(node) { | ||
context.report( | ||
node, | ||
`Object Rest/Spread is not supported in ${badBrowser}` | ||
) | ||
}, | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
// Catch older versions of eslint and babel-eslint | ||
ExperimentalRestProperty(node) { | ||
context.report(node, `Object Rest/Spread is not supported in ${badBrowser}`) | ||
}, | ||
ExperimentalSpreadProperty(node) { | ||
context.report(node, `Object Rest/Spread is not supported in ${badBrowser}`) | ||
}, | ||
}) |
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,14 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
CatchClause(node) { | ||
if (!node.param) { | ||
context.report( | ||
node, | ||
`Optional Catch Parameters are not supported in ${badBrowser}` | ||
) | ||
} | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
'CatchClause:not([param])'(node) { | ||
context.report(node, `Optional Catch Parameters are not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,12 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
OptionalMemberExpression(node) { | ||
context.report( | ||
node, | ||
`Optional Chaining is not supported in ${badBrowser}` | ||
) | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
OptionalMemberExpression(node) { | ||
context.report(node, `Optional Chaining is not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,14 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
BinaryExpression(node) { | ||
if (node.operator === '|>') { | ||
context.report( | ||
node, | ||
`The Pipeline Operator is not supported in ${badBrowser}` | ||
) | ||
} | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
'BinaryExpression[operator="|>"]'(node) { | ||
context.report(node, `The Pipeline Operator is not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,12 +1,5 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
ClassPrivateProperty(node) { | ||
context.report( | ||
node, | ||
`Private Class Fields are not supported in ${badBrowser}` | ||
) | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
ClassPrivateProperty(node) { | ||
context.report(node, `Private Class Fields are not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,14 +1,6 @@ | ||
module.exports = function(context, badBrowser) { | ||
return { | ||
ClassProperty(node) { | ||
// Ignore type annotations that don't assign | ||
if (node.typeAnnotation && !node.value) return | ||
context.report( | ||
node, | ||
`Class Fields are not supported in ${badBrowser}` | ||
) | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
// Ignore type annotations that don't assign | ||
'ClassProperty:not([typeAnnotation]:not([value]))'(node) { | ||
context.report(node, `Class Fields are not supported in ${badBrowser}`) | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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,32 +1,12 @@ | ||
const getRegExpFlags = node => { | ||
if (node.regex) { | ||
return node.regex.flags; | ||
} | ||
if (typeof node.value === "string" && | ||
(node.parent.type === "NewExpression" || node.parent.type === "CallExpression") && | ||
node.parent.callee.type === "Identifier" && | ||
node.parent.callee.name === "RegExp" && | ||
node.parent.arguments[1] === node | ||
) { | ||
return node.value; | ||
} | ||
return null; | ||
} | ||
|
||
|
||
module.exports = function(context, badBrowser) { | ||
return { | ||
Literal(node) { | ||
const flags = getRegExpFlags(node) | ||
if (!flags) return | ||
if (flags.indexOf('s') !== -1) { | ||
context.report( | ||
node, | ||
`RegExp "s" flag is not supported in ${badBrowser}` | ||
) | ||
} | ||
module.exports = (context, badBrowser) => ({ | ||
'Literal[regex]'(node) { | ||
if (node.regex.flags.includes('s')) { | ||
context.report(node, `RegExp "s" flag is not supported in ${badBrowser}`) | ||
} | ||
}, | ||
'CallExpression[callee.name="RegExp"], NewExpression[callee.name="RegExp"]'(node) { | ||
if (node.arguments[1] && node.arguments[1].value.includes('s')) { | ||
context.report(node, `RegExp "s" flag is not supported in ${badBrowser}`) | ||
} | ||
} | ||
} | ||
|
||
module.exports.schema = [] | ||
}) |
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