-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3177c5f
commit b5928ab
Showing
43 changed files
with
1,110 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Array.isArray` method (es/no-array-isarray) | ||
|
||
This rule reports ES5 `Array.isArray` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-array-isarray: error */ | ||
var array = Array.isArray(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-array-isarray.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-array-isarray.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Date.now` method (es/no-date-now) | ||
|
||
This rule reports ES5 `Date.now` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-date-now: error */ | ||
var now = Date.now() | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-date-now.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-date-now.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# disallow the `JSON` class (es/no-json) | ||
|
||
This rule reports ES5 `JSON` class as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-json: error */ | ||
var obj = JSON.parse(text) | ||
var str = JSON.stringify(data) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-json.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-json.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.defineProperties` method (es/no-object-defineproperties) | ||
|
||
This rule reports ES5 `Object.defineProperties` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-defineproperties: error */ | ||
Object.defineProperties(obj, {}) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-defineproperties.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-defineproperties.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.defineProperty` method (es/no-object-defineproperty) | ||
|
||
This rule reports ES5 `Object.defineProperty` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-defineproperty: error */ | ||
Object.defineProperty(obj, "prop", {}) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-defineproperty.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-defineproperty.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.freeze` method (es/no-object-freeze) | ||
|
||
This rule reports ES5 `Object.freeze` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-freeze: error */ | ||
Object.freeze(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-freeze.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-freeze.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.getOwnPropertyDescriptor` method (es/no-object-getownpropertydescriptor) | ||
|
||
This rule reports ES5 `Object.getOwnPropertyDescriptor` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-getownpropertydescriptor: error */ | ||
var descriptors = Object.getOwnPropertyDescriptor(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-getownpropertydescriptor.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-getownpropertydescriptor.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.getOwnPropertyNames` method (es/no-object-getownpropertynames) | ||
|
||
This rule reports ES5 `Object.getOwnPropertyNames` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-getownpropertynames: error */ | ||
Object.getOwnPropertyNames(obj, "prop", {}) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-getownpropertynames.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-getownpropertynames.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.getPrototypeOf` method (es/no-object-getprototypeof) | ||
|
||
This rule reports ES5 `Object.getPrototypeOf` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-getprototypeof: error */ | ||
var proto = Object.getPrototypeOf(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-getprototypeof.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-getprototypeof.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.isExtensible` method (es/no-object-isextensible) | ||
|
||
This rule reports ES5 `Object.isExtensible` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-isextensible: error */ | ||
var extensible = Object.isExtensible(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-isextensible.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-isextensible.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.isFrozen` method (es/no-object-isfrozen) | ||
|
||
This rule reports ES5 `Object.isFrozen` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-isfrozen: error */ | ||
var frozen = Object.isFrozen(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-isfrozen.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-isfrozen.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.isSealed` method (es/no-object-issealed) | ||
|
||
This rule reports ES5 `Object.isSealed` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-issealed: error */ | ||
var sealed = Object.isSealed(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-issealed.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-issealed.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.preventExtensions` method (es/no-object-preventextensions) | ||
|
||
This rule reports ES5 `Object.preventExtensions` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-preventextensions: error */ | ||
Object.preventExtensions(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-preventextensions.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-preventextensions.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# disallow the `Object.seal` method (es/no-object-seal) | ||
|
||
This rule reports ES5 `Object.seal` method as errors. | ||
|
||
## Examples | ||
|
||
⛔ Examples of **incorrect** code for this rule: | ||
|
||
<eslint-playground type="bad" code="/*eslint es/no-object-seal: error */ | ||
Object.seal(obj) | ||
" /> | ||
|
||
## 📚 References | ||
|
||
- [Rule source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/lib/rules/no-object-seal.js) | ||
- [Test source](https://github.com/mysticatea/eslint-plugin-es/blob/v2.0.0/tests/lib/rules/no-object-seal.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: undefined, // TODO(mysticatea): set ES5 category | ||
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(".") }, | ||
}) | ||
} | ||
}, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: undefined, // TODO(mysticatea): set ES5 category | ||
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(".") }, | ||
}) | ||
} | ||
}, | ||
} | ||
}, | ||
} |
Oops, something went wrong.