This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow accessor properties.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-accessor-properties.html",
},
fixable: null,
messages: {
forbidden: "ES5 accessor properties are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Property[kind='get'], Property[kind='set'], MethodDefinition[kind='get'], MethodDefinition[kind='set']"(
node
) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Array.from` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-array-from.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Array: {
from: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Array.isArray` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-array-isarray.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Array: {
isArray: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Array.of` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-array-of.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Array: {
of: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+129
View File
@@ -0,0 +1,129 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { isArrowToken, isParenthesized } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow arrow function expressions.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-arrow-functions.html",
},
fixable: "code",
messages: {
forbidden: "ES2015 arrow function expressions are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
/**
* ArrowFunctionExpression to FunctionExpression
* @param {Node} node ArrowFunctionExpression Node
* @param {boolean} hasThis `true` if the function has `this`.
* @returns {string} function expression text
*/
function toFunctionExpression(node, hasThis) {
const params = node.params
const paramText = params.length
? sourceCode.text.slice(
params[0].range[0],
params[params.length - 1].range[1]
)
: ""
const arrowToken = sourceCode.getTokenBefore(
node.body,
isArrowToken
)
const preText = sourceCode.text.slice(
arrowToken.range[1],
node.body.range[0]
)
const bodyText = sourceCode.text
.slice(arrowToken.range[1], node.range[1])
.trim()
let resultText =
/*eslint-disable @mysticatea/prettier */
node.body.type === "BlockStatement" ? (
`function(${paramText}) ${bodyText}`
) : preText.includes("\n") ? (
`function(${paramText}) { return (${bodyText}) }`
) : (
`function(${paramText}) { return ${bodyText} }`
)
/*eslint-enable @mysticatea/prettier */
if (node.async) {
resultText = `async ${resultText}`
}
if (hasThis) {
resultText += ".bind(this)"
}
if (
node.parent.type === "ExpressionStatement" &&
!isParenthesized(node, sourceCode)
) {
resultText = `(${resultText})`
}
return resultText
}
/**
* Report that ArrowFunctionExpression is being used
* @param {Node} node ArrowFunctionExpression Node
* @param {boolean} hasThis Whether `this` is referenced in` function` scope
* @param {boolean} hasSuper Whether `super` is referenced in` function` scope
* @returns {void}
*/
function report(node, hasThis, hasSuper) {
context.report({
node,
messageId: "forbidden",
fix(fixer) {
if (hasSuper) {
return undefined
}
return fixer.replaceText(
node,
toFunctionExpression(node, hasThis)
)
},
})
}
let stack = { upper: null, hasThis: false, hasSuper: false }
return {
":function"() {
stack = { upper: stack, hasThis: false, hasSuper: false }
},
":function:exit"(node) {
const { hasThis, hasSuper } = stack
stack = stack.upper
if (node.type === "ArrowFunctionExpression") {
report(node, hasThis, hasSuper)
stack.hasThis = stack.hasThis || hasThis
stack.hasSuper = stack.hasSuper || hasSuper
}
},
ThisExpression() {
stack.hasThis = true
},
Super() {
stack.hasSuper = true
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow async function declarations.",
category: "ES2017",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-async-functions.html",
},
fixable: null,
messages: {
forbidden: "ES2017 async function declarations are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":function[async=true]"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+33
View File
@@ -0,0 +1,33 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow async iteration.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-async-iteration.html",
},
fixable: null,
messages: {
forbidden: "ES2018 async iteration is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":function[async=true][generator=true]"(node) {
context.report({ node, messageId: "forbidden" })
},
"ForOfStatement[await=true]"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Atomics` class.",
category: "ES2017",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-atomics.html",
},
fixable: null,
messages: {
forbidden: "ES2017 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Atomics: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+47
View File
@@ -0,0 +1,47 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow `bigint` syntax and built-ins",
category: "ES2020",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-bigint.html",
},
fixable: null,
messages: {
forbidden: "ES2020 BigInt is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
Literal(node) {
if (node.bigint != null) {
context.report({ messageId: "forbidden", node })
}
},
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
const references = tracker.iterateGlobalReferences({
BigInt: { [ReferenceTracker.READ]: true },
BigInt64Array: { [ReferenceTracker.READ]: true },
BigUint64Array: { [ReferenceTracker.READ]: true },
})
for (const { node } of references) {
context.report({ messageId: "forbidden", node })
}
},
}
},
}
+34
View File
@@ -0,0 +1,34 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const Pattern = /^0[bB]/u
module.exports = {
meta: {
docs: {
description: "disallow binary numeric literals.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-binary-numeric-literals.html",
},
fixable: null,
messages: {
forbidden: "ES2015 binary numeric literals are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
Literal(node) {
if (typeof node.value === "number" && Pattern.test(node.raw)) {
context.report({ node, messageId: "forbidden" })
}
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow block-scoped function declarations.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-block-scoped-functions.html",
},
fixable: null,
messages: {
forbidden: "ES2015 block-scoped functions are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":not(:function) > BlockStatement > FunctionDeclaration"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow block-scoped variable declarations.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-block-scoped-variables.html",
},
fixable: null,
messages: {
forbidden: "ES2015 block-scoped variables are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"VariableDeclaration[kind='const'], VariableDeclaration[kind='let']"(
node
) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow class declarations.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-classes.html",
},
fixable: null,
messages: {
forbidden: "ES2015 class declarations are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"ClassDeclaration, ClassExpression"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow computed properties.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-computed-properties.html",
},
fixable: null,
messages: {
forbidden: "ES2015 computed properties are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":matches(Property, MethodDefinition)[computed=true]"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Date.now` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-date-now.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Date: {
now: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow default parameters.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-default-parameters.html",
},
fixable: null,
messages: {
forbidden: "ES2015 default parameters are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":function > AssignmentPattern"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow destructuring.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-destructuring.html",
},
fixable: null,
messages: {
forbidden: "ES2015 destructuring is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":matches(:function, AssignmentExpression, VariableDeclarator, :function > :matches(AssignmentPattern, RestElement), ForInStatement, ForOfStatement) > :matches(ArrayPattern, ObjectPattern)"(
node
) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow `import()` syntax",
category: "ES2020",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-dynamic-import.html",
},
fixable: null,
messages: {
forbidden: "ES2020 'import()' syntax is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
ImportExpression(node) {
context.report({ messageId: "forbidden", node })
},
}
},
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow exponential operators.",
category: "ES2016",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-exponential-operators.html",
},
fixable: null,
messages: {
forbidden: "ES2016 exponential operators are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"AssignmentExpression[operator='**='], BinaryExpression[operator='**']"(
node
) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow `for-of` statements.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-for-of-loops.html",
},
fixable: null,
messages: {
forbidden: "ES2015 'for-of' statements are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
ForOfStatement(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow generator function declarations.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-generators.html",
},
fixable: null,
messages: {
forbidden: "ES2015 generator function declarations are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":function[generator=true]"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `globalThis` variable",
category: "ES2020",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-global-this.html",
},
fixable: null,
messages: {
forbidden: "ES2020 '{{name}}' variable is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
globalThis: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+55
View File
@@ -0,0 +1,55 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { definePatternSearchGenerator } = require("../utils")
const iterateTargetChars = definePatternSearchGenerator(/[\u2028\u2029]/gu)
module.exports = {
meta: {
docs: {
description: "disallow `\\u2028` and `\\u2029` in string literals.",
category: "ES2019",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-json-superset.html",
},
fixable: "code",
messages: {
forbidden: "ES2019 '\\u{{code}}' in string literals is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
return {
Literal(node) {
if (typeof node.value !== "string") {
return
}
const offset = node.range[0]
for (const { index } of iterateTargetChars(node.raw)) {
const code = node.raw.codePointAt(index).toString(16)
const loc = sourceCode.getLocFromIndex(offset + index)
context.report({
node,
loc,
messageId: "forbidden",
data: { code },
fix(fixer) {
return fixer.replaceTextRange(
[offset + index, offset + index + 1],
`\\u${code}`
)
},
})
}
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `JSON` class.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-json.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
JSON: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+108
View File
@@ -0,0 +1,108 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
// https://www-archive.mozilla.org/js/language/E262-3.pdf
const keywords = new Set([
"abstract",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"double",
"else",
"enum",
"export",
"extends",
"false",
"final",
"finally",
"float",
"for",
"function",
"goto",
"if",
"implements",
"import",
"in",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"true",
"try",
"typeof",
"var",
"void",
"volatile",
"while",
"with",
])
module.exports = {
meta: {
docs: {
description: "disallow reserved words as property names.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-keyword-properties.html",
},
fixable: null,
messages: {
forbidden: "ES5 reserved words as property names are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
Property(node) {
if (
!node.computed &&
node.key.type === "Identifier" &&
keywords.has(node.key.name)
) {
context.report({ node, messageId: "forbidden" })
}
},
MemberExpression(node) {
if (
!node.computed &&
node.property.type === "Identifier" &&
keywords.has(node.property.name)
) {
context.report({ node, messageId: "forbidden" })
}
},
}
},
}
@@ -0,0 +1,37 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description:
"disallow template literals with invalid escape sequences.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-malformed-template-literals.html",
},
fixable: null,
messages: {
forbidden:
"ES2018 template literals with invalid escape sequences are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const reported = new Set()
return {
"TemplateElement[value.cooked=null]"(elementNode) {
const node = elementNode.parent
if (!reported.has(node)) {
reported.add(node)
context.report({ node, messageId: "forbidden" })
}
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Map` class.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-map.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Map: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.acosh` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-acosh.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
acosh: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.asinh` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-asinh.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
asinh: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.atanh` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-atanh.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
atanh: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.cbrt` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-cbrt.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
cbrt: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.clz32` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-clz32.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
clz32: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.cosh` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-cosh.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
cosh: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.expm1` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-expm1.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
expm1: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.fround` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-fround.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
fround: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.hypot` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-hypot.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
hypot: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.imul` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-imul.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
imul: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.log10` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-log10.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
log10: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.log1p` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-log1p.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
log1p: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.log2` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-log2.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
log2: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.sign` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-sign.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
sign: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.sinh` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-sinh.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
sinh: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.tanh` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-tanh.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
tanh: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Math.trunc` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-math-trunc.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Math: {
trunc: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow modules.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-modules.html",
},
fixable: null,
messages: {
forbidden: "ES2015 modules are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ImportDeclaration"(
node
) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow `new.target` meta property.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-new-target.html",
},
fixable: null,
messages: {
forbidden: "ES2015 'new.target' meta property is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"MetaProperty[meta.name='new'][property.name='target']"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.EPSILON` property.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-epsilon.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' property is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
EPSILON: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.isFinite` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-isfinite.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
isFinite: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.isInteger` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-isinteger.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
isInteger: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.isNaN` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-isnan.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
isNaN: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.isSafeInteger` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-issafeinteger.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
isSafeInteger: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.MAX_SAFE_INTEGER` property.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-maxsafeinteger.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' property is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
MAX_SAFE_INTEGER: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.MIN_SAFE_INTEGER` property.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-minsafeinteger.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' property is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
MIN_SAFE_INTEGER: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.parseFloat` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-parsefloat.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
parseFloat: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Number.parseInt` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-number-parseint.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Number: {
parseInt: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.assign` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-assign.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
assign: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.defineProperties` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-defineproperties.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
defineProperties: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.defineProperty` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-defineproperty.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
defineProperty: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.entries` method.",
category: "ES2017",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-entries.html",
},
fixable: null,
messages: {
forbidden: "ES2017 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
entries: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.freeze` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-freeze.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
freeze: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
@@ -0,0 +1,44 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description:
"disallow the `Object.getOwnPropertyDescriptor` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-getownpropertydescriptor.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
getOwnPropertyDescriptor: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
@@ -0,0 +1,44 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description:
"disallow the `Object.getOwnPropertyDescriptors` method.",
category: "ES2017",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-getownpropertydescriptors.html",
},
fixable: null,
messages: {
forbidden: "ES2017 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
getOwnPropertyDescriptors: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.getOwnPropertyNames` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-getownpropertynames.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
getOwnPropertyNames: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.getOwnPropertySymbols` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-getownpropertysymbols.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
getOwnPropertySymbols: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.getPrototypeOf` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-getprototypeof.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
getPrototypeOf: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.is` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-is.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
is: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.isExtensible` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-isextensible.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
isExtensible: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.isFrozen` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-isfrozen.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
isFrozen: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.isSealed` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-issealed.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
isSealed: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.keys` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-keys.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
keys: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.preventExtensions` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-preventextensions.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
preventExtensions: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.seal` method.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-seal.html",
},
fixable: null,
messages: {
forbidden: "ES5 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
seal: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.setPrototypeOf` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-setprototypeof.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
setPrototypeOf: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+47
View File
@@ -0,0 +1,47 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description:
"disallow `super` property accesses in object literals.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-super-properties.html",
},
fixable: null,
messages: {
forbidden:
"ES2015 'super' property accesses in object literals are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
let stack = null
return {
Super(node) {
if (stack && stack.inObjectMethod) {
context.report({ node, messageId: "forbidden" })
}
},
":matches(FunctionExpression, FunctionDeclaration)"(node) {
const { type, method } = node.parent
stack = {
inObjectMethod: type === "Property" && method === true,
upper: stack,
}
},
":matches(FunctionExpression, FunctionDeclaration):exit"() {
stack = stack.upper
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Object.values` method.",
category: "ES2017",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-object-values.html",
},
fixable: null,
messages: {
forbidden: "ES2017 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Object: {
values: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+34
View File
@@ -0,0 +1,34 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const Pattern = /^0[oO]/u
module.exports = {
meta: {
docs: {
description: "disallow octal numeric literals.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-octal-numeric-literals.html",
},
fixable: null,
messages: {
forbidden: "ES2015 octal numeric literals are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
Literal(node) {
if (typeof node.value === "number" && Pattern.test(node.raw)) {
context.report({ node, messageId: "forbidden" })
}
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow optional `catch` binding.",
category: "ES2019",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-optional-catch-binding.html",
},
fixable: null,
messages: {
forbidden: "ES2019 optional 'catch' binding is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"CatchClause[param=null]"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+37
View File
@@ -0,0 +1,37 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow `Promise.allSettled` function",
category: "ES2020",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-promise-all-settled.html",
},
fixable: null,
messages: {
forbidden: "ES2020 'Promise.allSettled' function is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node } of tracker.iterateGlobalReferences({
Promise: { allSettled: { [READ]: true } },
})) {
context.report({ node, messageId: "forbidden" })
}
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Promise` class.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-promise.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Promise: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+78
View File
@@ -0,0 +1,78 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { isOpeningBracketToken, isClosingBracketToken } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow property shorthands.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-property-shorthands.html",
},
fixable: "code",
messages: {
forbidden: "ES2015 property shorthands are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
/**
* Fixes a FunctionExpression node by making it into a longform property.
* @param {SourceCodeFixer} fixer The fixer object
* @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value
* @returns {object} A fix for this node
*/
function makeFunctionLongform(fixer, node) {
const firstKeyToken = node.computed
? sourceCode.getTokenBefore(node.key, isOpeningBracketToken)
: sourceCode.getFirstToken(node.key)
const lastKeyToken = node.computed
? sourceCode.getTokenAfter(node.key, isClosingBracketToken)
: sourceCode.getLastToken(node.key)
const keyText = sourceCode.text.slice(
firstKeyToken.range[0],
lastKeyToken.range[1]
)
let functionHeader = "function"
if (node.value.async) {
functionHeader = `async ${functionHeader}`
}
if (node.value.generator) {
functionHeader = `${functionHeader}*`
}
return fixer.replaceTextRange(
[node.range[0], lastKeyToken.range[1]],
`${keyText}: ${functionHeader}`
)
}
return {
"ObjectExpression > :matches(Property[method=true], Property[shorthand=true])"(
node
) {
context.report({
node,
messageId: "forbidden",
fix: node.method
? fixer => makeFunctionLongform(fixer, node)
: fixer =>
fixer.insertTextAfter(
node.key,
`: ${node.key.name}`
),
})
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Proxy` class.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-proxy.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Proxy: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Reflect` class.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-reflect.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Reflect: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
@@ -0,0 +1,74 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { RegExpValidator } = require("regexpp")
const { getRegExpCalls } = require("../utils")
/**
* Verify a given regular expression.
* @param {RuleContext} context The rule context to report.
* @param {Node} node The AST node to report.
* @param {string} pattern The pattern part of a RegExp.
* @param {string} flags The flags part of a RegExp.
* @returns {void}
*/
function verify(context, node, pattern, flags) {
try {
let found = false
new RegExpValidator({
onLookaroundAssertionEnter(_start, kind) {
if (kind === "lookbehind") {
found = true
}
},
}).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
if (found) {
context.report({ node, messageId: "forbidden" })
}
} catch (error) {
//istanbul ignore else
if (error.message.startsWith("Invalid regular expression:")) {
return
}
//istanbul ignore next
throw error
}
}
module.exports = {
meta: {
docs: {
description: "disallow RegExp lookbehind assertions.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-lookbehind-assertions.html",
},
fixable: null,
messages: {
forbidden: "ES2018 RegExp lookbehind assertions are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
const { pattern, flags } = node.regex
verify(context, node, pattern || "", flags || "")
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, pattern, flags } of getRegExpCalls(scope)) {
verify(context, node, pattern || "", flags || "")
}
},
}
},
}
@@ -0,0 +1,79 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { RegExpValidator } = require("regexpp")
const { getRegExpCalls } = require("../utils")
/**
* Verify a given regular expression.
* @param {RuleContext} context The rule context to report.
* @param {Node} node The AST node to report.
* @param {string} pattern The pattern part of a RegExp.
* @param {string} flags The flags part of a RegExp.
* @returns {void}
*/
function verify(context, node, pattern, flags) {
try {
let found = false
new RegExpValidator({
onCapturingGroupEnter(_start, name) {
if (name) {
found = true
}
},
onBackreference(_start, _end, ref) {
if (typeof ref === "string") {
found = true
}
},
}).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
if (found) {
context.report({ node, messageId: "forbidden" })
}
} catch (error) {
//istanbul ignore else
if (error.message.startsWith("Invalid regular expression:")) {
return
}
//istanbul ignore next
throw error
}
}
module.exports = {
meta: {
docs: {
description: "disallow RegExp named capture groups.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-named-capture-groups.html",
},
fixable: null,
messages: {
forbidden: "ES2018 RegExp named capture groups are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
const { pattern, flags } = node.regex
verify(context, node, pattern || "", flags || "")
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, pattern, flags } of getRegExpCalls(scope)) {
verify(context, node, pattern || "", flags || "")
}
},
}
},
}
+44
View File
@@ -0,0 +1,44 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { getRegExpCalls } = require("../utils")
module.exports = {
meta: {
docs: {
description: "disallow RegExp `s` flag.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-s-flag.html",
},
fixable: null,
messages: {
forbidden: "ES2018 RegExp 's' flag is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
if (node.regex.flags.includes("s")) {
context.report({ node, messageId: "forbidden" })
}
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, flags } of getRegExpCalls(scope)) {
if (flags && flags.includes("s")) {
context.report({ node, messageId: "forbidden" })
}
}
},
}
},
}
+44
View File
@@ -0,0 +1,44 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { getRegExpCalls } = require("../utils")
module.exports = {
meta: {
docs: {
description: "disallow RegExp `u` flag.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-u-flag.html",
},
fixable: null,
messages: {
forbidden: "ES2015 RegExp 'u' flag is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
if (node.regex.flags.includes("u")) {
context.report({ node, messageId: "forbidden" })
}
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, flags } of getRegExpCalls(scope)) {
if (flags && flags.includes("u")) {
context.report({ node, messageId: "forbidden" })
}
}
},
}
},
}
@@ -0,0 +1,97 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { RegExpValidator } = require("regexpp")
const { getRegExpCalls } = require("../utils")
const scNamePattern = /^(?:Script(?:_Extensions)?|scx?)$/u
const scValuePattern = /^(?:Dogr|Dogra|Gong|Gunjala_Gondi|Hanifi_Rohingya|Maka|Makasar|Medefaidrin|Medf|Old_Sogdian|Rohg|Sogd|Sogdian|Sogo)$/u
function isNewUnicodePropertyKeyValuePair(key, value) {
return scNamePattern.test(key) && scValuePattern.test(value)
}
function isNewBinaryUnicodeProperty(key) {
return key === "Extended_Pictographic"
}
/**
* Verify a given regular expression.
* @param {RuleContext} context The rule context to report.
* @param {Node} node The AST node to report.
* @param {string} pattern The pattern part of a RegExp.
* @param {string} flags The flags part of a RegExp.
* @returns {void}
*/
function verify(context, node, pattern, flags) {
try {
let foundValue = ""
new RegExpValidator({
onUnicodePropertyCharacterSet(start, end, _kind, key, value) {
if (foundValue) {
return
}
if (
value
? isNewUnicodePropertyKeyValuePair(key, value)
: isNewBinaryUnicodeProperty(key)
) {
foundValue = pattern.slice(start, end)
}
},
}).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
if (foundValue) {
context.report({
node,
messageId: "forbidden",
data: { value: foundValue },
})
}
} catch (error) {
//istanbul ignore else
if (error.message.startsWith("Invalid regular expression:")) {
return
}
//istanbul ignore next
throw error
}
}
module.exports = {
meta: {
docs: {
description:
"disallow the new values of RegExp Unicode property escape sequences in ES2019",
category: "ES2019",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-unicode-property-escapes-2019.html",
},
fixable: null,
messages: {
forbidden: "ES2019 '{{value}}' is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
const { pattern, flags } = node.regex
verify(context, node, pattern || "", flags || "")
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, pattern, flags } of getRegExpCalls(scope)) {
verify(context, node, pattern || "", flags || "")
}
},
}
},
}
@@ -0,0 +1,73 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { RegExpValidator } = require("regexpp")
const { getRegExpCalls } = require("../utils")
/**
* Verify a given regular expression.
* @param {RuleContext} context The rule context to report.
* @param {Node} node The AST node to report.
* @param {string} pattern The pattern part of a RegExp.
* @param {string} flags The flags part of a RegExp.
* @returns {void}
*/
function verify(context, node, pattern, flags) {
try {
let found = false
new RegExpValidator({
onUnicodePropertyCharacterSet() {
found = true
},
}).validatePattern(pattern, 0, pattern.length, flags.includes("u"))
if (found) {
context.report({ node, messageId: "forbidden" })
}
} catch (error) {
//istanbul ignore else
if (error.message.startsWith("Invalid regular expression:")) {
return
}
//istanbul ignore next
throw error
}
}
module.exports = {
meta: {
docs: {
description: "disallow RegExp Unicode property escape sequences.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-unicode-property-escapes.html",
},
fixable: null,
messages: {
forbidden:
"ES2018 RegExp Unicode property escape sequences are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
const { pattern, flags } = node.regex
verify(context, node, pattern || "", flags || "")
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, pattern, flags } of getRegExpCalls(scope)) {
verify(context, node, pattern || "", flags || "")
}
},
}
},
}
+44
View File
@@ -0,0 +1,44 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { getRegExpCalls } = require("../utils")
module.exports = {
meta: {
docs: {
description: "disallow RegExp `y` flag.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-regexp-y-flag.html",
},
fixable: null,
messages: {
forbidden: "ES2015 RegExp 'y' flag is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Literal[regex]"(node) {
if (node.regex.flags.includes("y")) {
context.report({ node, messageId: "forbidden" })
}
},
"Program:exit"() {
const scope = context.getScope()
for (const { node, flags } of getRegExpCalls(scope)) {
if (flags && flags.includes("y")) {
context.report({ node, messageId: "forbidden" })
}
}
},
}
},
}
+30
View File
@@ -0,0 +1,30 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow rest parameters.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-rest-parameters.html",
},
fixable: null,
messages: {
forbidden: "ES2015 rest parameters are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":function > RestElement"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+33
View File
@@ -0,0 +1,33 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow rest/spread properties.",
category: "ES2018",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-rest-spread-properties.html",
},
fixable: null,
messages: {
forbidden: "ES2018 rest/spread properties are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"ObjectPattern > RestElement"(node) {
context.report({ node, messageId: "forbidden" })
},
"ObjectExpression > SpreadElement"(node) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Set` class.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-set.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Set: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `SharedArrayBuffer` class.",
category: "ES2017",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-shared-array-buffer.html",
},
fixable: null,
messages: {
forbidden: "ES2017 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
SharedArrayBuffer: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+32
View File
@@ -0,0 +1,32 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
module.exports = {
meta: {
docs: {
description: "disallow spread elements.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-spread-elements.html",
},
fixable: null,
messages: {
forbidden: "ES2015 spread elements are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
":matches(ArrayExpression, CallExpression, NewExpression) > SpreadElement"(
node
) {
context.report({ node, messageId: "forbidden" })
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `String.fromCodePoint` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-string-fromcodepoint.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
String: {
fromCodePoint: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+43
View File
@@ -0,0 +1,43 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `String.raw` method.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-string-raw.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' method is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
String: {
raw: { [READ]: true },
},
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+55
View File
@@ -0,0 +1,55 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the subclassing of the built-in classes.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-subclassing-builtins.html",
},
fixable: null,
messages: {
forbidden: "ES2015 subclassing of '{{name}}' is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Array: { [READ]: true },
Boolean: { [READ]: true },
Error: { [READ]: true },
RegExp: { [READ]: true },
Function: { [READ]: true },
Map: { [READ]: true },
Number: { [READ]: true },
Promise: { [READ]: true },
Set: { [READ]: true },
String: { [READ]: true },
})) {
if (
node.parent.type.startsWith("Class") &&
node.parent.superClass === node
) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
}
},
}
},
}
+41
View File
@@ -0,0 +1,41 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { READ, ReferenceTracker } = require("eslint-utils")
module.exports = {
meta: {
docs: {
description: "disallow the `Symbol` class.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-symbol.html",
},
fixable: null,
messages: {
forbidden: "ES2015 '{{name}}' class is forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
for (const { node, path } of tracker.iterateGlobalReferences({
Symbol: { [READ]: true },
})) {
context.report({
node,
messageId: "forbidden",
data: { name: path.join(".") },
})
}
},
}
},
}
+85
View File
@@ -0,0 +1,85 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
/**
* Checks whether it is string literal
* @param {string} s string source code
* @returns {boolean} true: is string literal source code
*/
function isStringLiteralCode(s) {
return (
(s.startsWith("'") && s.endsWith("'")) ||
(s.startsWith('"') && s.endsWith('"'))
)
}
/**
* Transform template literal to string concatenation.
* @param {ASTNode} node TemplateLiteral node.(not within TaggedTemplateExpression)
* @param {SourceCode} sourceCode SourceCode
* @returns {string} After transformation
*/
function templateLiteralToStringConcat(node, sourceCode) {
const ss = []
node.quasis.forEach((q, i) => {
const value = q.value.cooked
if (value) {
ss.push(JSON.stringify(value))
}
if (i < node.expressions.length) {
const e = node.expressions[i]
const text = sourceCode.getText(e)
ss.push(text)
}
})
if (!ss.length || !isStringLiteralCode(ss[0])) {
ss.unshift('""')
}
return ss.join("+")
}
module.exports = {
meta: {
docs: {
description: "disallow template literals.",
category: "ES2015",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-template-literals.html",
},
fixable: "code",
messages: {
forbidden: "ES2015 template literals are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
return {
"TaggedTemplateExpression, :not(TaggedTemplateExpression) > TemplateLiteral"(
node
) {
context.report({
node,
messageId: "forbidden",
fix:
node.type === "TemplateLiteral"
? fixer =>
fixer.replaceText(
node,
templateLiteralToStringConcat(
node,
sourceCode
)
)
: undefined,
})
},
}
},
}
+39
View File
@@ -0,0 +1,39 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const { isCommaToken } = require("../utils")
module.exports = {
meta: {
docs: {
description: "disallow trailing commas in array/object literals.",
category: "ES5",
recommended: false,
url:
"http://mysticatea.github.io/eslint-plugin-es/rules/no-trailing-commas.html",
},
fixable: null,
messages: {
forbidden:
"ES5 trailing commas in array/object literals are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const sourceCode = context.getSourceCode()
return {
"ArrayExpression, ArrayPattern, ObjectExpression, ObjectPattern"(
node
) {
const token = sourceCode.getLastToken(node, 1)
if (isCommaToken(token)) {
context.report({ node, messageId: "forbidden" })
}
},
}
},
}

Some files were not shown because too many files have changed in this diff Show More