diff --git a/docs/rules/index.md b/docs/rules/index.md index a670ed7b..55e7cb7d 100644 --- a/docs/rules/index.md +++ b/docs/rules/index.md @@ -377,6 +377,73 @@ Rules in this category are not included in any preset. | [es-x/no-string-prototype-substr](./no-string-prototype-substr.md) | disallow the `String.prototype.substr` method. | | | [es-x/no-string-prototype-trimleft-trimright](./no-string-prototype-trimleft-trimright.md) | disallow the `String.prototype.{trimLeft,trimRight}` methods. | 🔧 | +## Non-standards + +Rules in this category disallow features that are not defined in ECMAScript.\ +Rules in this category are not included in any preset. + +| Rule ID | Description | | +|:--------|:------------|:--:| +| [es-x/no-nonstandard-array-properties](./no-nonstandard-array-properties.md) | disallow non-standard properties on `Array` class. | | +| [es-x/no-nonstandard-array-prototype-properties](./no-nonstandard-array-prototype-properties.md) | disallow non-standard properties on Array instance. | | +| [es-x/no-nonstandard-arraybuffer-properties](./no-nonstandard-arraybuffer-properties.md) | disallow non-standard properties on `ArrayBuffer` class. | | +| [es-x/no-nonstandard-arraybuffer-prototype-properties](./no-nonstandard-arraybuffer-prototype-properties.md) | disallow non-standard properties on ArrayBuffer instance. | | +| [es-x/no-nonstandard-atomics-properties](./no-nonstandard-atomics-properties.md) | disallow non-standard properties on `Atomics` class. | | +| [es-x/no-nonstandard-bigint-properties](./no-nonstandard-bigint-properties.md) | disallow non-standard properties on `BigInt` class. | | +| [es-x/no-nonstandard-bigint-prototype-properties](./no-nonstandard-bigint-prototype-properties.md) | disallow non-standard properties on BigInt instance. | | +| [es-x/no-nonstandard-boolean-properties](./no-nonstandard-boolean-properties.md) | disallow non-standard properties on `Boolean` class. | | +| [es-x/no-nonstandard-boolean-prototype-properties](./no-nonstandard-boolean-prototype-properties.md) | disallow non-standard properties on Boolean instance. | | +| [es-x/no-nonstandard-dataview-prototype-properties](./no-nonstandard-dataview-prototype-properties.md) | disallow non-standard properties on DataView instance. | | +| [es-x/no-nonstandard-date-properties](./no-nonstandard-date-properties.md) | disallow non-standard properties on `Date` class. | | +| [es-x/no-nonstandard-date-prototype-properties](./no-nonstandard-date-prototype-properties.md) | disallow non-standard properties on Date instance. | | +| [es-x/no-nonstandard-finalizationregistry-prototype-properties](./no-nonstandard-finalizationregistry-prototype-properties.md) | disallow non-standard properties on FinalizationRegistry instance. | | +| [es-x/no-nonstandard-function-properties](./no-nonstandard-function-properties.md) | disallow non-standard properties on `Function` class. | | +| [es-x/no-nonstandard-intl-collator-properties](./no-nonstandard-intl-collator-properties.md) | disallow non-standard properties on `Intl.Collator` class. | | +| [es-x/no-nonstandard-intl-collator-prototype-properties](./no-nonstandard-intl-collator-prototype-properties.md) | disallow non-standard properties on Intl.Collator instance. | | +| [es-x/no-nonstandard-intl-datetimeformat-properties](./no-nonstandard-intl-datetimeformat-properties.md) | disallow non-standard properties on `Intl.DateTimeFormat` class. | | +| [es-x/no-nonstandard-intl-datetimeformat-prototype-properties](./no-nonstandard-intl-datetimeformat-prototype-properties.md) | disallow non-standard properties on Intl.DateTimeFormat instance. | | +| [es-x/no-nonstandard-intl-displaynames-properties](./no-nonstandard-intl-displaynames-properties.md) | disallow non-standard properties on `Intl.DisplayNames` class. | | +| [es-x/no-nonstandard-intl-displaynames-prototype-properties](./no-nonstandard-intl-displaynames-prototype-properties.md) | disallow non-standard properties on Intl.DisplayNames instance. | | +| [es-x/no-nonstandard-intl-listformat-properties](./no-nonstandard-intl-listformat-properties.md) | disallow non-standard properties on `Intl.ListFormat` class. | | +| [es-x/no-nonstandard-intl-listformat-prototype-properties](./no-nonstandard-intl-listformat-prototype-properties.md) | disallow non-standard properties on Intl.ListFormat instance. | | +| [es-x/no-nonstandard-intl-locale-properties](./no-nonstandard-intl-locale-properties.md) | disallow non-standard properties on `Intl.Locale` class. | | +| [es-x/no-nonstandard-intl-locale-prototype-properties](./no-nonstandard-intl-locale-prototype-properties.md) | disallow non-standard properties on Intl.Locale instance. | | +| [es-x/no-nonstandard-intl-numberformat-properties](./no-nonstandard-intl-numberformat-properties.md) | disallow non-standard properties on `Intl.NumberFormat` class. | | +| [es-x/no-nonstandard-intl-numberformat-prototype-properties](./no-nonstandard-intl-numberformat-prototype-properties.md) | disallow non-standard properties on Intl.NumberFormat instance. | | +| [es-x/no-nonstandard-intl-pluralrules-properties](./no-nonstandard-intl-pluralrules-properties.md) | disallow non-standard properties on `Intl.PluralRules` class. | | +| [es-x/no-nonstandard-intl-pluralrules-prototype-properties](./no-nonstandard-intl-pluralrules-prototype-properties.md) | disallow non-standard properties on Intl.PluralRules instance. | | +| [es-x/no-nonstandard-intl-properties](./no-nonstandard-intl-properties.md) | disallow non-standard properties on `Intl` class. | | +| [es-x/no-nonstandard-intl-relativetimeformat-properties](./no-nonstandard-intl-relativetimeformat-properties.md) | disallow non-standard properties on `Intl.RelativeTimeFormat` class. | | +| [es-x/no-nonstandard-intl-relativetimeformat-prototype-properties](./no-nonstandard-intl-relativetimeformat-prototype-properties.md) | disallow non-standard properties on Intl.RelativeTimeFormat instance. | | +| [es-x/no-nonstandard-intl-segmenter-properties](./no-nonstandard-intl-segmenter-properties.md) | disallow non-standard properties on `Intl.Segmenter` class. | | +| [es-x/no-nonstandard-intl-segmenter-prototype-properties](./no-nonstandard-intl-segmenter-prototype-properties.md) | disallow non-standard properties on Intl.Segmenter instance. | | +| [es-x/no-nonstandard-iterator-properties](./no-nonstandard-iterator-properties.md) | disallow non-standard properties on `Iterator` class. | | +| [es-x/no-nonstandard-iterator-prototype-properties](./no-nonstandard-iterator-prototype-properties.md) | disallow non-standard properties on Iterator instance. | | +| [es-x/no-nonstandard-json-properties](./no-nonstandard-json-properties.md) | disallow non-standard properties on `JSON` class. | | +| [es-x/no-nonstandard-map-properties](./no-nonstandard-map-properties.md) | disallow non-standard properties on `Map` class. | | +| [es-x/no-nonstandard-map-prototype-properties](./no-nonstandard-map-prototype-properties.md) | disallow non-standard properties on Map instance. | | +| [es-x/no-nonstandard-math-properties](./no-nonstandard-math-properties.md) | disallow non-standard properties on `Math` class. | | +| [es-x/no-nonstandard-number-properties](./no-nonstandard-number-properties.md) | disallow non-standard properties on `Number` class. | | +| [es-x/no-nonstandard-number-prototype-properties](./no-nonstandard-number-prototype-properties.md) | disallow non-standard properties on Number instance. | | +| [es-x/no-nonstandard-object-properties](./no-nonstandard-object-properties.md) | disallow non-standard properties on `Object` class. | | +| [es-x/no-nonstandard-promise-properties](./no-nonstandard-promise-properties.md) | disallow non-standard properties on `Promise` class. | | +| [es-x/no-nonstandard-promise-prototype-properties](./no-nonstandard-promise-prototype-properties.md) | disallow non-standard properties on Promise instance. | | +| [es-x/no-nonstandard-proxy-properties](./no-nonstandard-proxy-properties.md) | disallow non-standard properties on `Proxy` class. | | +| [es-x/no-nonstandard-reflect-properties](./no-nonstandard-reflect-properties.md) | disallow non-standard properties on `Reflect` class. | | +| [es-x/no-nonstandard-regexp-properties](./no-nonstandard-regexp-properties.md) | disallow non-standard properties on `RegExp` class. | | +| [es-x/no-nonstandard-regexp-prototype-properties](./no-nonstandard-regexp-prototype-properties.md) | disallow non-standard properties on RegExp instance. | | +| [es-x/no-nonstandard-set-prototype-properties](./no-nonstandard-set-prototype-properties.md) | disallow non-standard properties on Set instance. | | +| [es-x/no-nonstandard-sharedarraybuffer-prototype-properties](./no-nonstandard-sharedarraybuffer-prototype-properties.md) | disallow non-standard properties on SharedArrayBuffer instance. | | +| [es-x/no-nonstandard-string-properties](./no-nonstandard-string-properties.md) | disallow non-standard properties on `String` class. | | +| [es-x/no-nonstandard-string-prototype-properties](./no-nonstandard-string-prototype-properties.md) | disallow non-standard properties on String instance. | | +| [es-x/no-nonstandard-symbol-properties](./no-nonstandard-symbol-properties.md) | disallow non-standard properties on `Symbol` class. | | +| [es-x/no-nonstandard-symbol-prototype-properties](./no-nonstandard-symbol-prototype-properties.md) | disallow non-standard properties on Symbol instance. | | +| [es-x/no-nonstandard-typed-array-properties](./no-nonstandard-typed-array-properties.md) | disallow non-standard properties on typed array class. | | +| [es-x/no-nonstandard-typed-array-prototype-properties](./no-nonstandard-typed-array-prototype-properties.md) | disallow non-standard properties on typed array instance. | | +| [es-x/no-nonstandard-weakmap-prototype-properties](./no-nonstandard-weakmap-prototype-properties.md) | disallow non-standard properties on WeakMap instance. | | +| [es-x/no-nonstandard-weakref-prototype-properties](./no-nonstandard-weakref-prototype-properties.md) | disallow non-standard properties on WeakRef instance. | | +| [es-x/no-nonstandard-weakset-prototype-properties](./no-nonstandard-weakset-prototype-properties.md) | disallow non-standard properties on WeakSet instance. | | + ## Deprecated 😇 We don't fix bugs which are in deprecated rules since we don't have enough resources. diff --git a/docs/rules/no-nonstandard-array-properties.md b/docs/rules/no-nonstandard-array-properties.md new file mode 100644 index 00000000..3ba8e1b9 --- /dev/null +++ b/docs/rules/no-nonstandard-array-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-array-properties" +description: "disallow non-standard properties on `Array` class" +--- + +# es-x/no-nonstandard-array-properties +> disallow non-standard properties on `Array` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Array` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-array-properties: error */ +Array.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-array-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-array-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-array-properties.js) diff --git a/docs/rules/no-nonstandard-array-prototype-properties.md b/docs/rules/no-nonstandard-array-prototype-properties.md new file mode 100644 index 00000000..1c73853c --- /dev/null +++ b/docs/rules/no-nonstandard-array-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-array-prototype-properties" +description: "disallow non-standard properties on Array instance" +--- + +# es-x/no-nonstandard-array-prototype-properties +> disallow non-standard properties on Array instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Array instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-array-prototype-properties: error */ +const foo = []; +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-array-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-array-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-array-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-arraybuffer-properties.md b/docs/rules/no-nonstandard-arraybuffer-properties.md new file mode 100644 index 00000000..2a2b64b2 --- /dev/null +++ b/docs/rules/no-nonstandard-arraybuffer-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-arraybuffer-properties" +description: "disallow non-standard properties on `ArrayBuffer` class" +--- + +# es-x/no-nonstandard-arraybuffer-properties +> disallow non-standard properties on `ArrayBuffer` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `ArrayBuffer` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-arraybuffer-properties: error */ +ArrayBuffer.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-arraybuffer-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-arraybuffer-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-arraybuffer-properties.js) diff --git a/docs/rules/no-nonstandard-arraybuffer-prototype-properties.md b/docs/rules/no-nonstandard-arraybuffer-prototype-properties.md new file mode 100644 index 00000000..7837b510 --- /dev/null +++ b/docs/rules/no-nonstandard-arraybuffer-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-arraybuffer-prototype-properties" +description: "disallow non-standard properties on ArrayBuffer instance" +--- + +# es-x/no-nonstandard-arraybuffer-prototype-properties +> disallow non-standard properties on ArrayBuffer instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on ArrayBuffer instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-arraybuffer-prototype-properties: error */ +const foo = new ArrayBuffer(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-arraybuffer-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-atomics-properties.md b/docs/rules/no-nonstandard-atomics-properties.md new file mode 100644 index 00000000..b6d5a88e --- /dev/null +++ b/docs/rules/no-nonstandard-atomics-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-atomics-properties" +description: "disallow non-standard properties on `Atomics` class" +--- + +# es-x/no-nonstandard-atomics-properties +> disallow non-standard properties on `Atomics` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Atomics` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-atomics-properties: error */ +Atomics.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-atomics-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-atomics-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-atomics-properties.js) diff --git a/docs/rules/no-nonstandard-bigint-properties.md b/docs/rules/no-nonstandard-bigint-properties.md new file mode 100644 index 00000000..761ba921 --- /dev/null +++ b/docs/rules/no-nonstandard-bigint-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-bigint-properties" +description: "disallow non-standard properties on `BigInt` class" +--- + +# es-x/no-nonstandard-bigint-properties +> disallow non-standard properties on `BigInt` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `BigInt` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-bigint-properties: error */ +BigInt.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-bigint-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-bigint-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-bigint-properties.js) diff --git a/docs/rules/no-nonstandard-bigint-prototype-properties.md b/docs/rules/no-nonstandard-bigint-prototype-properties.md new file mode 100644 index 00000000..a7802004 --- /dev/null +++ b/docs/rules/no-nonstandard-bigint-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-bigint-prototype-properties" +description: "disallow non-standard properties on BigInt instance" +--- + +# es-x/no-nonstandard-bigint-prototype-properties +> disallow non-standard properties on BigInt instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on BigInt instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-bigint-prototype-properties: error */ +const foo = 123n; +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-bigint-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-bigint-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-bigint-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-boolean-properties.md b/docs/rules/no-nonstandard-boolean-properties.md new file mode 100644 index 00000000..86de6580 --- /dev/null +++ b/docs/rules/no-nonstandard-boolean-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-boolean-properties" +description: "disallow non-standard properties on `Boolean` class" +--- + +# es-x/no-nonstandard-boolean-properties +> disallow non-standard properties on `Boolean` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Boolean` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-boolean-properties: error */ +Boolean.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-boolean-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-boolean-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-boolean-properties.js) diff --git a/docs/rules/no-nonstandard-boolean-prototype-properties.md b/docs/rules/no-nonstandard-boolean-prototype-properties.md new file mode 100644 index 00000000..70fbae27 --- /dev/null +++ b/docs/rules/no-nonstandard-boolean-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-boolean-prototype-properties" +description: "disallow non-standard properties on Boolean instance" +--- + +# es-x/no-nonstandard-boolean-prototype-properties +> disallow non-standard properties on Boolean instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Boolean instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-boolean-prototype-properties: error */ +const foo = true; +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-boolean-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-boolean-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-boolean-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-dataview-prototype-properties.md b/docs/rules/no-nonstandard-dataview-prototype-properties.md new file mode 100644 index 00000000..b297c0ee --- /dev/null +++ b/docs/rules/no-nonstandard-dataview-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-dataview-prototype-properties" +description: "disallow non-standard properties on DataView instance" +--- + +# es-x/no-nonstandard-dataview-prototype-properties +> disallow non-standard properties on DataView instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on DataView instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-dataview-prototype-properties: error */ +const foo = new DataView(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-dataview-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-dataview-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-dataview-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-date-properties.md b/docs/rules/no-nonstandard-date-properties.md new file mode 100644 index 00000000..491fbedf --- /dev/null +++ b/docs/rules/no-nonstandard-date-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-date-properties" +description: "disallow non-standard properties on `Date` class" +--- + +# es-x/no-nonstandard-date-properties +> disallow non-standard properties on `Date` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Date` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-date-properties: error */ +Date.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-date-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-date-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-date-properties.js) diff --git a/docs/rules/no-nonstandard-date-prototype-properties.md b/docs/rules/no-nonstandard-date-prototype-properties.md new file mode 100644 index 00000000..4653f40e --- /dev/null +++ b/docs/rules/no-nonstandard-date-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-date-prototype-properties" +description: "disallow non-standard properties on Date instance" +--- + +# es-x/no-nonstandard-date-prototype-properties +> disallow non-standard properties on Date instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Date instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-date-prototype-properties: error */ +const foo = new Date(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-date-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-date-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-date-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-finalizationregistry-prototype-properties.md b/docs/rules/no-nonstandard-finalizationregistry-prototype-properties.md new file mode 100644 index 00000000..3c92619b --- /dev/null +++ b/docs/rules/no-nonstandard-finalizationregistry-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-finalizationregistry-prototype-properties" +description: "disallow non-standard properties on FinalizationRegistry instance" +--- + +# es-x/no-nonstandard-finalizationregistry-prototype-properties +> disallow non-standard properties on FinalizationRegistry instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on FinalizationRegistry instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-finalizationregistry-prototype-properties: error */ +const foo = new FinalizationRegistry(() => {/* ... */}); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-finalizationregistry-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-function-properties.md b/docs/rules/no-nonstandard-function-properties.md new file mode 100644 index 00000000..73153d5e --- /dev/null +++ b/docs/rules/no-nonstandard-function-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-function-properties" +description: "disallow non-standard properties on `Function` class" +--- + +# es-x/no-nonstandard-function-properties +> disallow non-standard properties on `Function` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Function` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-function-properties: error */ +Function.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-function-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-function-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-function-properties.js) diff --git a/docs/rules/no-nonstandard-intl-collator-properties.md b/docs/rules/no-nonstandard-intl-collator-properties.md new file mode 100644 index 00000000..6a5c2361 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-collator-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-collator-properties" +description: "disallow non-standard properties on `Intl.Collator` class" +--- + +# es-x/no-nonstandard-intl-collator-properties +> disallow non-standard properties on `Intl.Collator` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.Collator` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-collator-properties: error */ +Intl.Collator.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-collator-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-collator-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-collator-properties.js) diff --git a/docs/rules/no-nonstandard-intl-collator-prototype-properties.md b/docs/rules/no-nonstandard-intl-collator-prototype-properties.md new file mode 100644 index 00000000..c9fd3fe3 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-collator-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-collator-prototype-properties" +description: "disallow non-standard properties on Intl.Collator instance" +--- + +# es-x/no-nonstandard-intl-collator-prototype-properties +> disallow non-standard properties on Intl.Collator instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.Collator instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-collator-prototype-properties: error */ +const foo = new Intl.Collator(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-collator-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-collator-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-collator-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-datetimeformat-properties.md b/docs/rules/no-nonstandard-intl-datetimeformat-properties.md new file mode 100644 index 00000000..b0597dfe --- /dev/null +++ b/docs/rules/no-nonstandard-intl-datetimeformat-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-datetimeformat-properties" +description: "disallow non-standard properties on `Intl.DateTimeFormat` class" +--- + +# es-x/no-nonstandard-intl-datetimeformat-properties +> disallow non-standard properties on `Intl.DateTimeFormat` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.DateTimeFormat` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-datetimeformat-properties: error */ +Intl.DateTimeFormat.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-datetimeformat-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-datetimeformat-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-datetimeformat-properties.js) diff --git a/docs/rules/no-nonstandard-intl-datetimeformat-prototype-properties.md b/docs/rules/no-nonstandard-intl-datetimeformat-prototype-properties.md new file mode 100644 index 00000000..34f44974 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-datetimeformat-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-datetimeformat-prototype-properties" +description: "disallow non-standard properties on Intl.DateTimeFormat instance" +--- + +# es-x/no-nonstandard-intl-datetimeformat-prototype-properties +> disallow non-standard properties on Intl.DateTimeFormat instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.DateTimeFormat instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-datetimeformat-prototype-properties: error */ +const foo = new Intl.DateTimeFormat(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-datetimeformat-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-displaynames-properties.md b/docs/rules/no-nonstandard-intl-displaynames-properties.md new file mode 100644 index 00000000..a044a918 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-displaynames-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-displaynames-properties" +description: "disallow non-standard properties on `Intl.DisplayNames` class" +--- + +# es-x/no-nonstandard-intl-displaynames-properties +> disallow non-standard properties on `Intl.DisplayNames` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.DisplayNames` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-displaynames-properties: error */ +Intl.DisplayNames.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-displaynames-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-displaynames-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-displaynames-properties.js) diff --git a/docs/rules/no-nonstandard-intl-displaynames-prototype-properties.md b/docs/rules/no-nonstandard-intl-displaynames-prototype-properties.md new file mode 100644 index 00000000..f3876387 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-displaynames-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-displaynames-prototype-properties" +description: "disallow non-standard properties on Intl.DisplayNames instance" +--- + +# es-x/no-nonstandard-intl-displaynames-prototype-properties +> disallow non-standard properties on Intl.DisplayNames instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.DisplayNames instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-displaynames-prototype-properties: error */ +const foo = new Intl.DisplayNames(['en'], { type: 'region' }); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-displaynames-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-listformat-properties.md b/docs/rules/no-nonstandard-intl-listformat-properties.md new file mode 100644 index 00000000..4a9907c7 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-listformat-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-listformat-properties" +description: "disallow non-standard properties on `Intl.ListFormat` class" +--- + +# es-x/no-nonstandard-intl-listformat-properties +> disallow non-standard properties on `Intl.ListFormat` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.ListFormat` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-listformat-properties: error */ +Intl.ListFormat.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-listformat-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-listformat-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-listformat-properties.js) diff --git a/docs/rules/no-nonstandard-intl-listformat-prototype-properties.md b/docs/rules/no-nonstandard-intl-listformat-prototype-properties.md new file mode 100644 index 00000000..75971a84 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-listformat-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-listformat-prototype-properties" +description: "disallow non-standard properties on Intl.ListFormat instance" +--- + +# es-x/no-nonstandard-intl-listformat-prototype-properties +> disallow non-standard properties on Intl.ListFormat instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.ListFormat instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-listformat-prototype-properties: error */ +const foo = new Intl.ListFormat(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-listformat-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-locale-properties.md b/docs/rules/no-nonstandard-intl-locale-properties.md new file mode 100644 index 00000000..fa5c1361 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-locale-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-locale-properties" +description: "disallow non-standard properties on `Intl.Locale` class" +--- + +# es-x/no-nonstandard-intl-locale-properties +> disallow non-standard properties on `Intl.Locale` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.Locale` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-locale-properties: error */ +Intl.Locale.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-locale-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-locale-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-locale-properties.js) diff --git a/docs/rules/no-nonstandard-intl-locale-prototype-properties.md b/docs/rules/no-nonstandard-intl-locale-prototype-properties.md new file mode 100644 index 00000000..ae8a2e23 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-locale-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-locale-prototype-properties" +description: "disallow non-standard properties on Intl.Locale instance" +--- + +# es-x/no-nonstandard-intl-locale-prototype-properties +> disallow non-standard properties on Intl.Locale instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.Locale instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-locale-prototype-properties: error */ +const foo = new Intl.Locale(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-locale-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-locale-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-locale-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-numberformat-properties.md b/docs/rules/no-nonstandard-intl-numberformat-properties.md new file mode 100644 index 00000000..856b4a37 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-numberformat-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-numberformat-properties" +description: "disallow non-standard properties on `Intl.NumberFormat` class" +--- + +# es-x/no-nonstandard-intl-numberformat-properties +> disallow non-standard properties on `Intl.NumberFormat` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.NumberFormat` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-numberformat-properties: error */ +Intl.NumberFormat.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-numberformat-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-numberformat-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-numberformat-properties.js) diff --git a/docs/rules/no-nonstandard-intl-numberformat-prototype-properties.md b/docs/rules/no-nonstandard-intl-numberformat-prototype-properties.md new file mode 100644 index 00000000..5ee3e938 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-numberformat-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-numberformat-prototype-properties" +description: "disallow non-standard properties on Intl.NumberFormat instance" +--- + +# es-x/no-nonstandard-intl-numberformat-prototype-properties +> disallow non-standard properties on Intl.NumberFormat instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.NumberFormat instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-numberformat-prototype-properties: error */ +const foo = new Intl.NumberFormat(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-numberformat-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-pluralrules-properties.md b/docs/rules/no-nonstandard-intl-pluralrules-properties.md new file mode 100644 index 00000000..350b8391 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-pluralrules-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-pluralrules-properties" +description: "disallow non-standard properties on `Intl.PluralRules` class" +--- + +# es-x/no-nonstandard-intl-pluralrules-properties +> disallow non-standard properties on `Intl.PluralRules` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.PluralRules` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-pluralrules-properties: error */ +Intl.PluralRules.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-pluralrules-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-pluralrules-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-pluralrules-properties.js) diff --git a/docs/rules/no-nonstandard-intl-pluralrules-prototype-properties.md b/docs/rules/no-nonstandard-intl-pluralrules-prototype-properties.md new file mode 100644 index 00000000..458c87dd --- /dev/null +++ b/docs/rules/no-nonstandard-intl-pluralrules-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-pluralrules-prototype-properties" +description: "disallow non-standard properties on Intl.PluralRules instance" +--- + +# es-x/no-nonstandard-intl-pluralrules-prototype-properties +> disallow non-standard properties on Intl.PluralRules instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.PluralRules instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-pluralrules-prototype-properties: error */ +const foo = new Intl.PluralRules(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-pluralrules-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-properties.md b/docs/rules/no-nonstandard-intl-properties.md new file mode 100644 index 00000000..5e298057 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-properties" +description: "disallow non-standard properties on `Intl` class" +--- + +# es-x/no-nonstandard-intl-properties +> disallow non-standard properties on `Intl` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-properties: error */ +const x = new Intl.Unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-properties.js) diff --git a/docs/rules/no-nonstandard-intl-relativetimeformat-properties.md b/docs/rules/no-nonstandard-intl-relativetimeformat-properties.md new file mode 100644 index 00000000..fb7b0ef8 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-relativetimeformat-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-relativetimeformat-properties" +description: "disallow non-standard properties on `Intl.RelativeTimeFormat` class" +--- + +# es-x/no-nonstandard-intl-relativetimeformat-properties +> disallow non-standard properties on `Intl.RelativeTimeFormat` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.RelativeTimeFormat` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-relativetimeformat-properties: error */ +Intl.RelativeTimeFormat.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-relativetimeformat-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js) diff --git a/docs/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.md b/docs/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.md new file mode 100644 index 00000000..bef1d266 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-relativetimeformat-prototype-properties" +description: "disallow non-standard properties on Intl.RelativeTimeFormat instance" +--- + +# es-x/no-nonstandard-intl-relativetimeformat-prototype-properties +> disallow non-standard properties on Intl.RelativeTimeFormat instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.RelativeTimeFormat instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-relativetimeformat-prototype-properties: error */ +const foo = new Intl.RelativeTimeFormat(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-relativetimeformat-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-intl-segmenter-properties.md b/docs/rules/no-nonstandard-intl-segmenter-properties.md new file mode 100644 index 00000000..a1df3cdc --- /dev/null +++ b/docs/rules/no-nonstandard-intl-segmenter-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-intl-segmenter-properties" +description: "disallow non-standard properties on `Intl.Segmenter` class" +--- + +# es-x/no-nonstandard-intl-segmenter-properties +> disallow non-standard properties on `Intl.Segmenter` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Intl.Segmenter` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-segmenter-properties: error */ +Intl.Segmenter.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-segmenter-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-segmenter-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-segmenter-properties.js) diff --git a/docs/rules/no-nonstandard-intl-segmenter-prototype-properties.md b/docs/rules/no-nonstandard-intl-segmenter-prototype-properties.md new file mode 100644 index 00000000..cd4a95b3 --- /dev/null +++ b/docs/rules/no-nonstandard-intl-segmenter-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-intl-segmenter-prototype-properties" +description: "disallow non-standard properties on Intl.Segmenter instance" +--- + +# es-x/no-nonstandard-intl-segmenter-prototype-properties +> disallow non-standard properties on Intl.Segmenter instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Intl.Segmenter instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-intl-segmenter-prototype-properties: error */ +const foo = new Intl.Segmenter(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-intl-segmenter-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-iterator-properties.md b/docs/rules/no-nonstandard-iterator-properties.md new file mode 100644 index 00000000..90750c00 --- /dev/null +++ b/docs/rules/no-nonstandard-iterator-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-iterator-properties" +description: "disallow non-standard properties on `Iterator` class" +--- + +# es-x/no-nonstandard-iterator-properties +> disallow non-standard properties on `Iterator` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Iterator` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-iterator-properties: error */ +Iterator.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-iterator-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-iterator-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-iterator-properties.js) diff --git a/docs/rules/no-nonstandard-iterator-prototype-properties.md b/docs/rules/no-nonstandard-iterator-prototype-properties.md new file mode 100644 index 00000000..d7f261e9 --- /dev/null +++ b/docs/rules/no-nonstandard-iterator-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-iterator-prototype-properties" +description: "disallow non-standard properties on Iterator instance" +--- + +# es-x/no-nonstandard-iterator-prototype-properties +> disallow non-standard properties on Iterator instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Iterator instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-iterator-prototype-properties: error */ +const foo = Iterator.from(obj); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-iterator-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-iterator-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-iterator-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-json-properties.md b/docs/rules/no-nonstandard-json-properties.md new file mode 100644 index 00000000..115d7fbd --- /dev/null +++ b/docs/rules/no-nonstandard-json-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-json-properties" +description: "disallow non-standard properties on `JSON` class" +--- + +# es-x/no-nonstandard-json-properties +> disallow non-standard properties on `JSON` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `JSON` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-json-properties: error */ +JSON.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-json-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-json-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-json-properties.js) diff --git a/docs/rules/no-nonstandard-map-properties.md b/docs/rules/no-nonstandard-map-properties.md new file mode 100644 index 00000000..38001f4e --- /dev/null +++ b/docs/rules/no-nonstandard-map-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-map-properties" +description: "disallow non-standard properties on `Map` class" +--- + +# es-x/no-nonstandard-map-properties +> disallow non-standard properties on `Map` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Map` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-map-properties: error */ +Map.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-map-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-map-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-map-properties.js) diff --git a/docs/rules/no-nonstandard-map-prototype-properties.md b/docs/rules/no-nonstandard-map-prototype-properties.md new file mode 100644 index 00000000..d778da1f --- /dev/null +++ b/docs/rules/no-nonstandard-map-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-map-prototype-properties" +description: "disallow non-standard properties on Map instance" +--- + +# es-x/no-nonstandard-map-prototype-properties +> disallow non-standard properties on Map instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Map instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-map-prototype-properties: error */ +const foo = new Map(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-map-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-map-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-map-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-math-properties.md b/docs/rules/no-nonstandard-math-properties.md new file mode 100644 index 00000000..b82ee3e6 --- /dev/null +++ b/docs/rules/no-nonstandard-math-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-math-properties" +description: "disallow non-standard properties on `Math` class" +--- + +# es-x/no-nonstandard-math-properties +> disallow non-standard properties on `Math` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Math` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-math-properties: error */ +Math.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-math-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-math-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-math-properties.js) diff --git a/docs/rules/no-nonstandard-number-properties.md b/docs/rules/no-nonstandard-number-properties.md new file mode 100644 index 00000000..7e5f79dd --- /dev/null +++ b/docs/rules/no-nonstandard-number-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-number-properties" +description: "disallow non-standard properties on `Number` class" +--- + +# es-x/no-nonstandard-number-properties +> disallow non-standard properties on `Number` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Number` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-number-properties: error */ +Number.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-number-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-number-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-number-properties.js) diff --git a/docs/rules/no-nonstandard-number-prototype-properties.md b/docs/rules/no-nonstandard-number-prototype-properties.md new file mode 100644 index 00000000..0c4ac65f --- /dev/null +++ b/docs/rules/no-nonstandard-number-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-number-prototype-properties" +description: "disallow non-standard properties on Number instance" +--- + +# es-x/no-nonstandard-number-prototype-properties +> disallow non-standard properties on Number instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Number instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-number-prototype-properties: error */ +const foo = 123; +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-number-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-number-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-number-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-object-properties.md b/docs/rules/no-nonstandard-object-properties.md new file mode 100644 index 00000000..cc5fb26b --- /dev/null +++ b/docs/rules/no-nonstandard-object-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-object-properties" +description: "disallow non-standard properties on `Object` class" +--- + +# es-x/no-nonstandard-object-properties +> disallow non-standard properties on `Object` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Object` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-object-properties: error */ +Object.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-object-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-object-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-object-properties.js) diff --git a/docs/rules/no-nonstandard-promise-properties.md b/docs/rules/no-nonstandard-promise-properties.md new file mode 100644 index 00000000..31016865 --- /dev/null +++ b/docs/rules/no-nonstandard-promise-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-promise-properties" +description: "disallow non-standard properties on `Promise` class" +--- + +# es-x/no-nonstandard-promise-properties +> disallow non-standard properties on `Promise` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Promise` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-promise-properties: error */ +Promise.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-promise-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-promise-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-promise-properties.js) diff --git a/docs/rules/no-nonstandard-promise-prototype-properties.md b/docs/rules/no-nonstandard-promise-prototype-properties.md new file mode 100644 index 00000000..ee94f9d4 --- /dev/null +++ b/docs/rules/no-nonstandard-promise-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-promise-prototype-properties" +description: "disallow non-standard properties on Promise instance" +--- + +# es-x/no-nonstandard-promise-prototype-properties +> disallow non-standard properties on Promise instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Promise instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-promise-prototype-properties: error */ +const foo = import('foo'); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-promise-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-promise-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-promise-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-proxy-properties.md b/docs/rules/no-nonstandard-proxy-properties.md new file mode 100644 index 00000000..d20fba9b --- /dev/null +++ b/docs/rules/no-nonstandard-proxy-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-proxy-properties" +description: "disallow non-standard properties on `Proxy` class" +--- + +# es-x/no-nonstandard-proxy-properties +> disallow non-standard properties on `Proxy` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Proxy` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-proxy-properties: error */ +Proxy.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-proxy-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-proxy-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-proxy-properties.js) diff --git a/docs/rules/no-nonstandard-reflect-properties.md b/docs/rules/no-nonstandard-reflect-properties.md new file mode 100644 index 00000000..7f65403b --- /dev/null +++ b/docs/rules/no-nonstandard-reflect-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-reflect-properties" +description: "disallow non-standard properties on `Reflect` class" +--- + +# es-x/no-nonstandard-reflect-properties +> disallow non-standard properties on `Reflect` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Reflect` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-reflect-properties: error */ +Reflect.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-reflect-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-reflect-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-reflect-properties.js) diff --git a/docs/rules/no-nonstandard-regexp-properties.md b/docs/rules/no-nonstandard-regexp-properties.md new file mode 100644 index 00000000..89970c22 --- /dev/null +++ b/docs/rules/no-nonstandard-regexp-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-regexp-properties" +description: "disallow non-standard properties on `RegExp` class" +--- + +# es-x/no-nonstandard-regexp-properties +> disallow non-standard properties on `RegExp` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `RegExp` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-regexp-properties: error */ +RegExp.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-regexp-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-regexp-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-regexp-properties.js) diff --git a/docs/rules/no-nonstandard-regexp-prototype-properties.md b/docs/rules/no-nonstandard-regexp-prototype-properties.md new file mode 100644 index 00000000..8376fee2 --- /dev/null +++ b/docs/rules/no-nonstandard-regexp-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-regexp-prototype-properties" +description: "disallow non-standard properties on RegExp instance" +--- + +# es-x/no-nonstandard-regexp-prototype-properties +> disallow non-standard properties on RegExp instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on RegExp instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-regexp-prototype-properties: error */ +const foo = /foo/u; +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-regexp-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-regexp-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-regexp-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-set-prototype-properties.md b/docs/rules/no-nonstandard-set-prototype-properties.md new file mode 100644 index 00000000..24bcd445 --- /dev/null +++ b/docs/rules/no-nonstandard-set-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-set-prototype-properties" +description: "disallow non-standard properties on Set instance" +--- + +# es-x/no-nonstandard-set-prototype-properties +> disallow non-standard properties on Set instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Set instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-set-prototype-properties: error */ +const foo = new Set(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-set-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-set-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-set-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-sharedarraybuffer-prototype-properties.md b/docs/rules/no-nonstandard-sharedarraybuffer-prototype-properties.md new file mode 100644 index 00000000..a5540a16 --- /dev/null +++ b/docs/rules/no-nonstandard-sharedarraybuffer-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-sharedarraybuffer-prototype-properties" +description: "disallow non-standard properties on SharedArrayBuffer instance" +--- + +# es-x/no-nonstandard-sharedarraybuffer-prototype-properties +> disallow non-standard properties on SharedArrayBuffer instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on SharedArrayBuffer instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-sharedarraybuffer-prototype-properties: error */ +const foo = new SharedArrayBuffer(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-sharedarraybuffer-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-string-properties.md b/docs/rules/no-nonstandard-string-properties.md new file mode 100644 index 00000000..cdb728a5 --- /dev/null +++ b/docs/rules/no-nonstandard-string-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-string-properties" +description: "disallow non-standard properties on `String` class" +--- + +# es-x/no-nonstandard-string-properties +> disallow non-standard properties on `String` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `String` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-string-properties: error */ +String.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-string-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-string-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-string-properties.js) diff --git a/docs/rules/no-nonstandard-string-prototype-properties.md b/docs/rules/no-nonstandard-string-prototype-properties.md new file mode 100644 index 00000000..4996e748 --- /dev/null +++ b/docs/rules/no-nonstandard-string-prototype-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-string-prototype-properties" +description: "disallow non-standard properties on String instance" +--- + +# es-x/no-nonstandard-string-prototype-properties +> disallow non-standard properties on String instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on String instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-string-prototype-properties: error */ +'string'.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-string-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-string-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-string-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-symbol-properties.md b/docs/rules/no-nonstandard-symbol-properties.md new file mode 100644 index 00000000..b71539e3 --- /dev/null +++ b/docs/rules/no-nonstandard-symbol-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-symbol-properties" +description: "disallow non-standard properties on `Symbol` class" +--- + +# es-x/no-nonstandard-symbol-properties +> disallow non-standard properties on `Symbol` class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on `Symbol` class as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-symbol-properties: error */ +Symbol.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-symbol-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-symbol-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-symbol-properties.js) diff --git a/docs/rules/no-nonstandard-symbol-prototype-properties.md b/docs/rules/no-nonstandard-symbol-prototype-properties.md new file mode 100644 index 00000000..b726b729 --- /dev/null +++ b/docs/rules/no-nonstandard-symbol-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-symbol-prototype-properties" +description: "disallow non-standard properties on Symbol instance" +--- + +# es-x/no-nonstandard-symbol-prototype-properties +> disallow non-standard properties on Symbol instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on Symbol instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-symbol-prototype-properties: error */ +const foo = Symbol(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-symbol-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-symbol-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-symbol-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-typed-array-properties.md b/docs/rules/no-nonstandard-typed-array-properties.md new file mode 100644 index 00000000..e7af11aa --- /dev/null +++ b/docs/rules/no-nonstandard-typed-array-properties.md @@ -0,0 +1,50 @@ +--- +title: "es-x/no-nonstandard-typed-array-properties" +description: "disallow non-standard properties on typed array class" +--- + +# es-x/no-nonstandard-typed-array-properties +> disallow non-standard properties on typed array class + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on typed array class (`%TypedArray%`) as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-typed-array-properties: error */ +Int8Array.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-typed-array-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-typed-array-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-typed-array-properties.js) diff --git a/docs/rules/no-nonstandard-typed-array-prototype-properties.md b/docs/rules/no-nonstandard-typed-array-prototype-properties.md new file mode 100644 index 00000000..10cb4539 --- /dev/null +++ b/docs/rules/no-nonstandard-typed-array-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-typed-array-prototype-properties" +description: "disallow non-standard properties on typed array instance" +--- + +# es-x/no-nonstandard-typed-array-prototype-properties +> disallow non-standard properties on typed array instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on typed array (`%TypedArray%`) instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-typed-array-prototype-properties: error */ +const foo = 123; +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-typed-array-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-typed-array-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-typed-array-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-weakmap-prototype-properties.md b/docs/rules/no-nonstandard-weakmap-prototype-properties.md new file mode 100644 index 00000000..547f85cd --- /dev/null +++ b/docs/rules/no-nonstandard-weakmap-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-weakmap-prototype-properties" +description: "disallow non-standard properties on WeakMap instance" +--- + +# es-x/no-nonstandard-weakmap-prototype-properties +> disallow non-standard properties on WeakMap instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on WeakMap instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-weakmap-prototype-properties: error */ +const foo = new WeakMap(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-weakmap-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-weakmap-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-weakmap-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-weakref-prototype-properties.md b/docs/rules/no-nonstandard-weakref-prototype-properties.md new file mode 100644 index 00000000..299ea49e --- /dev/null +++ b/docs/rules/no-nonstandard-weakref-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-weakref-prototype-properties" +description: "disallow non-standard properties on WeakRef instance" +--- + +# es-x/no-nonstandard-weakref-prototype-properties +> disallow non-standard properties on WeakRef instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on WeakRef instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-weakref-prototype-properties: error */ +const foo = new WeakRef(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-weakref-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-weakref-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-weakref-prototype-properties.js) diff --git a/docs/rules/no-nonstandard-weakset-prototype-properties.md b/docs/rules/no-nonstandard-weakset-prototype-properties.md new file mode 100644 index 00000000..a0366500 --- /dev/null +++ b/docs/rules/no-nonstandard-weakset-prototype-properties.md @@ -0,0 +1,51 @@ +--- +title: "es-x/no-nonstandard-weakset-prototype-properties" +description: "disallow non-standard properties on WeakSet instance" +--- + +# es-x/no-nonstandard-weakset-prototype-properties +> disallow non-standard properties on WeakSet instance + +- ❗ ***This rule has not been released yet.*** + +This rule reports non-standard properties on WeakSet instance as errors. + +## 💡 Examples + +⛔ Examples of **incorrect** code for this rule: + + + +```js +/*eslint es-x/no-nonstandard-weakset-prototype-properties: error */ +const foo = new WeakSet(); +foo.unknown(); +``` + + + +## 🔧 Options + +This rule has an option. + +```jsonc +{ + "rules": { + "es-x/no-nonstandard-weakset-prototype-properties": [ + "error", + { + "allow": [] + } + ] + } +} +``` + +### allow: string[] + +An array of non-standard property names to allow. + +## 📚 References + +- [Rule source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/lib/rules/no-nonstandard-weakset-prototype-properties.js) +- [Test source](https://github.com/eslint-community/eslint-plugin-es-x/blob/master/tests/lib/rules/no-nonstandard-weakset-prototype-properties.js) diff --git a/jsconfig.json b/jsconfig.json index 99293e9b..1d160c39 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { "target": "ESNext", + "moduleResolution": "NodeNext", + "module": "NodeNext", "strict": true, "strictNullChecks": true }, diff --git a/lib/index.js b/lib/index.js index 99999415..c3c38a33 100644 --- a/lib/index.js +++ b/lib/index.js @@ -265,6 +265,65 @@ module.exports = { "no-math-trunc": require("./rules/no-math-trunc"), "no-modules": require("./rules/no-modules"), "no-new-target": require("./rules/no-new-target"), + "no-nonstandard-array-properties": require("./rules/no-nonstandard-array-properties"), + "no-nonstandard-array-prototype-properties": require("./rules/no-nonstandard-array-prototype-properties"), + "no-nonstandard-arraybuffer-properties": require("./rules/no-nonstandard-arraybuffer-properties"), + "no-nonstandard-arraybuffer-prototype-properties": require("./rules/no-nonstandard-arraybuffer-prototype-properties"), + "no-nonstandard-atomics-properties": require("./rules/no-nonstandard-atomics-properties"), + "no-nonstandard-bigint-properties": require("./rules/no-nonstandard-bigint-properties"), + "no-nonstandard-bigint-prototype-properties": require("./rules/no-nonstandard-bigint-prototype-properties"), + "no-nonstandard-boolean-properties": require("./rules/no-nonstandard-boolean-properties"), + "no-nonstandard-boolean-prototype-properties": require("./rules/no-nonstandard-boolean-prototype-properties"), + "no-nonstandard-dataview-prototype-properties": require("./rules/no-nonstandard-dataview-prototype-properties"), + "no-nonstandard-date-properties": require("./rules/no-nonstandard-date-properties"), + "no-nonstandard-date-prototype-properties": require("./rules/no-nonstandard-date-prototype-properties"), + "no-nonstandard-finalizationregistry-prototype-properties": require("./rules/no-nonstandard-finalizationregistry-prototype-properties"), + "no-nonstandard-function-properties": require("./rules/no-nonstandard-function-properties"), + "no-nonstandard-intl-collator-properties": require("./rules/no-nonstandard-intl-collator-properties"), + "no-nonstandard-intl-collator-prototype-properties": require("./rules/no-nonstandard-intl-collator-prototype-properties"), + "no-nonstandard-intl-datetimeformat-properties": require("./rules/no-nonstandard-intl-datetimeformat-properties"), + "no-nonstandard-intl-datetimeformat-prototype-properties": require("./rules/no-nonstandard-intl-datetimeformat-prototype-properties"), + "no-nonstandard-intl-displaynames-properties": require("./rules/no-nonstandard-intl-displaynames-properties"), + "no-nonstandard-intl-displaynames-prototype-properties": require("./rules/no-nonstandard-intl-displaynames-prototype-properties"), + "no-nonstandard-intl-listformat-properties": require("./rules/no-nonstandard-intl-listformat-properties"), + "no-nonstandard-intl-listformat-prototype-properties": require("./rules/no-nonstandard-intl-listformat-prototype-properties"), + "no-nonstandard-intl-locale-properties": require("./rules/no-nonstandard-intl-locale-properties"), + "no-nonstandard-intl-locale-prototype-properties": require("./rules/no-nonstandard-intl-locale-prototype-properties"), + "no-nonstandard-intl-numberformat-properties": require("./rules/no-nonstandard-intl-numberformat-properties"), + "no-nonstandard-intl-numberformat-prototype-properties": require("./rules/no-nonstandard-intl-numberformat-prototype-properties"), + "no-nonstandard-intl-pluralrules-properties": require("./rules/no-nonstandard-intl-pluralrules-properties"), + "no-nonstandard-intl-pluralrules-prototype-properties": require("./rules/no-nonstandard-intl-pluralrules-prototype-properties"), + "no-nonstandard-intl-properties": require("./rules/no-nonstandard-intl-properties"), + "no-nonstandard-intl-relativetimeformat-properties": require("./rules/no-nonstandard-intl-relativetimeformat-properties"), + "no-nonstandard-intl-relativetimeformat-prototype-properties": require("./rules/no-nonstandard-intl-relativetimeformat-prototype-properties"), + "no-nonstandard-intl-segmenter-properties": require("./rules/no-nonstandard-intl-segmenter-properties"), + "no-nonstandard-intl-segmenter-prototype-properties": require("./rules/no-nonstandard-intl-segmenter-prototype-properties"), + "no-nonstandard-iterator-properties": require("./rules/no-nonstandard-iterator-properties"), + "no-nonstandard-iterator-prototype-properties": require("./rules/no-nonstandard-iterator-prototype-properties"), + "no-nonstandard-json-properties": require("./rules/no-nonstandard-json-properties"), + "no-nonstandard-map-properties": require("./rules/no-nonstandard-map-properties"), + "no-nonstandard-map-prototype-properties": require("./rules/no-nonstandard-map-prototype-properties"), + "no-nonstandard-math-properties": require("./rules/no-nonstandard-math-properties"), + "no-nonstandard-number-properties": require("./rules/no-nonstandard-number-properties"), + "no-nonstandard-number-prototype-properties": require("./rules/no-nonstandard-number-prototype-properties"), + "no-nonstandard-object-properties": require("./rules/no-nonstandard-object-properties"), + "no-nonstandard-promise-properties": require("./rules/no-nonstandard-promise-properties"), + "no-nonstandard-promise-prototype-properties": require("./rules/no-nonstandard-promise-prototype-properties"), + "no-nonstandard-proxy-properties": require("./rules/no-nonstandard-proxy-properties"), + "no-nonstandard-reflect-properties": require("./rules/no-nonstandard-reflect-properties"), + "no-nonstandard-regexp-properties": require("./rules/no-nonstandard-regexp-properties"), + "no-nonstandard-regexp-prototype-properties": require("./rules/no-nonstandard-regexp-prototype-properties"), + "no-nonstandard-set-prototype-properties": require("./rules/no-nonstandard-set-prototype-properties"), + "no-nonstandard-sharedarraybuffer-prototype-properties": require("./rules/no-nonstandard-sharedarraybuffer-prototype-properties"), + "no-nonstandard-string-properties": require("./rules/no-nonstandard-string-properties"), + "no-nonstandard-string-prototype-properties": require("./rules/no-nonstandard-string-prototype-properties"), + "no-nonstandard-symbol-properties": require("./rules/no-nonstandard-symbol-properties"), + "no-nonstandard-symbol-prototype-properties": require("./rules/no-nonstandard-symbol-prototype-properties"), + "no-nonstandard-typed-array-properties": require("./rules/no-nonstandard-typed-array-properties"), + "no-nonstandard-typed-array-prototype-properties": require("./rules/no-nonstandard-typed-array-prototype-properties"), + "no-nonstandard-weakmap-prototype-properties": require("./rules/no-nonstandard-weakmap-prototype-properties"), + "no-nonstandard-weakref-prototype-properties": require("./rules/no-nonstandard-weakref-prototype-properties"), + "no-nonstandard-weakset-prototype-properties": require("./rules/no-nonstandard-weakset-prototype-properties"), "no-nullish-coalescing-operators": require("./rules/no-nullish-coalescing-operators"), "no-number-epsilon": require("./rules/no-number-epsilon"), "no-number-isfinite": require("./rules/no-number-isfinite"), diff --git a/lib/rules/no-nonstandard-array-properties.js b/lib/rules/no-nonstandard-array-properties.js new file mode 100644 index 00000000..5e6be2f4 --- /dev/null +++ b/lib/rules/no-nonstandard-array-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { arrayProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Array` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-array-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...arrayProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Array", allows) + }, +} diff --git a/lib/rules/no-nonstandard-array-prototype-properties.js b/lib/rules/no-nonstandard-array-prototype-properties.js new file mode 100644 index 00000000..c8c07525 --- /dev/null +++ b/lib/rules/no-nonstandard-array-prototype-properties.js @@ -0,0 +1,51 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { arrayPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Array instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-array-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...arrayPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Array", + allows, + { + // Allow index properties + allowsPropertyName: (name) => /^(?:[1-9]\d*|0)$/u.test(name), + }, + ) + }, +} diff --git a/lib/rules/no-nonstandard-arraybuffer-properties.js b/lib/rules/no-nonstandard-arraybuffer-properties.js new file mode 100644 index 00000000..2a1efdd4 --- /dev/null +++ b/lib/rules/no-nonstandard-arraybuffer-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { arrayBufferProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `ArrayBuffer` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-arraybuffer-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...arrayBufferProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "ArrayBuffer", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js b/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js new file mode 100644 index 00000000..87629620 --- /dev/null +++ b/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + arrayBufferPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on ArrayBuffer instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-arraybuffer-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...arrayBufferPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "ArrayBuffer", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-atomics-properties.js b/lib/rules/no-nonstandard-atomics-properties.js new file mode 100644 index 00000000..3c251403 --- /dev/null +++ b/lib/rules/no-nonstandard-atomics-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { atomicsProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Atomics` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-atomics-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...atomicsProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Atomics", allows) + }, +} diff --git a/lib/rules/no-nonstandard-bigint-properties.js b/lib/rules/no-nonstandard-bigint-properties.js new file mode 100644 index 00000000..d5a887e3 --- /dev/null +++ b/lib/rules/no-nonstandard-bigint-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { bigintProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `BigInt` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-bigint-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...bigintProperties, + ]) + return defineNonstandardPropertiesHandler(context, "BigInt", allows) + }, +} diff --git a/lib/rules/no-nonstandard-bigint-prototype-properties.js b/lib/rules/no-nonstandard-bigint-prototype-properties.js new file mode 100644 index 00000000..d6f45a66 --- /dev/null +++ b/lib/rules/no-nonstandard-bigint-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { bigintPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on BigInt instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-bigint-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...bigintPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "BigInt", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-boolean-properties.js b/lib/rules/no-nonstandard-boolean-properties.js new file mode 100644 index 00000000..49d3179d --- /dev/null +++ b/lib/rules/no-nonstandard-boolean-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { booleanProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Boolean` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-boolean-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...booleanProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Boolean", allows) + }, +} diff --git a/lib/rules/no-nonstandard-boolean-prototype-properties.js b/lib/rules/no-nonstandard-boolean-prototype-properties.js new file mode 100644 index 00000000..48337569 --- /dev/null +++ b/lib/rules/no-nonstandard-boolean-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { booleanPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Boolean instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-boolean-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...booleanPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Boolean", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-dataview-prototype-properties.js b/lib/rules/no-nonstandard-dataview-prototype-properties.js new file mode 100644 index 00000000..bffe7f06 --- /dev/null +++ b/lib/rules/no-nonstandard-dataview-prototype-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { dataViewPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on DataView instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-dataview-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...dataViewPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "DataView", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-date-properties.js b/lib/rules/no-nonstandard-date-properties.js new file mode 100644 index 00000000..7139c2e9 --- /dev/null +++ b/lib/rules/no-nonstandard-date-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { dateProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Date` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-date-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...dateProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Date", allows) + }, +} diff --git a/lib/rules/no-nonstandard-date-prototype-properties.js b/lib/rules/no-nonstandard-date-prototype-properties.js new file mode 100644 index 00000000..14829fc9 --- /dev/null +++ b/lib/rules/no-nonstandard-date-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { datePrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Date instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-date-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...datePrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Date", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js b/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js new file mode 100644 index 00000000..e766193b --- /dev/null +++ b/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + finalizationRegistryPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on FinalizationRegistry instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-finalizationregistry-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...finalizationRegistryPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "FinalizationRegistry", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-function-properties.js b/lib/rules/no-nonstandard-function-properties.js new file mode 100644 index 00000000..f12c7ab7 --- /dev/null +++ b/lib/rules/no-nonstandard-function-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { functionProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Function` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-function-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...functionProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Function", allows) + }, +} diff --git a/lib/rules/no-nonstandard-intl-collator-properties.js b/lib/rules/no-nonstandard-intl-collator-properties.js new file mode 100644 index 00000000..47e896a0 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-collator-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlCollatorProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.Collator` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-collator-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlCollatorProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.Collator", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-collator-prototype-properties.js b/lib/rules/no-nonstandard-intl-collator-prototype-properties.js new file mode 100644 index 00000000..4fa65044 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-collator-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlCollatorPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.Collator instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-collator-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlCollatorPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.Collator", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-datetimeformat-properties.js b/lib/rules/no-nonstandard-intl-datetimeformat-properties.js new file mode 100644 index 00000000..f07ba799 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-datetimeformat-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { + intlDateTimeFormatProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.DateTimeFormat` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-datetimeformat-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlDateTimeFormatProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.DateTimeFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js b/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js new file mode 100644 index 00000000..172900ab --- /dev/null +++ b/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlDateTimeFormatPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.DateTimeFormat instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-datetimeformat-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlDateTimeFormatPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.DateTimeFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-displaynames-properties.js b/lib/rules/no-nonstandard-intl-displaynames-properties.js new file mode 100644 index 00000000..02660608 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-displaynames-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlDisplayNamesProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.DisplayNames` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-displaynames-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlDisplayNamesProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.DisplayNames", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js b/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js new file mode 100644 index 00000000..565f06dc --- /dev/null +++ b/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlDisplayNamesPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.DisplayNames instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-displaynames-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlDisplayNamesPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.DisplayNames", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-listformat-properties.js b/lib/rules/no-nonstandard-intl-listformat-properties.js new file mode 100644 index 00000000..1afe8fc1 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-listformat-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlListFormatProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.ListFormat` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-listformat-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlListFormatProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.ListFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js b/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js new file mode 100644 index 00000000..509488b6 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlListFormatPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.ListFormat instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-listformat-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlListFormatPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.ListFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-locale-properties.js b/lib/rules/no-nonstandard-intl-locale-properties.js new file mode 100644 index 00000000..3bc416ce --- /dev/null +++ b/lib/rules/no-nonstandard-intl-locale-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlLocaleProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.Locale` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-locale-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlLocaleProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.Locale", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-locale-prototype-properties.js b/lib/rules/no-nonstandard-intl-locale-prototype-properties.js new file mode 100644 index 00000000..6eb705b9 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-locale-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlLocalePrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.Locale instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-locale-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlLocalePrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.Locale", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-numberformat-properties.js b/lib/rules/no-nonstandard-intl-numberformat-properties.js new file mode 100644 index 00000000..e21b9850 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-numberformat-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlNumberFormatProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.NumberFormat` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-numberformat-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlNumberFormatProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.NumberFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js b/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js new file mode 100644 index 00000000..38d5c184 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlNumberFormatPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.NumberFormat instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-numberformat-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlNumberFormatPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.NumberFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-pluralrules-properties.js b/lib/rules/no-nonstandard-intl-pluralrules-properties.js new file mode 100644 index 00000000..2d602ccf --- /dev/null +++ b/lib/rules/no-nonstandard-intl-pluralrules-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlPluralRulesProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.PluralRules` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-pluralrules-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlPluralRulesProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.PluralRules", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js b/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js new file mode 100644 index 00000000..14cfc552 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlPluralRulesPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.PluralRules instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-pluralrules-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlPluralRulesPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.PluralRules", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-properties.js b/lib/rules/no-nonstandard-intl-properties.js new file mode 100644 index 00000000..ec6d21ee --- /dev/null +++ b/lib/rules/no-nonstandard-intl-properties.js @@ -0,0 +1,44 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Intl` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlProperties, + ]) + + return defineNonstandardPropertiesHandler(context, "Intl", allows) + }, +} diff --git a/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js b/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js new file mode 100644 index 00000000..37f0dfc4 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { + intlRelativeTimeFormatProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.RelativeTimeFormat` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-relativetimeformat-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlRelativeTimeFormatProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.RelativeTimeFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js b/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js new file mode 100644 index 00000000..2a551a29 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlRelativeTimeFormatPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.RelativeTimeFormat instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlRelativeTimeFormatPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.RelativeTimeFormat", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-segmenter-properties.js b/lib/rules/no-nonstandard-intl-segmenter-properties.js new file mode 100644 index 00000000..550d5268 --- /dev/null +++ b/lib/rules/no-nonstandard-intl-segmenter-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { intlSegmenterProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on `Intl.Segmenter` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-segmenter-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlSegmenterProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + "Intl.Segmenter", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js b/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js new file mode 100644 index 00000000..e721a86a --- /dev/null +++ b/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + intlSegmenterPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Intl.Segmenter instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-intl-segmenter-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...intlSegmenterPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Intl.Segmenter", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-iterator-properties.js b/lib/rules/no-nonstandard-iterator-properties.js new file mode 100644 index 00000000..8bbbdef6 --- /dev/null +++ b/lib/rules/no-nonstandard-iterator-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { iteratorProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Iterator` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-iterator-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...iteratorProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Iterator", allows) + }, +} diff --git a/lib/rules/no-nonstandard-iterator-prototype-properties.js b/lib/rules/no-nonstandard-iterator-prototype-properties.js new file mode 100644 index 00000000..7cefcf50 --- /dev/null +++ b/lib/rules/no-nonstandard-iterator-prototype-properties.js @@ -0,0 +1,48 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { iteratorPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on Iterator instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-iterator-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...iteratorPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Iterator", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-json-properties.js b/lib/rules/no-nonstandard-json-properties.js new file mode 100644 index 00000000..ae164cc3 --- /dev/null +++ b/lib/rules/no-nonstandard-json-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { jsonProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `JSON` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-json-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...jsonProperties, + ]) + return defineNonstandardPropertiesHandler(context, "JSON", allows) + }, +} diff --git a/lib/rules/no-nonstandard-map-properties.js b/lib/rules/no-nonstandard-map-properties.js new file mode 100644 index 00000000..a98ce7a0 --- /dev/null +++ b/lib/rules/no-nonstandard-map-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { mapProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Map` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-map-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...mapProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Map", allows) + }, +} diff --git a/lib/rules/no-nonstandard-map-prototype-properties.js b/lib/rules/no-nonstandard-map-prototype-properties.js new file mode 100644 index 00000000..c5c2a0a5 --- /dev/null +++ b/lib/rules/no-nonstandard-map-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { mapPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Map instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-map-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...mapPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Map", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-math-properties.js b/lib/rules/no-nonstandard-math-properties.js new file mode 100644 index 00000000..666548f4 --- /dev/null +++ b/lib/rules/no-nonstandard-math-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { mathProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Math` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-math-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...mathProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Math", allows) + }, +} diff --git a/lib/rules/no-nonstandard-number-properties.js b/lib/rules/no-nonstandard-number-properties.js new file mode 100644 index 00000000..26718993 --- /dev/null +++ b/lib/rules/no-nonstandard-number-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { numberProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Number` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-number-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...numberProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Number", allows) + }, +} diff --git a/lib/rules/no-nonstandard-number-prototype-properties.js b/lib/rules/no-nonstandard-number-prototype-properties.js new file mode 100644 index 00000000..e9990d7a --- /dev/null +++ b/lib/rules/no-nonstandard-number-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { numberPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Number instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-number-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...numberPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Number", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-object-properties.js b/lib/rules/no-nonstandard-object-properties.js new file mode 100644 index 00000000..b6498b4c --- /dev/null +++ b/lib/rules/no-nonstandard-object-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { objectProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Object` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-object-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...objectProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Object", allows) + }, +} diff --git a/lib/rules/no-nonstandard-promise-properties.js b/lib/rules/no-nonstandard-promise-properties.js new file mode 100644 index 00000000..108fd068 --- /dev/null +++ b/lib/rules/no-nonstandard-promise-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { promiseProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Promise` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-promise-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...promiseProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Promise", allows) + }, +} diff --git a/lib/rules/no-nonstandard-promise-prototype-properties.js b/lib/rules/no-nonstandard-promise-prototype-properties.js new file mode 100644 index 00000000..e3f7ead8 --- /dev/null +++ b/lib/rules/no-nonstandard-promise-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { promisePrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Promise instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-promise-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...promisePrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Promise", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-proxy-properties.js b/lib/rules/no-nonstandard-proxy-properties.js new file mode 100644 index 00000000..e3b08db7 --- /dev/null +++ b/lib/rules/no-nonstandard-proxy-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { proxyProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Proxy` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-proxy-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...proxyProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Proxy", allows) + }, +} diff --git a/lib/rules/no-nonstandard-reflect-properties.js b/lib/rules/no-nonstandard-reflect-properties.js new file mode 100644 index 00000000..efeb74ab --- /dev/null +++ b/lib/rules/no-nonstandard-reflect-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { reflectProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Reflect` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-reflect-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...reflectProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Reflect", allows) + }, +} diff --git a/lib/rules/no-nonstandard-regexp-properties.js b/lib/rules/no-nonstandard-regexp-properties.js new file mode 100644 index 00000000..98678761 --- /dev/null +++ b/lib/rules/no-nonstandard-regexp-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { regexpProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `RegExp` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-regexp-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...regexpProperties, + ]) + return defineNonstandardPropertiesHandler(context, "RegExp", allows) + }, +} diff --git a/lib/rules/no-nonstandard-regexp-prototype-properties.js b/lib/rules/no-nonstandard-regexp-prototype-properties.js new file mode 100644 index 00000000..93be2b9a --- /dev/null +++ b/lib/rules/no-nonstandard-regexp-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { regexpPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on RegExp instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-regexp-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...regexpPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "RegExp", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-set-prototype-properties.js b/lib/rules/no-nonstandard-set-prototype-properties.js new file mode 100644 index 00000000..ce559717 --- /dev/null +++ b/lib/rules/no-nonstandard-set-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { setPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Set instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-set-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...setPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Set", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js b/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js new file mode 100644 index 00000000..237aef66 --- /dev/null +++ b/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js @@ -0,0 +1,50 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + sharedArrayBufferPrototypeProperties, +} = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on SharedArrayBuffer instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-sharedarraybuffer-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...sharedArrayBufferPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "SharedArrayBuffer", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-string-properties.js b/lib/rules/no-nonstandard-string-properties.js new file mode 100644 index 00000000..8624d8e0 --- /dev/null +++ b/lib/rules/no-nonstandard-string-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { stringProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `String` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-string-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...stringProperties, + ]) + return defineNonstandardPropertiesHandler(context, "String", allows) + }, +} diff --git a/lib/rules/no-nonstandard-string-prototype-properties.js b/lib/rules/no-nonstandard-string-prototype-properties.js new file mode 100644 index 00000000..5b5bbd98 --- /dev/null +++ b/lib/rules/no-nonstandard-string-prototype-properties.js @@ -0,0 +1,51 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { stringPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on String instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-string-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...stringPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "String", + allows, + { + // Allow index properties + allowsPropertyName: (name) => /^(?:[1-9]\d*|0)$/u.test(name), + }, + ) + }, +} diff --git a/lib/rules/no-nonstandard-symbol-properties.js b/lib/rules/no-nonstandard-symbol-properties.js new file mode 100644 index 00000000..dd3eaf0d --- /dev/null +++ b/lib/rules/no-nonstandard-symbol-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { symbolProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on `Symbol` class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-symbol-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...symbolProperties, + ]) + return defineNonstandardPropertiesHandler(context, "Symbol", allows) + }, +} diff --git a/lib/rules/no-nonstandard-symbol-prototype-properties.js b/lib/rules/no-nonstandard-symbol-prototype-properties.js new file mode 100644 index 00000000..c597bf09 --- /dev/null +++ b/lib/rules/no-nonstandard-symbol-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { symbolPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on Symbol instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-symbol-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...symbolPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "Symbol", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-typed-array-properties.js b/lib/rules/no-nonstandard-typed-array-properties.js new file mode 100644 index 00000000..13089503 --- /dev/null +++ b/lib/rules/no-nonstandard-typed-array-properties.js @@ -0,0 +1,62 @@ +"use strict" + +const { + defineNonstandardPropertiesHandler, +} = require("../util/define-nonstandard-properties-handler") +const { typedArrayProperties } = require("../util/well-known-properties") + +const typedArrayList = [ + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "BigInt64Array", + "BigUint64Array", +] + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on typed array class", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-typed-array-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...typedArrayProperties, + ]) + return defineNonstandardPropertiesHandler( + context, + typedArrayList, + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-typed-array-prototype-properties.js b/lib/rules/no-nonstandard-typed-array-prototype-properties.js new file mode 100644 index 00000000..401d0058 --- /dev/null +++ b/lib/rules/no-nonstandard-typed-array-prototype-properties.js @@ -0,0 +1,68 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { + typedArrayPrototypeProperties, +} = require("../util/well-known-properties") + +const typedArrayList = [ + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "BigInt64Array", + "BigUint64Array", +] + +module.exports = { + meta: { + docs: { + description: + "disallow non-standard properties on typed array instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-typed-array-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...typedArrayPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + typedArrayList, + allows, + { + // Allow index properties + allowsPropertyName: (name) => /^(?:[1-9]\d*|0)$/u.test(name), + }, + ) + }, +} diff --git a/lib/rules/no-nonstandard-weakmap-prototype-properties.js b/lib/rules/no-nonstandard-weakmap-prototype-properties.js new file mode 100644 index 00000000..9447e41b --- /dev/null +++ b/lib/rules/no-nonstandard-weakmap-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { weakMapPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on WeakMap instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-weakmap-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...weakMapPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "WeakMap", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-weakref-prototype-properties.js b/lib/rules/no-nonstandard-weakref-prototype-properties.js new file mode 100644 index 00000000..28c3647d --- /dev/null +++ b/lib/rules/no-nonstandard-weakref-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { weakRefPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on WeakRef instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-weakref-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...weakRefPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "WeakRef", + allows, + ) + }, +} diff --git a/lib/rules/no-nonstandard-weakset-prototype-properties.js b/lib/rules/no-nonstandard-weakset-prototype-properties.js new file mode 100644 index 00000000..63b54cc7 --- /dev/null +++ b/lib/rules/no-nonstandard-weakset-prototype-properties.js @@ -0,0 +1,47 @@ +"use strict" + +const { + defineNonstandardPrototypePropertiesHandler, +} = require("../util/define-nonstandard-prototype-properties-handler") +const { weakSetPrototypeProperties } = require("../util/well-known-properties") + +module.exports = { + meta: { + docs: { + description: "disallow non-standard properties on WeakSet instance", + category: "nonstandard", + recommended: false, + url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-nonstandard-weakset-prototype-properties.html", + }, + fixable: null, + messages: { + forbidden: "Non-standard '{{name}}' property is forbidden.", + }, + schema: [ + { + type: "object", + properties: { + allow: { + type: "array", + items: { type: "string" }, + uniqueItems: true, + }, + }, + additionalProperties: false, + }, + ], + type: "problem", + }, + create(context) { + /** @type {Set} */ + const allows = new Set([ + ...(context.options[0]?.allow || []), + ...weakSetPrototypeProperties, + ]) + return defineNonstandardPrototypePropertiesHandler( + context, + "WeakSet", + allows, + ) + }, +} diff --git a/lib/util/define-nonstandard-properties-handler/index.js b/lib/util/define-nonstandard-properties-handler/index.js new file mode 100644 index 00000000..5d130b75 --- /dev/null +++ b/lib/util/define-nonstandard-properties-handler/index.js @@ -0,0 +1,73 @@ +"use strict" + +const { + getPropertyName, + ReferenceTracker, + READ, +} = require("@eslint-community/eslint-utils") +const { getSourceCode } = require("eslint-compat-utils") + +/** + * @typedef {import("estree").MemberExpression} MemberExpression + */ + +/** + * Define handlers to disallow non-standard global object properties. + * @param {RuleContext} context The rule context. + * @param {string|string[]} objectNameOrObjectNames The class name to check. + * @param {Iterable} propertyNames The property names to allow. + * @returns {Record void>} The defined handlers. + */ +function defineNonstandardPropertiesHandler( + context, + objectNameOrObjectNames, + propertyNames, +) { + const propertyNamesSet = new Set(propertyNames) + + const classNames = Array.isArray(objectNameOrObjectNames) + ? objectNameOrObjectNames + : [objectNameOrObjectNames] + const traceMap = {} + for (const className of classNames) { + let map = traceMap + for (const name of className.split(".")) { + map = map[name] || (map[name] = {}) + } + map[READ] = true + } + return { + "Program:exit"(program) { + const sourceCode = getSourceCode(context) + const tracker = new ReferenceTracker(sourceCode.getScope(program)) + for (const { node, path } of tracker.iterateGlobalReferences( + traceMap, + )) { + if ( + node.parent.type !== "MemberExpression" || + node.parent.object !== node + ) { + continue + } + const propertyName = getPropertyName( + node.parent, + sourceCode.getScope(node), + ) + if ( + propertyName == null || + propertyNamesSet.has(propertyName) + ) { + continue + } + + context.report({ + node, + messageId: "forbidden", + data: { name: [...path, propertyName].join(".") }, + }) + } + }, + } +} + +module.exports = { defineNonstandardPropertiesHandler } diff --git a/lib/util/define-nonstandard-prototype-properties-handler/index.js b/lib/util/define-nonstandard-prototype-properties-handler/index.js new file mode 100644 index 00000000..b0f5542a --- /dev/null +++ b/lib/util/define-nonstandard-prototype-properties-handler/index.js @@ -0,0 +1,71 @@ +"use strict" + +const { getPropertyName } = require("@eslint-community/eslint-utils") +const { + buildObjectTypeChecker, +} = require("../type-checker/object-type-checker") +const { + buildObjectTypeCheckerForTS, +} = require("../type-checker/object-type-checker-for-ts") +const { getSourceCode } = require("eslint-compat-utils") + +/** + * @typedef {import("estree").MemberExpression} MemberExpression + */ + +/** + * Define handlers to disallow non-standard prototype properties. + * @param {RuleContext} context The rule context. + * @param {string|string[]} classNameOrClassNames The class name to check. + * @param {Iterable} propertyNames The property names to allow. + * @param {object} [options] The options. + * @param {(name: string) => boolean} [options.allowsPropertyName] The function to check whether the property name is allowed. + * @returns {Record void>} The defined handlers. + */ +function defineNonstandardPrototypePropertiesHandler( + context, + classNameOrClassNames, + propertyNames, + options, +) { + const propertyNamesSet = new Set(propertyNames) + const sourceCode = getSourceCode(context) + + const objectTypeChecker = + buildObjectTypeCheckerForTS(context, false) || + buildObjectTypeChecker(context, false) + + const classNames = Array.isArray(classNameOrClassNames) + ? classNameOrClassNames + : [classNameOrClassNames] + return { + MemberExpression(node) { + const propertyName = getPropertyName( + node, + sourceCode.getScope(node), + ) + if ( + propertyName == null || + options?.allowsPropertyName?.(propertyName) || + propertyNamesSet.has(propertyName) + ) { + return + } + for (const className of classNames) { + if (!objectTypeChecker(node, className)) { + continue + } + context.report({ + node, + messageId: "forbidden", + data: { + name: `${className}.prototype.${propertyName}`, + }, + }) + break + } + }, + } +} + +module.exports = { defineNonstandardPrototypePropertiesHandler } diff --git a/lib/util/define-prototype-method-handler/index.js b/lib/util/define-prototype-method-handler/index.js index aff09e23..06762ddc 100644 --- a/lib/util/define-prototype-method-handler/index.js +++ b/lib/util/define-prototype-method-handler/index.js @@ -1,10 +1,17 @@ "use strict" const { getPropertyName } = require("@eslint-community/eslint-utils") -const { buildObjectTypeChecker } = require("./object-type-checker") -const { buildObjectTypeCheckerForTS } = require("./object-type-checker-for-ts") +const { + buildObjectTypeChecker, +} = require("../type-checker/object-type-checker") +const { + buildObjectTypeCheckerForTS, +} = require("../type-checker/object-type-checker-for-ts") const { getSourceCode } = require("eslint-compat-utils") +/** + * @typedef {import("estree").MemberExpression} MemberExpression + */ /** * @typedef {object} CreateReportArgument * @property {true | 'aggressive'} objectTypeResult @@ -33,41 +40,6 @@ function definePrototypeMethodHandler(context, nameMap, options) { buildObjectTypeCheckerForTS(context, aggressiveResult) || buildObjectTypeChecker(context, aggressiveResult) - /** - * Check if the type of the given node is one of given class or not. - * @param {MemberExpression} memberAccessNode The MemberExpression node. - * @param {string} className The class name to disallow. - * @returns {boolean | "aggressive"} `true` if should disallow it. - */ - function checkObjectType(memberAccessNode, className) { - // If it's obvious, shortcut. - if (memberAccessNode.object.type === "ArrayExpression") { - return className === "Array" - } - if ( - memberAccessNode.object.type === "Literal" && - memberAccessNode.object.regex - ) { - return className === "RegExp" - } - if ( - (memberAccessNode.object.type === "Literal" && - typeof memberAccessNode.object.value === "string") || - memberAccessNode.object.type === "TemplateLiteral" - ) { - return className === "String" - } - if ( - memberAccessNode.object.type === "FunctionExpression" || - memberAccessNode.object.type === "ArrowFunctionExpression" - ) { - return className === "Function" - } - - // Test object type. - return objectTypeChecker(memberAccessNode, className) - } - // For performance const nameMapEntries = Object.entries(nameMap) if (nameMapEntries.length === 1) { @@ -81,7 +53,7 @@ function definePrototypeMethodHandler(context, nameMap, options) { let objectTypeResult = undefined if ( methodNames.includes(propertyName) && - (objectTypeResult = checkObjectType(node, className)) + (objectTypeResult = objectTypeChecker(node, className)) ) { context.report({ node, @@ -114,7 +86,7 @@ function definePrototypeMethodHandler(context, nameMap, options) { let objectTypeResult = undefined if ( methodNames.includes(propertyName) && - (objectTypeResult = checkObjectType(node, className)) + (objectTypeResult = objectTypeChecker(node, className)) ) { context.report({ node, diff --git a/lib/util/define-prototype-method-handler/es-types.js b/lib/util/type-checker/es-types.js similarity index 83% rename from lib/util/define-prototype-method-handler/es-types.js rename to lib/util/type-checker/es-types.js index 46188128..4e836e3d 100644 --- a/lib/util/define-prototype-method-handler/es-types.js +++ b/lib/util/type-checker/es-types.js @@ -155,6 +155,20 @@ const WELLKNOWN_GLOBALS = { of: { type: "Function", return: { type: "Array" } }, }, }, + Map: { + type: "Function", + return: { type: "Map" }, + /** @type {Record} */ + properties: { + groupBy: { type: "Function", return: { type: "Map" } }, + }, + }, + Set: { + type: "Function", + return: { type: "Set" }, + /** @type {Record} */ + properties: {}, + }, RegExp: { type: "Function", return: { type: "RegExp" }, @@ -227,6 +241,12 @@ const WELLKNOWN_GLOBALS = { Float64Array: buildGlobalTypedArrayTypeInfo("Float64Array"), BigInt64Array: buildGlobalTypedArrayTypeInfo("BigInt64Array"), BigUint64Array: buildGlobalTypedArrayTypeInfo("BigUint64Array"), + DataView: { + type: "Function", + return: { type: "DataView" }, + /** @type {Record} */ + properties: {}, + }, ArrayBuffer: { type: "Function", return: { type: "ArrayBuffer" }, @@ -241,6 +261,18 @@ const WELLKNOWN_GLOBALS = { /** @type {Record} */ properties: {}, }, + WeakMap: { + type: "Function", + return: { type: "WeakMap" }, + /** @type {Record} */ + properties: {}, + }, + WeakSet: { + type: "Function", + return: { type: "WeakSet" }, + /** @type {Record} */ + properties: {}, + }, Intl: { type: "Object", /** @type {Record} */ @@ -299,6 +331,18 @@ const WELLKNOWN_GLOBALS = { from: { type: "Function", return: { type: "Iterator" } }, }, }, + WeakRef: { + type: "Function", + return: { type: "WeakRef" }, + /** @type {Record} */ + properties: {}, + }, + FinalizationRegistry: { + type: "Function", + return: { type: "FinalizationRegistry" }, + /** @type {Record} */ + properties: {}, + }, undefined: { type: "undefined" }, NaN: { type: "Number" }, Infinity: { type: "Number" }, @@ -468,6 +512,40 @@ const WELLKNOWN_PROTOTYPE = /** @type {WellKnownPrototypes} */ ({ }, /** @type {Record} */ Array: ARRAY_PROPERTIES, + /** @type {Record} */ + Map: { + clear: { type: "Function" }, + delete: RETURN_BOOLEAN, + entries: { type: "Function", return: { type: "Iterator" } }, + forEach: { type: "Function" }, + get: { type: "Function" }, + has: RETURN_BOOLEAN, + keys: { type: "Function", return: { type: "Iterator" } }, + set: { type: "Function" }, + values: { type: "Function", return: { type: "Iterator" } }, + // Properties + size: { type: "Number" }, + }, + /** @type {Record} */ + Set: { + add: { type: "Function" }, + clear: { type: "Function" }, + delete: RETURN_BOOLEAN, + difference: { type: "Function", return: { type: "Set" } }, + entries: { type: "Function", return: { type: "Iterator" } }, + forEach: { type: "Function" }, + has: RETURN_BOOLEAN, + intersection: { type: "Function", return: { type: "Set" } }, + isDisjointFrom: RETURN_BOOLEAN, + isSubsetOf: RETURN_BOOLEAN, + isSupersetOf: RETURN_BOOLEAN, + keys: { type: "Function", return: { type: "Iterator" } }, + symmetricDifference: { type: "Function", return: { type: "Set" } }, + union: { type: "Function", return: { type: "Set" } }, + values: { type: "Function", return: { type: "Iterator" } }, + // Properties + size: { type: "Number" }, + }, /** @type {Record} */ RegExp: { compile: { type: "Function" }, @@ -553,6 +631,33 @@ const WELLKNOWN_PROTOTYPE = /** @type {WellKnownPrototypes} */ ({ Float64Array: buildTypedArrayPrototypeTypeInfo("Float64Array"), BigInt64Array: buildTypedArrayPrototypeTypeInfo("BigInt64Array"), BigUint64Array: buildTypedArrayPrototypeTypeInfo("BigUint64Array"), + /** @type {Record} */ + DataView: { + getBigInt64: { type: "Function", return: { type: "BigInt" } }, + getBigUint64: { type: "Function", return: { type: "BigInt" } }, + getFloat32: { type: "Function", return: { type: "Number" } }, + getFloat64: { type: "Function", return: { type: "Number" } }, + getInt16: { type: "Function", return: { type: "Number" } }, + getInt32: { type: "Function", return: { type: "Number" } }, + getInt8: { type: "Function", return: { type: "Number" } }, + getUint16: { type: "Function", return: { type: "Number" } }, + getUint32: { type: "Function", return: { type: "Number" } }, + getUint8: { type: "Function", return: { type: "Number" } }, + setBigInt64: { type: "Function" }, + setBigUint64: { type: "Function" }, + setFloat32: { type: "Function" }, + setFloat64: { type: "Function" }, + setInt16: { type: "Function" }, + setInt32: { type: "Function" }, + setInt8: { type: "Function" }, + setUint16: { type: "Function" }, + setUint32: { type: "Function" }, + setUint8: { type: "Function" }, + // Properties + byteLength: { type: "Number" }, + byteOffset: { type: "Number" }, + buffer: { type: "ArrayBuffer" }, + }, /** @type {Record} */ ArrayBuffer: { resize: { type: "Function" }, @@ -577,6 +682,19 @@ const WELLKNOWN_PROTOTYPE = /** @type {WellKnownPrototypes} */ ({ growable: { type: "Boolean" }, maxByteLength: { type: "Number" }, }, + /** @type {Record} */ + WeakMap: { + delete: RETURN_BOOLEAN, + get: { type: "Function" }, + has: RETURN_BOOLEAN, + set: { type: "Function" }, + }, + /** @type {Record} */ + WeakSet: { + add: { type: "Function" }, + delete: RETURN_BOOLEAN, + has: RETURN_BOOLEAN, + }, /** @type {Record} */ Iterator: { next: { type: "Function" }, @@ -595,6 +713,15 @@ const WELLKNOWN_PROTOTYPE = /** @type {WellKnownPrototypes} */ ({ every: RETURN_BOOLEAN, find: { type: "Function" }, }, + /** @type {Record} */ + WeakRef: { + deref: { type: "Function" }, + }, + /** @type {Record} */ + FinalizationRegistry: { + register: { type: "Function" }, + unregister: RETURN_BOOLEAN, + }, }) /** diff --git a/lib/util/define-prototype-method-handler/object-type-checker-for-ts.js b/lib/util/type-checker/object-type-checker-for-ts.js similarity index 85% rename from lib/util/define-prototype-method-handler/object-type-checker-for-ts.js rename to lib/util/type-checker/object-type-checker-for-ts.js index 1760665e..e5ff391b 100644 --- a/lib/util/define-prototype-method-handler/object-type-checker-for-ts.js +++ b/lib/util/type-checker/object-type-checker-for-ts.js @@ -2,6 +2,7 @@ const { getSourceCode } = require("eslint-compat-utils") const { optionalRequire } = require("../optional-require") +const { checkExpressionNodeType } = require("./utils") /** @type {import("typescript")} */ const ts = optionalRequire(require, "typescript") @@ -14,7 +15,7 @@ module.exports = { buildObjectTypeCheckerForTS } /** * Build object type checker for TypeScript. * @param {RuleContext} context The rule context. - * @param {boolean} aggressiveResult The value to return if the type cannot be determined. + * @param {boolean | "aggressive"} aggressiveResult The value to return if the type cannot be determined. * @returns {((memberAccessNode: MemberExpression, className: string) => boolean | "aggressive") | null} Returns an object type checker. Returns null if TypeScript is not available. */ function buildObjectTypeCheckerForTS(context, aggressiveResult) { @@ -35,8 +36,9 @@ function buildObjectTypeCheckerForTS(context, aggressiveResult) { return function (memberAccessNode, className) { return ( - checkByPropertyDeclaration(memberAccessNode, className) || - checkByObjectExpressionType(memberAccessNode, className) + checkExpressionNodeType(memberAccessNode.object, className) ?? + (checkByPropertyDeclaration(memberAccessNode, className) || + checkByObjectExpressionType(memberAccessNode, className)) ) } @@ -81,6 +83,7 @@ function buildObjectTypeCheckerForTS(context, aggressiveResult) { * @param {string} className The expected type name. * @returns {boolean} `true` if should disallow it. */ + // eslint-disable-next-line complexity function typeEquals(type, className) { // console.log( // "typeEquals(%o, %o)", @@ -134,6 +137,18 @@ function buildObjectTypeCheckerForTS(context, aggressiveResult) { if (isStringLike(type)) { return className === "String" } + if (isNumberLike(type)) { + return className === "Number" + } + if (isBooleanLike(type)) { + return className === "Boolean" + } + if (isBigIntLike(type)) { + return className === "BigInt" + } + if (isSymbolLike(type)) { + return className === "Symbol" + } if (isArrayLikeObject(type)) { return className === "Array" } @@ -278,6 +293,42 @@ function isStringLike(type) { return (type.flags & ts.TypeFlags.StringLike) !== 0 } +/** + * Check if a given type is a number-like type or not. + * @param {import("typescript").Type} type The type to check. + * @returns {boolean} `true` if the type is a number-like type. + */ +function isNumberLike(type) { + return (type.flags & ts.TypeFlags.NumberLike) !== 0 +} + +/** + * Check if a given type is a boolean-like type or not. + * @param {import("typescript").Type} type The type to check. + * @returns {boolean} `true` if the type is a boolean-like type. + */ +function isBooleanLike(type) { + return (type.flags & ts.TypeFlags.BooleanLike) !== 0 +} + +/** + * Check if a given type is a bigint-like type or not. + * @param {import("typescript").Type} type The type to check. + * @returns {boolean} `true` if the type is a bigint-like type. + */ +function isBigIntLike(type) { + return (type.flags & ts.TypeFlags.BigIntLike) !== 0 +} + +/** + * Check if a given type is a symbol-like type or not. + * @param {import("typescript").Type} type The type to check. + * @returns {boolean} `true` if the type is a symbol-like type. + */ +function isSymbolLike(type) { + return (type.flags & ts.TypeFlags.ESSymbolLike) !== 0 +} + /** * Check if a given type is a type parameter type or not. * @param {import("typescript").Type} type The type to check. diff --git a/lib/util/define-prototype-method-handler/object-type-checker.js b/lib/util/type-checker/object-type-checker.js similarity index 97% rename from lib/util/define-prototype-method-handler/object-type-checker.js rename to lib/util/type-checker/object-type-checker.js index a320033a..6713ee2f 100644 --- a/lib/util/define-prototype-method-handler/object-type-checker.js +++ b/lib/util/type-checker/object-type-checker.js @@ -6,6 +6,7 @@ const { } = require("@eslint-community/eslint-utils") const { getSourceCode } = require("eslint-compat-utils") const { WELLKNOWN_GLOBALS, getPropertyType } = require("./es-types") +const { checkExpressionNodeType } = require("./utils") module.exports = { buildObjectTypeChecker, buildExpressionTypeProvider } @@ -25,12 +26,20 @@ module.exports = { buildObjectTypeChecker, buildExpressionTypeProvider } /** * Build object type checker. * @param {RuleContext} context The rule context. - * @param {boolean} aggressiveResult The value to return if the type cannot be determined. - * @returns {((memberAccessNode: MemberExpression, className: string) => boolean)} Returns an object type checker. + * @param {boolean | "aggressive"} aggressiveResult The value to return if the type cannot be determined. + * @returns {((memberAccessNode: MemberExpression, className: string) => boolean | "aggressive")} Returns an object type checker. */ function buildObjectTypeChecker(context, aggressiveResult) { const getType = buildExpressionTypeProvider(context) return function (memberAccessNode, className) { + const result = checkExpressionNodeType( + memberAccessNode.object, + className, + ) + if (result != null) { + return result + } + const type = getType(memberAccessNode.object) if (type == null) { return aggressiveResult @@ -71,6 +80,7 @@ function buildExpressionTypeProviderImpl(context) { Literal: getLiteralTypeInfo, TemplateLiteral: () => ({ type: "String" }), Identifier: getIdentifierTypeInfo, + ImportExpression: () => ({ type: "Promise" }), MemberExpression: getMemberExpressionTypeInfo, /** @param {import("estree").BinaryExpression} node */ BinaryExpression: (node) => diff --git a/lib/util/define-prototype-method-handler/types.d.ts b/lib/util/type-checker/types.d.ts similarity index 76% rename from lib/util/define-prototype-method-handler/types.d.ts rename to lib/util/type-checker/types.d.ts index 0b589270..9a58a639 100644 --- a/lib/util/define-prototype-method-handler/types.d.ts +++ b/lib/util/type-checker/types.d.ts @@ -26,6 +26,7 @@ export type TypeName = | "Float64Array" | "BigInt64Array" | "BigUint64Array" + | "DataView" | "ArrayBuffer" | "SharedArrayBuffer" | "Object" @@ -33,6 +34,12 @@ export type TypeName = | "Boolean" | "BigInt" | "Iterator" + | "Map" + | "Set" + | "WeakMap" + | "WeakSet" + | "WeakRef" + | "FinalizationRegistry" | "null" | "undefined"; @@ -104,6 +111,16 @@ export type ArrayPrototypeProperty = Exclude< keyof Array, ExcludePrototypeProperty >; +export type MapProperty = Exclude; +export type MapPrototypeProperty = Exclude< + keyof Map, + ExcludePrototypeProperty +>; +export type SetProperty = Exclude; +export type SetPrototypeProperty = Exclude< + keyof Set, + ExcludePrototypeProperty +>; export type RegExpProperty = Exclude; export type RegExpPrototypeProperty = Exclude< keyof RegExp, @@ -126,6 +143,14 @@ export type PromisePrototypeProperty = Exclude< keyof Promise, ExcludePrototypeProperty >; +export type DataViewProperty = Exclude< + keyof typeof DataView, + ExcludeProperty +>; +export type DataViewPrototypeProperty = Exclude< + keyof DataView, + ExcludePrototypeProperty +>; export type ArrayBufferProperty = Exclude< keyof typeof ArrayBuffer, ExcludeProperty @@ -147,6 +172,26 @@ export type SharedArrayBufferPrototypeProperty = | "grow" | "growable" | "maxByteLength"; +export type WeakMapProperty = Exclude; +export type WeakMapPrototypeProperty = Exclude< + keyof WeakMap, + ExcludePrototypeProperty +>; +export type WeakSetProperty = Exclude; +export type WeakSetPrototypeProperty = Exclude< + keyof WeakSet, + ExcludePrototypeProperty +>; +export type WeakRefProperty = Exclude; +export type WeakRefPrototypeProperty = Exclude< + keyof WeakRef, + ExcludePrototypeProperty +>; +export type FinalizationRegistryProperty = Exclude; +export type FinalizationRegistryPrototypeProperty = Exclude< + keyof FinalizationRegistry, + ExcludePrototypeProperty +>; export type IntlProperty = Exclude; export type IteratorProperty = Exclude; export type IteratorPrototypeProperty = Exclude< diff --git a/lib/util/type-checker/utils.js b/lib/util/type-checker/utils.js new file mode 100644 index 00000000..b0f27ac1 --- /dev/null +++ b/lib/util/type-checker/utils.js @@ -0,0 +1,53 @@ +"use strict" + +module.exports = { checkExpressionNodeType } + +/** + * @typedef {import("estree").Expression} Expression + * @typedef {import("estree").Super} Super + */ +/** + * Check if the type of the given node is given class or not. + * @param {Expression | Super} node The expression node. + * @param {string} className The class name to disallow. + * @returns {boolean | null} `true` if should disallow it. + */ +function checkExpressionNodeType(node, className) { + // If it's obvious, shortcut. + if (node.type === "ArrayExpression") { + return className === "Array" + } + if (node.type === "Literal") { + if (node.regex) { + return className === "RegExp" + } + if (node.bigint) { + return className === "BigInt" + } + if (typeof node.value === "string") { + return className === "String" + } + if (typeof node.value === "number") { + return className === "Number" + } + if (typeof node.value === "boolean") { + return className === "Boolean" + } + return false + } + if (node.type === "TemplateLiteral") { + return className === "String" + } + if ( + node.type === "FunctionExpression" || + node.type === "ArrowFunctionExpression" || + node.type === "ClassExpression" + ) { + return className === "Function" + } + if (node.type === "UpdateExpression") { + return className === "Number" + } + + return null +} diff --git a/lib/util/well-known-properties.js b/lib/util/well-known-properties.js new file mode 100644 index 00000000..3a5279c7 --- /dev/null +++ b/lib/util/well-known-properties.js @@ -0,0 +1,1216 @@ +"use strict" + +const objectPrototypeProperties = new Set([ + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-object-prototype-object + "constructor", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "toLocaleString", + "toString", + "valueOf", + "__proto__", + "__defineGetter__", + "__defineSetter__", + "__lookupGetter__", + "__lookupSetter__", +]) + +const functionPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-function-prototype-object + + "apply", + "bind", + "call", + "constructor", + "toString", + // [ %Symbol.hasInstance% ] + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-function-instances + "length", + "name", + "prototype", +]) + +const objectProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-object-constructor + "assign", + "create", + "defineProperties", + "defineProperty", + "entries", + "freeze", + "fromEntries", + "getOwnPropertyDescriptor", + "getOwnPropertyDescriptors", + "getOwnPropertyNames", + "getOwnPropertySymbols", + "getPrototypeOf", + "groupBy", + "hasOwn", + "is", + "isExtensible", + "isFrozen", + "isSealed", + "keys", + "preventExtensions", + "prototype", + "seal", + "setPrototypeOf", + "values", +]) + +const functionProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-function-constructor + "prototype", +]) + +const booleanProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-boolean-constructor + "prototype", +]) + +const booleanPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-boolean-prototype-object + "constructor", + "toString", + "valueOf", +]) + +const symbolProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-symbol-constructor + "asyncIterator", + "for", + "hasInstance", + "isConcatSpreadable", + "iterator", + "keyFor", + "match", + "matchAll", + "prototype", + "replace", + "search", + "species", + "split", + "toPrimitive", + "toStringTag", + "unscopables", +]) + +const symbolPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-symbol-prototype-object + "description", + "toString", + "valueOf", + // [ %Symbol.toPrimitive% ] + // [ %Symbol.toStringTag% ] +]) + +const errorProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-error-constructor + "prototype", +]) + +const errorPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-properties-of-the-error-prototype-object + "constructor", + "message", + "name", + "toString", +]) + +const numberProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-properties-of-the-number-constructor + "EPSILON", + "isFinite", + "isInteger", + "isNaN", + "isSafeInteger", + "MAX_SAFE_INTEGER", + "MAX_VALUE", + "MIN_SAFE_INTEGER", + "MIN_VALUE", + "NaN", + "NEGATIVE_INFINITY", + "parseFloat", + "parseInt", + "POSITIVE_INFINITY", + "prototype", +]) + +const numberPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-properties-of-the-number-prototype-object + "constructor", + "toExponential", + "toFixed", + "toLocaleString", + "toPrecision", + "toString", + "valueOf", +]) + +const bigintProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-properties-of-the-bigint-constructor + "asIntN", + "asUintN", + "prototype", +]) + +const bigintPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-properties-of-the-bigint-prototype-object + "constructor", + "toLocaleString", + "toString", + "valueOf", +]) + +const mathProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-value-properties-of-the-math-object + "E", + "LN10", + "LN2", + "LOG10E", + "LOG2E", + "PI", + "SQRT1_2", + "SQRT2", + // [ %Symbol.toStringTag% ] + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-function-properties-of-the-math-object + "abs", + "acos", + "acosh", + "asin", + "asinh", + "atan", + "atanh", + "atan2", + "cbrt", + "ceil", + "clz32", + "cos", + "cosh", + "exp", + "expm1", + "floor", + "fround", + "hypot", + "imul", + "log", + "log1p", + "log10", + "log2", + "max", + "min", + "pow", + "random", + "round", + "sign", + "sin", + "sinh", + "sqrt", + "tan", + "tanh", + "trunc", +]) + +const dateProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-properties-of-the-date-constructor + "now", + "parse", + "prototype", + "UTC", +]) + +const datePrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-properties-of-the-date-prototype-object + "constructor", + "getDate", + "getDay", + "getFullYear", + "getHours", + "getMilliseconds", + "getMinutes", + "getMonth", + "getSeconds", + "getTime", + "getTimezoneOffset", + "getUTCDate", + "getUTCDay", + "getUTCFullYear", + "getUTCHours", + "getUTCMilliseconds", + "getUTCMinutes", + "getUTCMonth", + "getUTCSeconds", + "setDate", + "setFullYear", + "setHours", + "setMilliseconds", + "setMinutes", + "setMonth", + "setSeconds", + "setTime", + "setUTCDate", + "setUTCFullYear", + "setUTCHours", + "setUTCMilliseconds", + "setUTCMinutes", + "setUTCMonth", + "setUTCSeconds", + "toDateString", + "toISOString", + "toJSON", + "toLocaleDateString", + "toLocaleString", + "toLocaleTimeString", + "toString", + "toTimeString", + "toUTCString", + "valueOf", + // [ %Symbol.toPrimitive% ] + + // https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-additional-properties-of-the-date.prototype-object + "getYear", + "setYear", + "toGMTString", +]) + +const stringProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/text-processing.html#sec-properties-of-the-string-constructor + "fromCharCode", + "fromCodePoint", + "prototype", + "raw", +]) + +const stringPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/text-processing.html#sec-properties-of-the-string-prototype-object + "at", + "charAt", + "charCodeAt", + "codePointAt", + "concat", + "constructor", + "endsWith", + "includes", + "indexOf", + "isWellFormed", + "lastIndexOf", + "localeCompare", + "match", + "matchAll", + "normalize", + "padEnd", + "padStart", + "repeat", + "replace", + "replaceAll", + "search", + "slice", + "split", + "startsWith", + "substring", + "toLocaleLowerCase", + "toLocaleUpperCase", + "toLowerCase", + "toString", + "toUpperCase", + "toWellFormed", + "trim", + "trimEnd", + "trimStart", + "valueOf", + // [ %Symbol.iterator% ] + + // https://tc39.es/ecma262/multipage/text-processing.html#sec-properties-of-string-instances + "length", + + // https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-additional-properties-of-the-string.prototype-object + "substr", + "anchor", + "big", + "blink", + "bold", + "fixed", + "fontcolor", + "fontsize", + "italics", + "link", + "small", + "strike", + "sub", + "sup", + "trimLeft", + "trimRight", +]) + +const regexpProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/text-processing.html#sec-properties-of-the-regexp-constructor + "prototype", + // [ %Symbol.species% ] + + // https://github.com/tc39/proposal-regexp-legacy-features/ + "input", + "$_", + "lastMatch", + "$&", + "lastParen", + "$+", + "leftContext", + "$`", + "rightContext", + "$'", + "$1", + "$2", + "$3", + "$4", + "$5", + "$6", + "$7", + "$8", + "$9", +]) + +const regexpPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/text-processing.html#sec-properties-of-the-regexp-prototype-object + "constructor", + "exec", + "dotAll", + "flags", + "global", + "hasIndices", + "ignoreCase", + // [ %Symbol.match% ] + // [ %Symbol.matchAll% ] + "multiline", + // [ %Symbol.replace% ] + // [ %Symbol.search% ] + "source", + // [ %Symbol.split% ] + "sticky", + "test", + "toString", + "unicode", + "unicodeSets", + + // https://tc39.es/ecma262/multipage/text-processing.html#sec-properties-of-regexp-instances + "lastIndex", + + // https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-additional-properties-of-the-regexp.prototype-object + "compile", +]) + +const arrayProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-the-array-constructor + "from", + "isArray", + "of", + "prototype", + // [ %Symbol.species% ] +]) + +const arrayPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-the-array-prototype-object + "at", + "concat", + "constructor", + "copyWithin", + "entries", + "every", + "fill", + "filter", + "find", + "findIndex", + "findLast", + "findLastIndex", + "flat", + "flatMap", + "forEach", + "includes", + "indexOf", + "join", + "keys", + "lastIndexOf", + "map", + "pop", + "push", + "reduce", + "reduceRight", + "reverse", + "shift", + "slice", + "some", + "sort", + "splice", + "toLocaleString", + "toReversed", + "toSorted", + "toSpliced", + "toString", + "unshift", + "values", + "with", + // [ %Symbol.iterator% ] + // [ %Symbol.unscopables% ] + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-array-instances + "length", + + // RegExp results + // https://tc39.es/ecma262/multipage/text-processing.html#sec-regexpbuiltinexec + "index", + "input", + "groups", + "indices", +]) + +const typedArrayProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-the-%typedarray%-intrinsic-object + "from", + "of", + "prototype", + // [ %Symbol.species% ] + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-the-typedarray-constructors + "BYTES_PER_ELEMENT", + "prototype", +]) + +const typedArrayPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-the-%typedarrayprototype%-object + "at", + "buffer", + "byteLength", + "byteOffset", + "constructor", + "copyWithin", + "entries", + "every", + "fill", + "filter", + "find", + "findIndex", + "findLast", + "findLastIndex", + "forEach", + "includes", + "indexOf", + "join", + "keys", + "lastIndexOf", + "length", + "map", + "reduce", + "reduceRight", + "reverse", + "set", + "slice", + "some", + "sort", + "subarray", + "toLocaleString", + "toReversed", + "toSorted", + "toString", + "values", + "with", + // [ %Symbol.iterator% ] + // [ %Symbol.toStringTag% ] + + // https://tc39.es/ecma262/multipage/indexed-collections.html#sec-properties-of-typedarray-prototype-objects + "BYTES_PER_ELEMENT", + "constructor", +]) + +const mapProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-map-constructor + "groupBy", + "prototype", + // [ %Symbol.species% ] +]) + +const mapPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-map-prototype-object + "clear", + "constructor", + "delete", + "entries", + "forEach", + "get", + "has", + "keys", + "set", + "size", + "values", + // [ %Symbol.iterator% ] + // [ %Symbol.toStringTag% ] +]) + +const setProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-set-constructor + "prototype", + // [ %Symbol.species% ] +]) + +const setPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-set-prototype-object + "add", + "clear", + "constructor", + "delete", + "difference", + "entries", + "forEach", + "has", + "intersection", + "isDisjointFrom", + "isSubsetOf", + "isSupersetOf", + "keys", + "size", + "symmetricDifference", + "union", + "values", + // [ %Symbol.iterator% ] + // [ %Symbol.toStringTag% ] +]) + +const weakMapProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-weakmap-constructor + "prototype", + // [ %Symbol.species% ] +]) + +const weakMapPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-weakmap-prototype-object + "constructor", + "delete", + "get", + "has", + "set", + // [ %Symbol.toStringTag% ] +]) + +const weakSetProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-weakset-constructor + "prototype", + // [ %Symbol.species% ] +]) + +const weakSetPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/keyed-collections.html#sec-properties-of-the-weakset-prototype-object + "add", + "constructor", + "delete", + "has", + // [ %Symbol.toStringTag% ] +]) + +const arrayBufferProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-properties-of-the-arraybuffer-constructor + "isView", + "prototype", + // [ %Symbol.species% ] +]) + +const arrayBufferPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-properties-of-the-arraybuffer-prototype-object + "byteLength", + "constructor", + "detached", + "maxByteLength", + "resizable", + "resize", + "slice", + "transfer", + "transferToFixedLength", + // [ %Symbol.toStringTag% ] +]) + +const sharedArrayBufferProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-properties-of-the-sharedarraybuffer-constructor + "prototype", + // [ %Symbol.species% ] +]) + +const sharedArrayBufferPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-properties-of-the-sharedarraybuffer-prototype-object + "byteLength", + "constructor", + "grow", + "growable", + "maxByteLength", + "slice", + // [ %Symbol.toStringTag% ] +]) + +const dataViewProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-properties-of-the-dataview-constructor + "prototype", + // [ %Symbol.species% ] +]) + +const dataViewPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-properties-of-the-dataview-prototype-object + "buffer", + "byteLength", + "byteOffset", + "constructor", + "getBigInt64", + "getBigUint64", + "getFloat32", + "getFloat64", + "getInt8", + "getInt16", + "getInt32", + "getUint8", + "getUint16", + "getUint32", + "setBigInt64", + "setBigUint64", + "setFloat32", + "setFloat64", + "setInt8", + "setInt16", + "setInt32", + "setUint8", + "setUint16", + "setUint32", + // [ %Symbol.toStringTag% ] +]) + +const atomicsProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-atomics-object + "add", + "and", + "compareExchange", + "exchange", + "isLockFree", + "load", + "or", + "store", + "sub", + "wait", + "waitAsync", + "notify", + "xor", + // [ %Symbol.toStringTag% ] +]) + +const jsonProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/structured-data.html#sec-json-object + "parse", + "stringify", + // [ %Symbol.toStringTag% ] +]) + +const weakRefProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/managing-memory.html#sec-properties-of-the-weak-ref-constructor + "prototype", +]) + +const weakRefPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/managing-memory.html#sec-properties-of-the-weak-ref-prototype-object + "constructor", + "deref", + // [ %Symbol.toStringTag% ] +]) + +const finalizationRegistryProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/managing-memory.html#sec-properties-of-the-finalization-registry-constructor + "prototype", +]) + +const finalizationRegistryPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/managing-memory.html#sec-properties-of-the-finalization-registry-prototype-object + "constructor", + "register", + "unregister", + // [ %Symbol.toStringTag% ] +]) + +const iteratorProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-properties-of-the-iterator-constructor + "from", + "prototype", +]) + +const iteratorPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iterator.prototype%-object + "constructor", + "drop", + "every", + "filter", + "find", + "flatMap", + "forEach", + "map", + "reduce", + "some", + "take", + "toArray", + // [ %Symbol.iterator% ] + // [ %Symbol.toStringTag% ] + + // https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-asynciteratorprototype + // [ %Symbol.asyncIterator%% ] +]) + +const promiseProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-properties-of-the-promise-constructor + "all", + "allSettled", + "any", + "prototype", + "race", + "reject", + "resolve", + "try", + "withResolvers", + // [ %Symbol.species% ] +]) + +const promisePrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-properties-of-the-promise-prototype-object + "catch", + "constructor", + "finally", + "then", + // [ %Symbol.toStringTag% ] +]) + +const reflectProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma262/multipage/reflection.html#sec-reflect-object + "apply", + "construct", + "defineProperty", + "deleteProperty", + "get", + "getOwnPropertyDescriptor", + "getPrototypeOf", + "has", + "isExtensible", + "ownKeys", + "preventExtensions", + "set", + "setPrototypeOf", + // [ %Symbol.toStringTag% ] +]) + +const proxyProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma262/multipage/reflection.html#sec-proxy-objects + "revocable", +]) + +const intlProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#intl-object + // [ %Symbol.toStringTag% ] + + // https://tc39.es/ecma402/#sec-constructor-properties-of-the-intl-object + "Collator", + "DateTimeFormat", + "DisplayNames", + "ListFormat", + "Locale", + "NumberFormat", + "PluralRules", + "RelativeTimeFormat", + "Segmenter", + + // https://tc39.es/ecma402/#sec-function-properties-of-the-intl-object + "getCanonicalLocales", + "supportedValuesOf", +]) + +const intlCollatorProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-the-intl-collator-constructor + "prototype", + "supportedLocalesOf", + // [ %Symbol.toStringTag% ] +]) + +const intlCollatorPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-the-intl-collator-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "compare", + "resolvedOptions", +]) + +const intlDateTimeFormatProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlDateTimeFormatPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "format", + "formatToParts", + "formatRange", + "formatRangeToParts", + "resolvedOptions", +]) + +const intlDisplayNamesProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlDisplayNamesPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "of", + "resolvedOptions", +]) + +const intlListFormatProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-listformat-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlListFormatPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "format", + "formatToParts", + "resolvedOptions", +]) + +const intlLocaleProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-locale-constructor + "prototype", +]) + +const intlLocalePrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "maximize", + "minimize", + "toString", + "baseName", + "calendar", + "caseFirst", + "collation", + "hourCycle", + "numeric", + "numberingSystem", + "language", + "script", + "region", +]) + +const intlNumberFormatProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlNumberFormatPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "format", + "formatToParts", + "formatRange", + "formatRangeToParts", + "resolvedOptions", +]) + +const intlPluralRulesProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlPluralRulesPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "select", + "selectRange", + "resolvedOptions", +]) + +const intlRelativeTimeFormatProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlRelativeTimeFormatPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "format", + "formatToParts", + "resolvedOptions", +]) + +const intlSegmenterProperties = new Set([ + ...objectPrototypeProperties, + ...functionPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-constructor + "prototype", + "supportedLocalesOf", +]) + +const intlSegmenterPrototypeProperties = new Set([ + ...objectPrototypeProperties, + + // https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object + "constructor", + // [ %Symbol.toStringTag% ] + "segment", + "resolvedOptions", +]) + +module.exports = { + // ECMA 262 ECMAScript Language Specification + objectProperties, + objectPrototypeProperties, + functionProperties, + functionPrototypeProperties, + booleanProperties, + booleanPrototypeProperties, + symbolProperties, + symbolPrototypeProperties, + errorProperties, + errorPrototypeProperties, + numberProperties, + numberPrototypeProperties, + bigintProperties, + bigintPrototypeProperties, + mathProperties, + dateProperties, + datePrototypeProperties, + stringProperties, + stringPrototypeProperties, + regexpProperties, + regexpPrototypeProperties, + arrayProperties, + arrayPrototypeProperties, + typedArrayProperties, + typedArrayPrototypeProperties, + mapProperties, + mapPrototypeProperties, + setProperties, + setPrototypeProperties, + weakMapProperties, + weakMapPrototypeProperties, + weakSetProperties, + weakSetPrototypeProperties, + arrayBufferProperties, + arrayBufferPrototypeProperties, + sharedArrayBufferProperties, + sharedArrayBufferPrototypeProperties, + dataViewProperties, + dataViewPrototypeProperties, + atomicsProperties, + jsonProperties, + weakRefProperties, + weakRefPrototypeProperties, + finalizationRegistryProperties, + finalizationRegistryPrototypeProperties, + iteratorProperties, + iteratorPrototypeProperties, + promiseProperties, + promisePrototypeProperties, + reflectProperties, + proxyProperties, + // ECMA 402 ECMAScript Internationalization API + intlProperties, + intlCollatorProperties, + intlCollatorPrototypeProperties, + intlDateTimeFormatProperties, + intlDateTimeFormatPrototypeProperties, + intlDisplayNamesProperties, + intlDisplayNamesPrototypeProperties, + intlListFormatProperties, + intlListFormatPrototypeProperties, + intlLocaleProperties, + intlLocalePrototypeProperties, + intlNumberFormatProperties, + intlNumberFormatPrototypeProperties, + intlPluralRulesProperties, + intlPluralRulesPrototypeProperties, + intlRelativeTimeFormatProperties, + intlRelativeTimeFormatPrototypeProperties, + intlSegmenterProperties, + intlSegmenterPrototypeProperties, +} diff --git a/scripts/rules.js b/scripts/rules.js index b416a4d4..4a4b646d 100644 --- a/scripts/rules.js +++ b/scripts/rules.js @@ -100,6 +100,13 @@ categories.legacy = { "Rules in this category disallow the syntax contained in [Annex B](https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html) or Legacy.", rules: [], } +categories.nonstandard = { + id: "nonstandard", + title: "Non-standards", + comment: + "Rules in this category disallow features that are not defined in ECMAScript.", + rules: [], +} categories.uncategorized = { id: "uncategorized", title: "Uncategorized", diff --git a/tests/lib/configs/flat/flat-config.mjs b/tests/lib/configs/flat/flat-config.mjs index 484825f0..13dfe811 100644 --- a/tests/lib/configs/flat/flat-config.mjs +++ b/tests/lib/configs/flat/flat-config.mjs @@ -9,9 +9,8 @@ import pluginESx from "../../../../lib/index.js" if (eslintModule.loadESLint) { const dirname = path.dirname(new URL(import.meta.url).pathname) - const TEST_CWD = path.join( - dirname, - "../../fixtures/integrations/eslint-plugin", + const TEST_CWD = path.resolve( + path.join(dirname, "../../fixtures/integrations/eslint-plugin"), ) describe("ESM flat config", () => { diff --git a/tests/lib/rules/no-nonstandard-array-properties.js b/tests/lib/rules/no-nonstandard-array-properties.js new file mode 100644 index 00000000..6b815f71 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-array-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-array-properties.js") +const { arrayProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-array-properties", rule, { + valid: [ + ...[...arrayProperties].map((p) => `Array.${p}`), + { code: "Array.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Array.unknown()", + errors: ["Non-standard 'Array.unknown' property is forbidden."], + }, + { + code: "Array.foo", + errors: ["Non-standard 'Array.foo' property is forbidden."], + }, + { + code: "Array.bar", + errors: ["Non-standard 'Array.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-array-prototype-properties.js b/tests/lib/rules/no-nonstandard-array-prototype-properties.js new file mode 100644 index 00000000..32109a3a --- /dev/null +++ b/tests/lib/rules/no-nonstandard-array-prototype-properties.js @@ -0,0 +1,127 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-array-prototype-properties.js") +const { + arrayPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-array-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...arrayPrototypeProperties].map((p) => `['A'].${p}`), + "['A'][0]", + "['A']['0']", + { code: "['A'].unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "['A'].unknown()", + errors: [ + "Non-standard 'Array.prototype.unknown' property is forbidden.", + ], + }, + { + code: "['A'].foo", + errors: [ + "Non-standard 'Array.prototype.foo' property is forbidden.", + ], + }, + { + code: "['A'].bar", + errors: [ + "Non-standard 'Array.prototype.bar' property is forbidden.", + ], + }, + { + code: "['A']['01']", + errors: [ + "Non-standard 'Array.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...arrayPrototypeProperties].map((p) => ({ + filename, + code: `['A'].${p}`, + })), + { filename, code: "['A'][0]" }, + { filename, code: "['A']['0']" }, + { + filename, + code: "let foo = /re/.exec('re'); foo.index", + }, + ], + invalid: [ + { + filename, + code: "['A'].foo", + errors: [ + "Non-standard 'Array.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "['A'].bar", + errors: [ + "Non-standard 'Array.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "['A']['01']", + errors: [ + "Non-standard 'Array.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = ['A']; foo.foo", + errors: [ + "Non-standard 'Array.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Array(''); foo.bar", + errors: [ + "Non-standard 'Array.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Array.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-arraybuffer-properties.js b/tests/lib/rules/no-nonstandard-arraybuffer-properties.js new file mode 100644 index 00000000..d80ce4f5 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-arraybuffer-properties.js @@ -0,0 +1,30 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-arraybuffer-properties.js") +const { + arrayBufferProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-arraybuffer-properties", rule, { + valid: [ + ...[...arrayBufferProperties].map((p) => `ArrayBuffer.${p}`), + { code: "ArrayBuffer.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "ArrayBuffer.unknown()", + errors: [ + "Non-standard 'ArrayBuffer.unknown' property is forbidden.", + ], + }, + { + code: "ArrayBuffer.foo", + errors: ["Non-standard 'ArrayBuffer.foo' property is forbidden."], + }, + { + code: "ArrayBuffer.bar", + errors: ["Non-standard 'ArrayBuffer.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js b/tests/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js new file mode 100644 index 00000000..ec2ee773 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-arraybuffer-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-arraybuffer-prototype-properties.js") +const { + arrayBufferPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-arraybuffer-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...arrayBufferPrototypeProperties].map( + (p) => `new ArrayBuffer().${p}`, + ), + { + code: "new ArrayBuffer().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new ArrayBuffer().unknown()", + errors: [ + "Non-standard 'ArrayBuffer.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new ArrayBuffer().foo", + errors: [ + "Non-standard 'ArrayBuffer.prototype.foo' property is forbidden.", + ], + }, + { + code: "new ArrayBuffer().bar", + errors: [ + "Non-standard 'ArrayBuffer.prototype.bar' property is forbidden.", + ], + }, + { + code: "new ArrayBuffer()[0]", + errors: [ + "Non-standard 'ArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + code: "new ArrayBuffer()['0']", + errors: [ + "Non-standard 'ArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + code: "new ArrayBuffer()['01']", + errors: [ + "Non-standard 'ArrayBuffer.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...arrayBufferPrototypeProperties].map((p) => ({ + filename, + code: `new ArrayBuffer().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new ArrayBuffer().foo", + errors: [ + "Non-standard 'ArrayBuffer.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new ArrayBuffer().bar", + errors: [ + "Non-standard 'ArrayBuffer.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new ArrayBuffer()[0]", + errors: [ + "Non-standard 'ArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new ArrayBuffer()['0']", + errors: [ + "Non-standard 'ArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new ArrayBuffer()['01']", + errors: [ + "Non-standard 'ArrayBuffer.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new ArrayBuffer(); foo.foo", + errors: [ + "Non-standard 'ArrayBuffer.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'ArrayBuffer.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-atomics-properties.js b/tests/lib/rules/no-nonstandard-atomics-properties.js new file mode 100644 index 00000000..c0124d50 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-atomics-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-atomics-properties.js") +const { atomicsProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-atomics-properties", rule, { + valid: [ + ...[...atomicsProperties].map((p) => `Atomics.${p}`), + { code: "Atomics.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Atomics.unknown()", + errors: ["Non-standard 'Atomics.unknown' property is forbidden."], + }, + { + code: "Atomics.foo", + errors: ["Non-standard 'Atomics.foo' property is forbidden."], + }, + { + code: "Atomics.bar", + errors: ["Non-standard 'Atomics.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-bigint-properties.js b/tests/lib/rules/no-nonstandard-bigint-properties.js new file mode 100644 index 00000000..81fc77e4 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-bigint-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-bigint-properties.js") +const { bigintProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-bigint-properties", rule, { + valid: [ + ...[...bigintProperties].map((p) => `BigInt.${p}`), + { code: "BigInt.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "BigInt.unknown()", + errors: ["Non-standard 'BigInt.unknown' property is forbidden."], + }, + { + code: "BigInt.foo", + errors: ["Non-standard 'BigInt.foo' property is forbidden."], + }, + { + code: "BigInt.bar", + errors: ["Non-standard 'BigInt.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-bigint-prototype-properties.js b/tests/lib/rules/no-nonstandard-bigint-prototype-properties.js new file mode 100644 index 00000000..771672e4 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-bigint-prototype-properties.js @@ -0,0 +1,145 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-bigint-prototype-properties.js") +const { + bigintPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-bigint-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...bigintPrototypeProperties].map((p) => `(123n).${p}`), + { code: "(123n).unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "(123n).unknown()", + errors: [ + "Non-standard 'BigInt.prototype.unknown' property is forbidden.", + ], + }, + { + code: "(123n).foo", + errors: [ + "Non-standard 'BigInt.prototype.foo' property is forbidden.", + ], + }, + { + code: "(123n).bar", + errors: [ + "Non-standard 'BigInt.prototype.bar' property is forbidden.", + ], + }, + { + code: "(123n)[0]", + errors: [ + "Non-standard 'BigInt.prototype.0' property is forbidden.", + ], + }, + { + code: "(123n)['0']", + errors: [ + "Non-standard 'BigInt.prototype.0' property is forbidden.", + ], + }, + { + code: "(123n)['01']", + errors: [ + "Non-standard 'BigInt.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...bigintPrototypeProperties].map((p) => ({ + filename, + code: `(123n).${p}`, + })), + ], + invalid: [ + { + filename, + code: "(123n).foo", + errors: [ + "Non-standard 'BigInt.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "(123n).bar", + errors: [ + "Non-standard 'BigInt.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "(123n)[0]", + errors: [ + "Non-standard 'BigInt.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "(123n)['0']", + errors: [ + "Non-standard 'BigInt.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "(123n)['01']", + errors: [ + "Non-standard 'BigInt.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = (123n); foo.foo", + errors: [ + "Non-standard 'BigInt.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = BigInt(''); foo.bar", + errors: [ + "Non-standard 'BigInt.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'BigInt.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-boolean-properties.js b/tests/lib/rules/no-nonstandard-boolean-properties.js new file mode 100644 index 00000000..8ffaa229 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-boolean-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-boolean-properties.js") +const { booleanProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-boolean-properties", rule, { + valid: [ + ...[...booleanProperties].map((p) => `Boolean.${p}`), + { code: "Boolean.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Boolean.unknown()", + errors: ["Non-standard 'Boolean.unknown' property is forbidden."], + }, + { + code: "Boolean.foo", + errors: ["Non-standard 'Boolean.foo' property is forbidden."], + }, + { + code: "Boolean.bar", + errors: ["Non-standard 'Boolean.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-boolean-prototype-properties.js b/tests/lib/rules/no-nonstandard-boolean-prototype-properties.js new file mode 100644 index 00000000..3d5eb52a --- /dev/null +++ b/tests/lib/rules/no-nonstandard-boolean-prototype-properties.js @@ -0,0 +1,145 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-boolean-prototype-properties.js") +const { + booleanPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-boolean-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...booleanPrototypeProperties].map((p) => `true.${p}`), + { code: "true.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "true.unknown()", + errors: [ + "Non-standard 'Boolean.prototype.unknown' property is forbidden.", + ], + }, + { + code: "true.foo", + errors: [ + "Non-standard 'Boolean.prototype.foo' property is forbidden.", + ], + }, + { + code: "true.bar", + errors: [ + "Non-standard 'Boolean.prototype.bar' property is forbidden.", + ], + }, + { + code: "true[0]", + errors: [ + "Non-standard 'Boolean.prototype.0' property is forbidden.", + ], + }, + { + code: "true['0']", + errors: [ + "Non-standard 'Boolean.prototype.0' property is forbidden.", + ], + }, + { + code: "true['01']", + errors: [ + "Non-standard 'Boolean.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...booleanPrototypeProperties].map((p) => ({ + filename, + code: `true.${p}`, + })), + ], + invalid: [ + { + filename, + code: "true.foo", + errors: [ + "Non-standard 'Boolean.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "true.bar", + errors: [ + "Non-standard 'Boolean.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "true[0]", + errors: [ + "Non-standard 'Boolean.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "true['0']", + errors: [ + "Non-standard 'Boolean.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "true['01']", + errors: [ + "Non-standard 'Boolean.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = true; foo.foo", + errors: [ + "Non-standard 'Boolean.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Boolean(''); foo.bar", + errors: [ + "Non-standard 'Boolean.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Boolean.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-dataview-prototype-properties.js b/tests/lib/rules/no-nonstandard-dataview-prototype-properties.js new file mode 100644 index 00000000..d1cef819 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-dataview-prototype-properties.js @@ -0,0 +1,138 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-dataview-prototype-properties.js") +const { + dataViewPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-dataview-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...dataViewPrototypeProperties].map((p) => `new DataView().${p}`), + { code: "new DataView().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new DataView().unknown()", + errors: [ + "Non-standard 'DataView.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new DataView().foo", + errors: [ + "Non-standard 'DataView.prototype.foo' property is forbidden.", + ], + }, + { + code: "new DataView().bar", + errors: [ + "Non-standard 'DataView.prototype.bar' property is forbidden.", + ], + }, + { + code: "new DataView()[0]", + errors: [ + "Non-standard 'DataView.prototype.0' property is forbidden.", + ], + }, + { + code: "new DataView()['0']", + errors: [ + "Non-standard 'DataView.prototype.0' property is forbidden.", + ], + }, + { + code: "new DataView()['01']", + errors: [ + "Non-standard 'DataView.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...dataViewPrototypeProperties].map((p) => ({ + filename, + code: `new DataView().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new DataView().foo", + errors: [ + "Non-standard 'DataView.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new DataView().bar", + errors: [ + "Non-standard 'DataView.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new DataView()[0]", + errors: [ + "Non-standard 'DataView.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new DataView()['0']", + errors: [ + "Non-standard 'DataView.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new DataView()['01']", + errors: [ + "Non-standard 'DataView.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new DataView(); foo.foo", + errors: [ + "Non-standard 'DataView.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'DataView.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-date-properties.js b/tests/lib/rules/no-nonstandard-date-properties.js new file mode 100644 index 00000000..10f12c34 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-date-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-date-properties.js") +const { dateProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-date-properties", rule, { + valid: [ + ...[...dateProperties].map((p) => `Date.${p}`), + { code: "Date.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Date.unknown()", + errors: ["Non-standard 'Date.unknown' property is forbidden."], + }, + { + code: "Date.foo", + errors: ["Non-standard 'Date.foo' property is forbidden."], + }, + { + code: "Date.bar", + errors: ["Non-standard 'Date.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-date-prototype-properties.js b/tests/lib/rules/no-nonstandard-date-prototype-properties.js new file mode 100644 index 00000000..221393bf --- /dev/null +++ b/tests/lib/rules/no-nonstandard-date-prototype-properties.js @@ -0,0 +1,126 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-date-prototype-properties.js") +const { + datePrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-date-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...datePrototypeProperties].map((p) => `new Date().${p}`), + { code: "new Date().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new Date().unknown()", + errors: [ + "Non-standard 'Date.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Date().foo", + errors: [ + "Non-standard 'Date.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Date().bar", + errors: [ + "Non-standard 'Date.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Date()[0]", + errors: ["Non-standard 'Date.prototype.0' property is forbidden."], + }, + { + code: "new Date()['0']", + errors: ["Non-standard 'Date.prototype.0' property is forbidden."], + }, + { + code: "new Date()['01']", + errors: ["Non-standard 'Date.prototype.01' property is forbidden."], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...datePrototypeProperties].map((p) => ({ + filename, + code: `new Date().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Date().foo", + errors: [ + "Non-standard 'Date.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Date().bar", + errors: [ + "Non-standard 'Date.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Date()[0]", + errors: ["Non-standard 'Date.prototype.0' property is forbidden."], + }, + { + filename, + code: "new Date()['0']", + errors: ["Non-standard 'Date.prototype.0' property is forbidden."], + }, + { + filename, + code: "new Date()['01']", + errors: ["Non-standard 'Date.prototype.01' property is forbidden."], + }, + { + filename, + code: "let foo = new Date(); foo.foo", + errors: [ + "Non-standard 'Date.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Date.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js b/tests/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js new file mode 100644 index 00000000..043e4721 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-finalizationregistry-prototype-properties.js") +const { + finalizationRegistryPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-finalizationregistry-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...finalizationRegistryPrototypeProperties].map( + (p) => `new FinalizationRegistry().${p}`, + ), + { + code: "new FinalizationRegistry().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new FinalizationRegistry().unknown()", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new FinalizationRegistry().foo", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.foo' property is forbidden.", + ], + }, + { + code: "new FinalizationRegistry().bar", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.bar' property is forbidden.", + ], + }, + { + code: "new FinalizationRegistry()[0]", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.0' property is forbidden.", + ], + }, + { + code: "new FinalizationRegistry()['0']", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.0' property is forbidden.", + ], + }, + { + code: "new FinalizationRegistry()['01']", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...finalizationRegistryPrototypeProperties].map((p) => ({ + filename, + code: `new FinalizationRegistry().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new FinalizationRegistry().foo", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new FinalizationRegistry().bar", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new FinalizationRegistry()[0]", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new FinalizationRegistry()['0']", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new FinalizationRegistry()['01']", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new FinalizationRegistry(); foo.foo", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: [ + "Non-standard 'FinalizationRegistry.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-function-properties.js b/tests/lib/rules/no-nonstandard-function-properties.js new file mode 100644 index 00000000..860e07f7 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-function-properties.js @@ -0,0 +1,28 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-function-properties.js") +const { + functionProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-function-properties", rule, { + valid: [ + ...[...functionProperties].map((p) => `Function.${p}`), + { code: "Function.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Function.unknown()", + errors: ["Non-standard 'Function.unknown' property is forbidden."], + }, + { + code: "Function.foo", + errors: ["Non-standard 'Function.foo' property is forbidden."], + }, + { + code: "Function.bar", + errors: ["Non-standard 'Function.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-collator-properties.js b/tests/lib/rules/no-nonstandard-intl-collator-properties.js new file mode 100644 index 00000000..00724e9b --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-collator-properties.js @@ -0,0 +1,30 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-collator-properties.js") +const { + intlCollatorProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-collator-properties", rule, { + valid: [ + ...[...intlCollatorProperties].map((p) => `Intl.Collator.${p}`), + { code: "Intl.Collator.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Intl.Collator.unknown()", + errors: [ + "Non-standard 'Intl.Collator.unknown' property is forbidden.", + ], + }, + { + code: "Intl.Collator.foo", + errors: ["Non-standard 'Intl.Collator.foo' property is forbidden."], + }, + { + code: "Intl.Collator.bar", + errors: ["Non-standard 'Intl.Collator.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-collator-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-collator-prototype-properties.js new file mode 100644 index 00000000..bdd504aa --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-collator-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-collator-prototype-properties.js") +const { + intlCollatorPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-collator-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlCollatorPrototypeProperties].map( + (p) => `new Intl.Collator().${p}`, + ), + { + code: "new Intl.Collator().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.Collator().unknown()", + errors: [ + "Non-standard 'Intl.Collator.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.Collator().foo", + errors: [ + "Non-standard 'Intl.Collator.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.Collator().bar", + errors: [ + "Non-standard 'Intl.Collator.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.Collator()[0]", + errors: [ + "Non-standard 'Intl.Collator.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.Collator()['0']", + errors: [ + "Non-standard 'Intl.Collator.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.Collator()['01']", + errors: [ + "Non-standard 'Intl.Collator.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlCollatorPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.Collator().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.Collator().foo", + errors: [ + "Non-standard 'Intl.Collator.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Collator().bar", + errors: [ + "Non-standard 'Intl.Collator.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Collator()[0]", + errors: [ + "Non-standard 'Intl.Collator.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Collator()['0']", + errors: [ + "Non-standard 'Intl.Collator.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Collator()['01']", + errors: [ + "Non-standard 'Intl.Collator.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.Collator(); foo.foo", + errors: [ + "Non-standard 'Intl.Collator.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.Collator.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-datetimeformat-properties.js b/tests/lib/rules/no-nonstandard-intl-datetimeformat-properties.js new file mode 100644 index 00000000..7d56d8c5 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-datetimeformat-properties.js @@ -0,0 +1,39 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-datetimeformat-properties.js") +const { + intlDateTimeFormatProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-datetimeformat-properties", rule, { + valid: [ + ...[...intlDateTimeFormatProperties].map( + (p) => `Intl.DateTimeFormat.${p}`, + ), + { + code: "Intl.DateTimeFormat.unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Intl.DateTimeFormat.unknown()", + errors: [ + "Non-standard 'Intl.DateTimeFormat.unknown' property is forbidden.", + ], + }, + { + code: "Intl.DateTimeFormat.foo", + errors: [ + "Non-standard 'Intl.DateTimeFormat.foo' property is forbidden.", + ], + }, + { + code: "Intl.DateTimeFormat.bar", + errors: [ + "Non-standard 'Intl.DateTimeFormat.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js new file mode 100644 index 00000000..54d1052d --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-datetimeformat-prototype-properties.js") +const { + intlDateTimeFormatPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-datetimeformat-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlDateTimeFormatPrototypeProperties].map( + (p) => `new Intl.DateTimeFormat().${p}`, + ), + { + code: "new Intl.DateTimeFormat().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.DateTimeFormat().unknown()", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.DateTimeFormat().foo", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.DateTimeFormat().bar", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.DateTimeFormat()[0]", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.DateTimeFormat()['0']", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.DateTimeFormat()['01']", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlDateTimeFormatPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.DateTimeFormat().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.DateTimeFormat().foo", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DateTimeFormat().bar", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DateTimeFormat()[0]", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DateTimeFormat()['0']", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DateTimeFormat()['01']", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.DateTimeFormat(); foo.foo", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.DateTimeFormat.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-displaynames-properties.js b/tests/lib/rules/no-nonstandard-intl-displaynames-properties.js new file mode 100644 index 00000000..6a20dbfa --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-displaynames-properties.js @@ -0,0 +1,37 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-displaynames-properties.js") +const { + intlDisplayNamesProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-displaynames-properties", rule, { + valid: [ + ...[...intlDisplayNamesProperties].map((p) => `Intl.DisplayNames.${p}`), + { + code: "Intl.DisplayNames.unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Intl.DisplayNames.unknown()", + errors: [ + "Non-standard 'Intl.DisplayNames.unknown' property is forbidden.", + ], + }, + { + code: "Intl.DisplayNames.foo", + errors: [ + "Non-standard 'Intl.DisplayNames.foo' property is forbidden.", + ], + }, + { + code: "Intl.DisplayNames.bar", + errors: [ + "Non-standard 'Intl.DisplayNames.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js new file mode 100644 index 00000000..c4643627 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-displaynames-prototype-properties.js") +const { + intlDisplayNamesPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-displaynames-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlDisplayNamesPrototypeProperties].map( + (p) => `new Intl.DisplayNames().${p}`, + ), + { + code: "new Intl.DisplayNames().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.DisplayNames().unknown()", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.DisplayNames().foo", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.DisplayNames().bar", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.DisplayNames()[0]", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.DisplayNames()['0']", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.DisplayNames()['01']", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlDisplayNamesPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.DisplayNames().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.DisplayNames().foo", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DisplayNames().bar", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DisplayNames()[0]", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DisplayNames()['0']", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.DisplayNames()['01']", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.DisplayNames(); foo.foo", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.DisplayNames.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-listformat-properties.js b/tests/lib/rules/no-nonstandard-intl-listformat-properties.js new file mode 100644 index 00000000..66344153 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-listformat-properties.js @@ -0,0 +1,37 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-listformat-properties.js") +const { + intlListFormatProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-listformat-properties", rule, { + valid: [ + ...[...intlListFormatProperties].map((p) => `Intl.ListFormat.${p}`), + { + code: "Intl.ListFormat.unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Intl.ListFormat.unknown()", + errors: [ + "Non-standard 'Intl.ListFormat.unknown' property is forbidden.", + ], + }, + { + code: "Intl.ListFormat.foo", + errors: [ + "Non-standard 'Intl.ListFormat.foo' property is forbidden.", + ], + }, + { + code: "Intl.ListFormat.bar", + errors: [ + "Non-standard 'Intl.ListFormat.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js new file mode 100644 index 00000000..10d3bd77 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-listformat-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-listformat-prototype-properties.js") +const { + intlListFormatPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-listformat-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlListFormatPrototypeProperties].map( + (p) => `new Intl.ListFormat().${p}`, + ), + { + code: "new Intl.ListFormat().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.ListFormat().unknown()", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.ListFormat().foo", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.ListFormat().bar", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.ListFormat()[0]", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.ListFormat()['0']", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.ListFormat()['01']", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlListFormatPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.ListFormat().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.ListFormat().foo", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.ListFormat().bar", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.ListFormat()[0]", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.ListFormat()['0']", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.ListFormat()['01']", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.ListFormat(); foo.foo", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.ListFormat.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-locale-properties.js b/tests/lib/rules/no-nonstandard-intl-locale-properties.js new file mode 100644 index 00000000..00b6d405 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-locale-properties.js @@ -0,0 +1,30 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-locale-properties.js") +const { + intlLocaleProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-locale-properties", rule, { + valid: [ + ...[...intlLocaleProperties].map((p) => `Intl.Locale.${p}`), + { code: "Intl.Locale.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Intl.Locale.unknown()", + errors: [ + "Non-standard 'Intl.Locale.unknown' property is forbidden.", + ], + }, + { + code: "Intl.Locale.foo", + errors: ["Non-standard 'Intl.Locale.foo' property is forbidden."], + }, + { + code: "Intl.Locale.bar", + errors: ["Non-standard 'Intl.Locale.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-locale-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-locale-prototype-properties.js new file mode 100644 index 00000000..2b288d22 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-locale-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-locale-prototype-properties.js") +const { + intlLocalePrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-locale-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlLocalePrototypeProperties].map( + (p) => `new Intl.Locale().${p}`, + ), + { + code: "new Intl.Locale().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.Locale().unknown()", + errors: [ + "Non-standard 'Intl.Locale.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.Locale().foo", + errors: [ + "Non-standard 'Intl.Locale.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.Locale().bar", + errors: [ + "Non-standard 'Intl.Locale.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.Locale()[0]", + errors: [ + "Non-standard 'Intl.Locale.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.Locale()['0']", + errors: [ + "Non-standard 'Intl.Locale.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.Locale()['01']", + errors: [ + "Non-standard 'Intl.Locale.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlLocalePrototypeProperties].map((p) => ({ + filename, + code: `new Intl.Locale().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.Locale().foo", + errors: [ + "Non-standard 'Intl.Locale.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Locale().bar", + errors: [ + "Non-standard 'Intl.Locale.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Locale()[0]", + errors: [ + "Non-standard 'Intl.Locale.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Locale()['0']", + errors: [ + "Non-standard 'Intl.Locale.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Locale()['01']", + errors: [ + "Non-standard 'Intl.Locale.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.Locale(); foo.foo", + errors: [ + "Non-standard 'Intl.Locale.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.Locale.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-numberformat-properties.js b/tests/lib/rules/no-nonstandard-intl-numberformat-properties.js new file mode 100644 index 00000000..14c529b1 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-numberformat-properties.js @@ -0,0 +1,37 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-numberformat-properties.js") +const { + intlNumberFormatProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-numberformat-properties", rule, { + valid: [ + ...[...intlNumberFormatProperties].map((p) => `Intl.NumberFormat.${p}`), + { + code: "Intl.NumberFormat.unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Intl.NumberFormat.unknown()", + errors: [ + "Non-standard 'Intl.NumberFormat.unknown' property is forbidden.", + ], + }, + { + code: "Intl.NumberFormat.foo", + errors: [ + "Non-standard 'Intl.NumberFormat.foo' property is forbidden.", + ], + }, + { + code: "Intl.NumberFormat.bar", + errors: [ + "Non-standard 'Intl.NumberFormat.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js new file mode 100644 index 00000000..189ab241 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-numberformat-prototype-properties.js") +const { + intlNumberFormatPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-numberformat-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlNumberFormatPrototypeProperties].map( + (p) => `new Intl.NumberFormat().${p}`, + ), + { + code: "new Intl.NumberFormat().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.NumberFormat().unknown()", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.NumberFormat().foo", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.NumberFormat().bar", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.NumberFormat()[0]", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.NumberFormat()['0']", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.NumberFormat()['01']", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlNumberFormatPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.NumberFormat().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.NumberFormat().foo", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.NumberFormat().bar", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.NumberFormat()[0]", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.NumberFormat()['0']", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.NumberFormat()['01']", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.NumberFormat(); foo.foo", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.NumberFormat.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-pluralrules-properties.js b/tests/lib/rules/no-nonstandard-intl-pluralrules-properties.js new file mode 100644 index 00000000..cca7f1ec --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-pluralrules-properties.js @@ -0,0 +1,37 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-pluralrules-properties.js") +const { + intlPluralRulesProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-pluralrules-properties", rule, { + valid: [ + ...[...intlPluralRulesProperties].map((p) => `Intl.PluralRules.${p}`), + { + code: "Intl.PluralRules.unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Intl.PluralRules.unknown()", + errors: [ + "Non-standard 'Intl.PluralRules.unknown' property is forbidden.", + ], + }, + { + code: "Intl.PluralRules.foo", + errors: [ + "Non-standard 'Intl.PluralRules.foo' property is forbidden.", + ], + }, + { + code: "Intl.PluralRules.bar", + errors: [ + "Non-standard 'Intl.PluralRules.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js new file mode 100644 index 00000000..a6ceb082 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-pluralrules-prototype-properties.js") +const { + intlPluralRulesPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-pluralrules-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlPluralRulesPrototypeProperties].map( + (p) => `new Intl.PluralRules().${p}`, + ), + { + code: "new Intl.PluralRules().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.PluralRules().unknown()", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.PluralRules().foo", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.PluralRules().bar", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.PluralRules()[0]", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.PluralRules()['0']", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.PluralRules()['01']", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlPluralRulesPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.PluralRules().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.PluralRules().foo", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.PluralRules().bar", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.PluralRules()[0]", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.PluralRules()['0']", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.PluralRules()['01']", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.PluralRules(); foo.foo", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.PluralRules.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-properties.js b/tests/lib/rules/no-nonstandard-intl-properties.js new file mode 100644 index 00000000..834ca925 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-properties.js") +const { intlProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-properties", rule, { + valid: [ + ...[...intlProperties].map((p) => `Intl.${p}`), + { code: "Intl.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Intl.unknown()", + errors: ["Non-standard 'Intl.unknown' property is forbidden."], + }, + { + code: "Intl.foo", + errors: ["Non-standard 'Intl.foo' property is forbidden."], + }, + { + code: "Intl.bar", + errors: ["Non-standard 'Intl.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js b/tests/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js new file mode 100644 index 00000000..db26a639 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-relativetimeformat-properties.js @@ -0,0 +1,43 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-relativetimeformat-properties.js") +const { + intlRelativeTimeFormatProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run( + "no-nonstandard-intl-relativetimeformat-properties", + rule, + { + valid: [ + ...[...intlRelativeTimeFormatProperties].map( + (p) => `Intl.RelativeTimeFormat.${p}`, + ), + { + code: "Intl.RelativeTimeFormat.unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Intl.RelativeTimeFormat.unknown()", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.unknown' property is forbidden.", + ], + }, + { + code: "Intl.RelativeTimeFormat.foo", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.foo' property is forbidden.", + ], + }, + { + code: "Intl.RelativeTimeFormat.bar", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.bar' property is forbidden.", + ], + }, + ], + }, +) diff --git a/tests/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js new file mode 100644 index 00000000..e168c5f3 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-relativetimeformat-prototype-properties.js") +const { + intlRelativeTimeFormatPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-relativetimeformat-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlRelativeTimeFormatPrototypeProperties].map( + (p) => `new Intl.RelativeTimeFormat().${p}`, + ), + { + code: "new Intl.RelativeTimeFormat().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.RelativeTimeFormat().unknown()", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.RelativeTimeFormat().foo", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.RelativeTimeFormat().bar", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.RelativeTimeFormat()[0]", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.RelativeTimeFormat()['0']", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.RelativeTimeFormat()['01']", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlRelativeTimeFormatPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.RelativeTimeFormat().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.RelativeTimeFormat().foo", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.RelativeTimeFormat().bar", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.RelativeTimeFormat()[0]", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.RelativeTimeFormat()['0']", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.RelativeTimeFormat()['01']", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.RelativeTimeFormat(); foo.foo", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.RelativeTimeFormat.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-segmenter-properties.js b/tests/lib/rules/no-nonstandard-intl-segmenter-properties.js new file mode 100644 index 00000000..83039a4e --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-segmenter-properties.js @@ -0,0 +1,34 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-segmenter-properties.js") +const { + intlSegmenterProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-intl-segmenter-properties", rule, { + valid: [ + ...[...intlSegmenterProperties].map((p) => `Intl.Segmenter.${p}`), + { code: "Intl.Segmenter.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Intl.Segmenter.unknown()", + errors: [ + "Non-standard 'Intl.Segmenter.unknown' property is forbidden.", + ], + }, + { + code: "Intl.Segmenter.foo", + errors: [ + "Non-standard 'Intl.Segmenter.foo' property is forbidden.", + ], + }, + { + code: "Intl.Segmenter.bar", + errors: [ + "Non-standard 'Intl.Segmenter.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js b/tests/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js new file mode 100644 index 00000000..14ea9820 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-intl-segmenter-prototype-properties.js") +const { + intlSegmenterPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-intl-segmenter-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...intlSegmenterPrototypeProperties].map( + (p) => `new Intl.Segmenter().${p}`, + ), + { + code: "new Intl.Segmenter().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new Intl.Segmenter().unknown()", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Intl.Segmenter().foo", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.foo' property is forbidden.", + ], + }, + { + code: "new Intl.Segmenter().bar", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.bar' property is forbidden.", + ], + }, + { + code: "new Intl.Segmenter()[0]", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.Segmenter()['0']", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.0' property is forbidden.", + ], + }, + { + code: "new Intl.Segmenter()['01']", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...intlSegmenterPrototypeProperties].map((p) => ({ + filename, + code: `new Intl.Segmenter().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Intl.Segmenter().foo", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Segmenter().bar", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Segmenter()[0]", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Segmenter()['0']", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new Intl.Segmenter()['01']", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Intl.Segmenter(); foo.foo", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Intl.Segmenter.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-iterator-properties.js b/tests/lib/rules/no-nonstandard-iterator-properties.js new file mode 100644 index 00000000..98ff8cc1 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-iterator-properties.js @@ -0,0 +1,28 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-iterator-properties.js") +const { + iteratorProperties, +} = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-iterator-properties", rule, { + valid: [ + ...[...iteratorProperties].map((p) => `Iterator.${p}`), + { code: "Iterator.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Iterator.unknown()", + errors: ["Non-standard 'Iterator.unknown' property is forbidden."], + }, + { + code: "Iterator.foo", + errors: ["Non-standard 'Iterator.foo' property is forbidden."], + }, + { + code: "Iterator.bar", + errors: ["Non-standard 'Iterator.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-iterator-prototype-properties.js b/tests/lib/rules/no-nonstandard-iterator-prototype-properties.js new file mode 100644 index 00000000..ac3b96f1 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-iterator-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-iterator-prototype-properties.js") +const { + iteratorPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-iterator-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...iteratorPrototypeProperties].map( + (p) => `Iterator.from({}).${p}`, + ), + { + code: "Iterator.from({}).unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Iterator.from({}).unknown()", + errors: [ + "Non-standard 'Iterator.prototype.unknown' property is forbidden.", + ], + }, + { + code: "Iterator.from({}).foo", + errors: [ + "Non-standard 'Iterator.prototype.foo' property is forbidden.", + ], + }, + { + code: "Iterator.from({}).bar", + errors: [ + "Non-standard 'Iterator.prototype.bar' property is forbidden.", + ], + }, + { + code: "Iterator.from({})[0]", + errors: [ + "Non-standard 'Iterator.prototype.0' property is forbidden.", + ], + }, + { + code: "Iterator.from({})['0']", + errors: [ + "Non-standard 'Iterator.prototype.0' property is forbidden.", + ], + }, + { + code: "Iterator.from({})['01']", + errors: [ + "Non-standard 'Iterator.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...iteratorPrototypeProperties].map((p) => ({ + filename, + code: `Iterator.from({}).${p}`, + })), + ], + invalid: [ + { + filename, + code: "Iterator.from({}).foo", + errors: [ + "Non-standard 'Iterator.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "Iterator.from({}).bar", + errors: [ + "Non-standard 'Iterator.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "Iterator.from({})[0]", + errors: [ + "Non-standard 'Iterator.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "Iterator.from({})['0']", + errors: [ + "Non-standard 'Iterator.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "Iterator.from({})['01']", + errors: [ + "Non-standard 'Iterator.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Iterator.from({}); foo.foo", + errors: [ + "Non-standard 'Iterator.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: [ + "Non-standard 'Iterator.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-json-properties.js b/tests/lib/rules/no-nonstandard-json-properties.js new file mode 100644 index 00000000..5fc3f961 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-json-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-json-properties.js") +const { jsonProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-json-properties", rule, { + valid: [ + ...[...jsonProperties].map((p) => `JSON.${p}`), + { code: "JSON.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "JSON.unknown()", + errors: ["Non-standard 'JSON.unknown' property is forbidden."], + }, + { + code: "JSON.foo", + errors: ["Non-standard 'JSON.foo' property is forbidden."], + }, + { + code: "JSON.bar", + errors: ["Non-standard 'JSON.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-map-properties.js b/tests/lib/rules/no-nonstandard-map-properties.js new file mode 100644 index 00000000..0b4a5995 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-map-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-map-properties.js") +const { mapProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-map-properties", rule, { + valid: [ + ...[...mapProperties].map((p) => `Map.${p}`), + { code: "Map.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Map.unknown()", + errors: ["Non-standard 'Map.unknown' property is forbidden."], + }, + { + code: "Map.foo", + errors: ["Non-standard 'Map.foo' property is forbidden."], + }, + { + code: "Map.bar", + errors: ["Non-standard 'Map.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-map-prototype-properties.js b/tests/lib/rules/no-nonstandard-map-prototype-properties.js new file mode 100644 index 00000000..25fa9f49 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-map-prototype-properties.js @@ -0,0 +1,114 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-map-prototype-properties.js") +const { + mapPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-map-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...mapPrototypeProperties].map((p) => `new Map().${p}`), + { code: "new Map().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new Map().unknown()", + errors: [ + "Non-standard 'Map.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Map().foo", + errors: ["Non-standard 'Map.prototype.foo' property is forbidden."], + }, + { + code: "new Map().bar", + errors: ["Non-standard 'Map.prototype.bar' property is forbidden."], + }, + { + code: "new Map()[0]", + errors: ["Non-standard 'Map.prototype.0' property is forbidden."], + }, + { + code: "new Map()['0']", + errors: ["Non-standard 'Map.prototype.0' property is forbidden."], + }, + { + code: "new Map()['01']", + errors: ["Non-standard 'Map.prototype.01' property is forbidden."], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...mapPrototypeProperties].map((p) => ({ + filename, + code: `new Map().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Map().foo", + errors: ["Non-standard 'Map.prototype.foo' property is forbidden."], + }, + { + filename, + code: "new Map().bar", + errors: ["Non-standard 'Map.prototype.bar' property is forbidden."], + }, + { + filename, + code: "new Map()[0]", + errors: ["Non-standard 'Map.prototype.0' property is forbidden."], + }, + { + filename, + code: "new Map()['0']", + errors: ["Non-standard 'Map.prototype.0' property is forbidden."], + }, + { + filename, + code: "new Map()['01']", + errors: ["Non-standard 'Map.prototype.01' property is forbidden."], + }, + { + filename, + code: "let foo = new Map(); foo.foo", + errors: ["Non-standard 'Map.prototype.foo' property is forbidden."], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: ["Non-standard 'Map.prototype.baz' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-math-properties.js b/tests/lib/rules/no-nonstandard-math-properties.js new file mode 100644 index 00000000..335b054d --- /dev/null +++ b/tests/lib/rules/no-nonstandard-math-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-math-properties.js") +const { mathProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-math-properties", rule, { + valid: [ + ...[...mathProperties].map((p) => `Math.${p}`), + { code: "Math.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Math.unknown()", + errors: ["Non-standard 'Math.unknown' property is forbidden."], + }, + { + code: "Math.foo", + errors: ["Non-standard 'Math.foo' property is forbidden."], + }, + { + code: "Math.bar", + errors: ["Non-standard 'Math.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-number-properties.js b/tests/lib/rules/no-nonstandard-number-properties.js new file mode 100644 index 00000000..dd5f1fd0 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-number-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-number-properties.js") +const { numberProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-number-properties", rule, { + valid: [ + ...[...numberProperties].map((p) => `Number.${p}`), + { code: "Number.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Number.unknown()", + errors: ["Non-standard 'Number.unknown' property is forbidden."], + }, + { + code: "Number.foo", + errors: ["Non-standard 'Number.foo' property is forbidden."], + }, + { + code: "Number.bar", + errors: ["Non-standard 'Number.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-number-prototype-properties.js b/tests/lib/rules/no-nonstandard-number-prototype-properties.js new file mode 100644 index 00000000..69a9f626 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-number-prototype-properties.js @@ -0,0 +1,145 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-number-prototype-properties.js") +const { + numberPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-number-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...numberPrototypeProperties].map((p) => `(123).${p}`), + { code: "(123).unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "(123).unknown()", + errors: [ + "Non-standard 'Number.prototype.unknown' property is forbidden.", + ], + }, + { + code: "(123).foo", + errors: [ + "Non-standard 'Number.prototype.foo' property is forbidden.", + ], + }, + { + code: "(123).bar", + errors: [ + "Non-standard 'Number.prototype.bar' property is forbidden.", + ], + }, + { + code: "(123)[0]", + errors: [ + "Non-standard 'Number.prototype.0' property is forbidden.", + ], + }, + { + code: "(123)['0']", + errors: [ + "Non-standard 'Number.prototype.0' property is forbidden.", + ], + }, + { + code: "(123)['01']", + errors: [ + "Non-standard 'Number.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...numberPrototypeProperties].map((p) => ({ + filename, + code: `(123).${p}`, + })), + ], + invalid: [ + { + filename, + code: "(123).foo", + errors: [ + "Non-standard 'Number.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "(123).bar", + errors: [ + "Non-standard 'Number.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "(123)[0]", + errors: [ + "Non-standard 'Number.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "(123)['0']", + errors: [ + "Non-standard 'Number.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "(123)['01']", + errors: [ + "Non-standard 'Number.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = (123); foo.foo", + errors: [ + "Non-standard 'Number.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Number(''); foo.bar", + errors: [ + "Non-standard 'Number.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'Number.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-object-properties.js b/tests/lib/rules/no-nonstandard-object-properties.js new file mode 100644 index 00000000..1327b24d --- /dev/null +++ b/tests/lib/rules/no-nonstandard-object-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-object-properties.js") +const { objectProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-object-properties", rule, { + valid: [ + ...[...objectProperties].map((p) => `Object.${p}`), + { code: "Object.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Object.unknown()", + errors: ["Non-standard 'Object.unknown' property is forbidden."], + }, + { + code: "Object.foo", + errors: ["Non-standard 'Object.foo' property is forbidden."], + }, + { + code: "Object.bar", + errors: ["Non-standard 'Object.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-promise-properties.js b/tests/lib/rules/no-nonstandard-promise-properties.js new file mode 100644 index 00000000..96856875 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-promise-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-promise-properties.js") +const { promiseProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-promise-properties", rule, { + valid: [ + ...[...promiseProperties].map((p) => `Promise.${p}`), + { code: "Promise.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Promise.unknown()", + errors: ["Non-standard 'Promise.unknown' property is forbidden."], + }, + { + code: "Promise.foo", + errors: ["Non-standard 'Promise.foo' property is forbidden."], + }, + { + code: "Promise.bar", + errors: ["Non-standard 'Promise.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-promise-prototype-properties.js b/tests/lib/rules/no-nonstandard-promise-prototype-properties.js new file mode 100644 index 00000000..97d78c2e --- /dev/null +++ b/tests/lib/rules/no-nonstandard-promise-prototype-properties.js @@ -0,0 +1,154 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-promise-prototype-properties.js") +const { + promisePrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-promise-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...promisePrototypeProperties].map((p) => `Promise.resolve().${p}`), + { + code: "Promise.resolve().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "Promise.resolve().unknown()", + errors: [ + "Non-standard 'Promise.prototype.unknown' property is forbidden.", + ], + }, + { + code: "Promise.resolve().foo", + errors: [ + "Non-standard 'Promise.prototype.foo' property is forbidden.", + ], + }, + { + code: "Promise.resolve().bar", + errors: [ + "Non-standard 'Promise.prototype.bar' property is forbidden.", + ], + }, + { + code: "Promise.resolve()[0]", + errors: [ + "Non-standard 'Promise.prototype.0' property is forbidden.", + ], + }, + { + code: "Promise.resolve()['0']", + errors: [ + "Non-standard 'Promise.prototype.0' property is forbidden.", + ], + }, + { + code: "Promise.resolve()['01']", + errors: [ + "Non-standard 'Promise.prototype.01' property is forbidden.", + ], + }, + { + code: "const foo = import('foo'); foo['01']", + errors: [ + "Non-standard 'Promise.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...promisePrototypeProperties].map((p) => ({ + filename, + code: `Promise.resolve().${p}`, + })), + ], + invalid: [ + { + filename, + code: "Promise.resolve().foo", + errors: [ + "Non-standard 'Promise.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "Promise.resolve().bar", + errors: [ + "Non-standard 'Promise.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "Promise.resolve()[0]", + errors: [ + "Non-standard 'Promise.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "Promise.resolve()['0']", + errors: [ + "Non-standard 'Promise.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "Promise.resolve()['01']", + errors: [ + "Non-standard 'Promise.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Promise.resolve(); foo.foo", + errors: [ + "Non-standard 'Promise.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new Promise(); foo.bar", + errors: [ + "Non-standard 'Promise.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: [ + "Non-standard 'Promise.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-proxy-properties.js b/tests/lib/rules/no-nonstandard-proxy-properties.js new file mode 100644 index 00000000..1b7a384b --- /dev/null +++ b/tests/lib/rules/no-nonstandard-proxy-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-proxy-properties.js") +const { proxyProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-proxy-properties", rule, { + valid: [ + ...[...proxyProperties].map((p) => `Proxy.${p}`), + { code: "Proxy.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Proxy.unknown()", + errors: ["Non-standard 'Proxy.unknown' property is forbidden."], + }, + { + code: "Proxy.foo", + errors: ["Non-standard 'Proxy.foo' property is forbidden."], + }, + { + code: "Proxy.bar", + errors: ["Non-standard 'Proxy.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-reflect-properties.js b/tests/lib/rules/no-nonstandard-reflect-properties.js new file mode 100644 index 00000000..aae2fb5f --- /dev/null +++ b/tests/lib/rules/no-nonstandard-reflect-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-reflect-properties.js") +const { reflectProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-reflect-properties", rule, { + valid: [ + ...[...reflectProperties].map((p) => `Reflect.${p}`), + { code: "Reflect.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Reflect.unknown()", + errors: ["Non-standard 'Reflect.unknown' property is forbidden."], + }, + { + code: "Reflect.foo", + errors: ["Non-standard 'Reflect.foo' property is forbidden."], + }, + { + code: "Reflect.bar", + errors: ["Non-standard 'Reflect.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-regexp-properties.js b/tests/lib/rules/no-nonstandard-regexp-properties.js new file mode 100644 index 00000000..0b71cc9e --- /dev/null +++ b/tests/lib/rules/no-nonstandard-regexp-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-regexp-properties.js") +const { regexpProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-regexp-properties", rule, { + valid: [ + ...[...regexpProperties].map((p) => `RegExp[${JSON.stringify(p)}]`), + { code: "RegExp.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "RegExp.unknown()", + errors: ["Non-standard 'RegExp.unknown' property is forbidden."], + }, + { + code: "RegExp.foo", + errors: ["Non-standard 'RegExp.foo' property is forbidden."], + }, + { + code: "RegExp.bar", + errors: ["Non-standard 'RegExp.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-regexp-prototype-properties.js b/tests/lib/rules/no-nonstandard-regexp-prototype-properties.js new file mode 100644 index 00000000..04050389 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-regexp-prototype-properties.js @@ -0,0 +1,145 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-regexp-prototype-properties.js") +const { + regexpPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-regexp-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...regexpPrototypeProperties].map((p) => `/foo/u.${p}`), + { code: "/foo/u.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "/foo/u.unknown()", + errors: [ + "Non-standard 'RegExp.prototype.unknown' property is forbidden.", + ], + }, + { + code: "/foo/u.foo", + errors: [ + "Non-standard 'RegExp.prototype.foo' property is forbidden.", + ], + }, + { + code: "/foo/u.bar", + errors: [ + "Non-standard 'RegExp.prototype.bar' property is forbidden.", + ], + }, + { + code: "/foo/u[0]", + errors: [ + "Non-standard 'RegExp.prototype.0' property is forbidden.", + ], + }, + { + code: "/foo/u['0']", + errors: [ + "Non-standard 'RegExp.prototype.0' property is forbidden.", + ], + }, + { + code: "/foo/u['01']", + errors: [ + "Non-standard 'RegExp.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...regexpPrototypeProperties].map((p) => ({ + filename, + code: `/foo/u.${p}`, + })), + ], + invalid: [ + { + filename, + code: "/foo/u.foo", + errors: [ + "Non-standard 'RegExp.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "/foo/u.bar", + errors: [ + "Non-standard 'RegExp.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "/foo/u[0]", + errors: [ + "Non-standard 'RegExp.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "/foo/u['0']", + errors: [ + "Non-standard 'RegExp.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "/foo/u['01']", + errors: [ + "Non-standard 'RegExp.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = /foo/u; foo.foo", + errors: [ + "Non-standard 'RegExp.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new RegExp(''); foo.bar", + errors: [ + "Non-standard 'RegExp.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'RegExp.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-set-prototype-properties.js b/tests/lib/rules/no-nonstandard-set-prototype-properties.js new file mode 100644 index 00000000..78e2aa7e --- /dev/null +++ b/tests/lib/rules/no-nonstandard-set-prototype-properties.js @@ -0,0 +1,114 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-set-prototype-properties.js") +const { + setPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-set-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...setPrototypeProperties].map((p) => `new Set().${p}`), + { code: "new Set().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new Set().unknown()", + errors: [ + "Non-standard 'Set.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new Set().foo", + errors: ["Non-standard 'Set.prototype.foo' property is forbidden."], + }, + { + code: "new Set().bar", + errors: ["Non-standard 'Set.prototype.bar' property is forbidden."], + }, + { + code: "new Set()[0]", + errors: ["Non-standard 'Set.prototype.0' property is forbidden."], + }, + { + code: "new Set()['0']", + errors: ["Non-standard 'Set.prototype.0' property is forbidden."], + }, + { + code: "new Set()['01']", + errors: ["Non-standard 'Set.prototype.01' property is forbidden."], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...setPrototypeProperties].map((p) => ({ + filename, + code: `new Set().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new Set().foo", + errors: ["Non-standard 'Set.prototype.foo' property is forbidden."], + }, + { + filename, + code: "new Set().bar", + errors: ["Non-standard 'Set.prototype.bar' property is forbidden."], + }, + { + filename, + code: "new Set()[0]", + errors: ["Non-standard 'Set.prototype.0' property is forbidden."], + }, + { + filename, + code: "new Set()['0']", + errors: ["Non-standard 'Set.prototype.0' property is forbidden."], + }, + { + filename, + code: "new Set()['01']", + errors: ["Non-standard 'Set.prototype.01' property is forbidden."], + }, + { + filename, + code: "let foo = new Set(); foo.foo", + errors: ["Non-standard 'Set.prototype.foo' property is forbidden."], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: ["Non-standard 'Set.prototype.baz' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js b/tests/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js new file mode 100644 index 00000000..4e24beac --- /dev/null +++ b/tests/lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js @@ -0,0 +1,143 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-sharedarraybuffer-prototype-properties.js") +const { + sharedArrayBufferPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-sharedarraybuffer-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...sharedArrayBufferPrototypeProperties].map( + (p) => `new SharedArrayBuffer().${p}`, + ), + { + code: "new SharedArrayBuffer().unknown()", + options: [{ allow: ["unknown"] }], + }, + ], + invalid: [ + { + code: "new SharedArrayBuffer().unknown()", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new SharedArrayBuffer().foo", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.foo' property is forbidden.", + ], + }, + { + code: "new SharedArrayBuffer().bar", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.bar' property is forbidden.", + ], + }, + { + code: "new SharedArrayBuffer()[0]", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + code: "new SharedArrayBuffer()['0']", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + code: "new SharedArrayBuffer()['01']", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...sharedArrayBufferPrototypeProperties].map((p) => ({ + filename, + code: `new SharedArrayBuffer().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new SharedArrayBuffer().foo", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new SharedArrayBuffer().bar", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new SharedArrayBuffer()[0]", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new SharedArrayBuffer()['0']", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new SharedArrayBuffer()['01']", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new SharedArrayBuffer(); foo.foo", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.baz }", + errors: [ + "Non-standard 'SharedArrayBuffer.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-string-properties.js b/tests/lib/rules/no-nonstandard-string-properties.js new file mode 100644 index 00000000..a1be55b0 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-string-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-string-properties.js") +const { stringProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-string-properties", rule, { + valid: [ + ...[...stringProperties].map((p) => `String.${p}`), + { code: "String.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "String.unknown()", + errors: ["Non-standard 'String.unknown' property is forbidden."], + }, + { + code: "String.foo", + errors: ["Non-standard 'String.foo' property is forbidden."], + }, + { + code: "String.bar", + errors: ["Non-standard 'String.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-string-prototype-properties.js b/tests/lib/rules/no-nonstandard-string-prototype-properties.js new file mode 100644 index 00000000..8b82a65c --- /dev/null +++ b/tests/lib/rules/no-nonstandard-string-prototype-properties.js @@ -0,0 +1,137 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-string-prototype-properties.js") +const { + stringPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-string-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...stringPrototypeProperties].map((p) => `'A'.${p}`), + "'A'[0]", + "'A'['0']", + { code: "'A'.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "'A'.unknown()", + errors: [ + "Non-standard 'String.prototype.unknown' property is forbidden.", + ], + }, + { + code: "'123'.foo", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + { + code: "'123'.bar", + errors: [ + "Non-standard 'String.prototype.bar' property is forbidden.", + ], + }, + { + code: "'123'['01']", + errors: [ + "Non-standard 'String.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...stringPrototypeProperties].map((p) => ({ + filename, + code: `'A'.${p}`, + })), + { filename, code: "'A'[0]" }, + { filename, code: "'A'['0']" }, + ], + invalid: [ + { + filename, + code: "'123'.foo", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "'123'.bar", + errors: [ + "Non-standard 'String.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "'123'['01']", + errors: [ + "Non-standard 'String.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = 'str'; foo.foo", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = String(42); foo.foo", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.foo }", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.foo }", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f(a: T) { a.foo }", + errors: [ + "Non-standard 'String.prototype.foo' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-symbol-properties.js b/tests/lib/rules/no-nonstandard-symbol-properties.js new file mode 100644 index 00000000..8b7a985a --- /dev/null +++ b/tests/lib/rules/no-nonstandard-symbol-properties.js @@ -0,0 +1,26 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-symbol-properties.js") +const { symbolProperties } = require("../../../lib/util/well-known-properties") + +new RuleTester().run("no-nonstandard-symbol-properties", rule, { + valid: [ + ...[...symbolProperties].map((p) => `Symbol.${p}`), + { code: "Symbol.unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Symbol.unknown()", + errors: ["Non-standard 'Symbol.unknown' property is forbidden."], + }, + { + code: "Symbol.foo", + errors: ["Non-standard 'Symbol.foo' property is forbidden."], + }, + { + code: "Symbol.bar", + errors: ["Non-standard 'Symbol.bar' property is forbidden."], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-symbol-prototype-properties.js b/tests/lib/rules/no-nonstandard-symbol-prototype-properties.js new file mode 100644 index 00000000..aa52b04c --- /dev/null +++ b/tests/lib/rules/no-nonstandard-symbol-prototype-properties.js @@ -0,0 +1,138 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-symbol-prototype-properties.js") +const { + symbolPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-symbol-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...symbolPrototypeProperties].map((p) => `Symbol().${p}`), + { code: "Symbol().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "Symbol().unknown()", + errors: [ + "Non-standard 'Symbol.prototype.unknown' property is forbidden.", + ], + }, + { + code: "Symbol().foo", + errors: [ + "Non-standard 'Symbol.prototype.foo' property is forbidden.", + ], + }, + { + code: "Symbol().bar", + errors: [ + "Non-standard 'Symbol.prototype.bar' property is forbidden.", + ], + }, + { + code: "Symbol()[0]", + errors: [ + "Non-standard 'Symbol.prototype.0' property is forbidden.", + ], + }, + { + code: "Symbol()['0']", + errors: [ + "Non-standard 'Symbol.prototype.0' property is forbidden.", + ], + }, + { + code: "Symbol()['01']", + errors: [ + "Non-standard 'Symbol.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...symbolPrototypeProperties].map((p) => ({ + filename, + code: `Symbol().${p}`, + })), + ], + invalid: [ + { + filename, + code: "Symbol().foo", + errors: [ + "Non-standard 'Symbol.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "Symbol().bar", + errors: [ + "Non-standard 'Symbol.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "Symbol()[0]", + errors: [ + "Non-standard 'Symbol.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "Symbol()['0']", + errors: [ + "Non-standard 'Symbol.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "Symbol()['01']", + errors: [ + "Non-standard 'Symbol.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Symbol.iterator; foo.foo", + errors: [ + "Non-standard 'Symbol.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "let foo = Symbol(); foo.bar", + errors: [ + "Non-standard 'Symbol.prototype.bar' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-typed-array-properties.js b/tests/lib/rules/no-nonstandard-typed-array-properties.js new file mode 100644 index 00000000..db5731ab --- /dev/null +++ b/tests/lib/rules/no-nonstandard-typed-array-properties.js @@ -0,0 +1,55 @@ +"use strict" + +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-typed-array-properties.js") +const { + typedArrayProperties, +} = require("../../../lib/util/well-known-properties") + +const typedArrayList = [ + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "BigInt64Array", + "BigUint64Array", +] + +new RuleTester().run("no-nonstandard-typed-array-properties", rule, { + valid: [ + ...typedArrayList.flatMap((className) => [ + ...[...typedArrayProperties].map((p) => `${className}.${p}`), + { + code: `${className}.unknown()`, + options: [{ allow: ["unknown"] }], + }, + ]), + ], + invalid: [ + ...typedArrayList.flatMap((className) => [ + { + code: `${className}.unknown()`, + errors: [ + `Non-standard '${className}.unknown' property is forbidden.`, + ], + }, + { + code: `${className}.foo`, + errors: [ + `Non-standard '${className}.foo' property is forbidden.`, + ], + }, + { + code: `${className}.bar`, + errors: [ + `Non-standard '${className}.bar' property is forbidden.`, + ], + }, + ]), + ], +}) diff --git a/tests/lib/rules/no-nonstandard-typed-array-prototype-properties.js b/tests/lib/rules/no-nonstandard-typed-array-prototype-properties.js new file mode 100644 index 00000000..66f440b3 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-typed-array-prototype-properties.js @@ -0,0 +1,150 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-typed-array-prototype-properties.js") +const { + typedArrayPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-typed-array-prototype-properties" + +const typedArrayList = [ + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "BigInt64Array", + "BigUint64Array", +] + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...typedArrayList.flatMap((className) => [ + ...[...typedArrayPrototypeProperties].map( + (p) => `new ${className}().${p}`, + ), + `new ${className}()[0]`, + `new ${className}()['0']`, + { + code: `new ${className}().unknown()`, + options: [{ allow: ["unknown"] }], + }, + ]), + ], + invalid: [ + ...typedArrayList.flatMap((className) => [ + { + code: `new ${className}().unknown()`, + errors: [ + `Non-standard '${className}.prototype.unknown' property is forbidden.`, + ], + }, + { + code: `new ${className}().foo`, + errors: [ + `Non-standard '${className}.prototype.foo' property is forbidden.`, + ], + }, + { + code: `new ${className}().bar`, + errors: [ + `Non-standard '${className}.prototype.bar' property is forbidden.`, + ], + }, + { + code: `new ${className}()['01']`, + errors: [ + `Non-standard '${className}.prototype.01' property is forbidden.`, + ], + }, + ]), + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...typedArrayList.flatMap((className) => [ + ...[...typedArrayPrototypeProperties].map((p) => ({ + filename, + code: `new ${className}().${p}`, + })), + { filename, code: `new ${className}()[0]` }, + { filename, code: `new ${className}()['0']` }, + ]), + ], + invalid: [ + ...typedArrayList.flatMap((className) => [ + { + filename, + code: `new ${className}().foo`, + errors: [ + `Non-standard '${className}.prototype.foo' property is forbidden.`, + ], + }, + { + filename, + code: `new ${className}().bar`, + errors: [ + `Non-standard '${className}.prototype.bar' property is forbidden.`, + ], + }, + { + filename, + code: `new ${className}()['01']`, + errors: [ + `Non-standard '${className}.prototype.01' property is forbidden.`, + ], + }, + { + filename, + code: `let foo = new ${className}(); foo.foo`, + errors: [ + `Non-standard '${className}.prototype.foo' property is forbidden.`, + ], + }, + { + filename, + code: `let foo = ${className}.from(''); foo.bar`, + errors: [ + `Non-standard '${className}.prototype.bar' property is forbidden.`, + ], + }, + { + filename, + code: `function f(a: T) { a.baz }`, + errors: [ + `Non-standard '${className}.prototype.baz' property is forbidden.`, + ], + }, + ]), + ], +}) diff --git a/tests/lib/rules/no-nonstandard-weakmap-prototype-properties.js b/tests/lib/rules/no-nonstandard-weakmap-prototype-properties.js new file mode 100644 index 00000000..0a37c05f --- /dev/null +++ b/tests/lib/rules/no-nonstandard-weakmap-prototype-properties.js @@ -0,0 +1,138 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-weakmap-prototype-properties.js") +const { + weakMapPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-weakmap-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...weakMapPrototypeProperties].map((p) => `new WeakMap().${p}`), + { code: "new WeakMap().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new WeakMap().unknown()", + errors: [ + "Non-standard 'WeakMap.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new WeakMap().foo", + errors: [ + "Non-standard 'WeakMap.prototype.foo' property is forbidden.", + ], + }, + { + code: "new WeakMap().bar", + errors: [ + "Non-standard 'WeakMap.prototype.bar' property is forbidden.", + ], + }, + { + code: "new WeakMap()[0]", + errors: [ + "Non-standard 'WeakMap.prototype.0' property is forbidden.", + ], + }, + { + code: "new WeakMap()['0']", + errors: [ + "Non-standard 'WeakMap.prototype.0' property is forbidden.", + ], + }, + { + code: "new WeakMap()['01']", + errors: [ + "Non-standard 'WeakMap.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...weakMapPrototypeProperties].map((p) => ({ + filename, + code: `new WeakMap().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new WeakMap().foo", + errors: [ + "Non-standard 'WeakMap.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new WeakMap().bar", + errors: [ + "Non-standard 'WeakMap.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new WeakMap()[0]", + errors: [ + "Non-standard 'WeakMap.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new WeakMap()['0']", + errors: [ + "Non-standard 'WeakMap.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new WeakMap()['01']", + errors: [ + "Non-standard 'WeakMap.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new WeakMap(); foo.foo", + errors: [ + "Non-standard 'WeakMap.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: [ + "Non-standard 'WeakMap.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-weakref-prototype-properties.js b/tests/lib/rules/no-nonstandard-weakref-prototype-properties.js new file mode 100644 index 00000000..6a2272b6 --- /dev/null +++ b/tests/lib/rules/no-nonstandard-weakref-prototype-properties.js @@ -0,0 +1,138 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-weakref-prototype-properties.js") +const { + weakRefPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-weakref-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...weakRefPrototypeProperties].map((p) => `new WeakRef().${p}`), + { code: "new WeakRef().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new WeakRef().unknown()", + errors: [ + "Non-standard 'WeakRef.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new WeakRef().foo", + errors: [ + "Non-standard 'WeakRef.prototype.foo' property is forbidden.", + ], + }, + { + code: "new WeakRef().bar", + errors: [ + "Non-standard 'WeakRef.prototype.bar' property is forbidden.", + ], + }, + { + code: "new WeakRef()[0]", + errors: [ + "Non-standard 'WeakRef.prototype.0' property is forbidden.", + ], + }, + { + code: "new WeakRef()['0']", + errors: [ + "Non-standard 'WeakRef.prototype.0' property is forbidden.", + ], + }, + { + code: "new WeakRef()['01']", + errors: [ + "Non-standard 'WeakRef.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...weakRefPrototypeProperties].map((p) => ({ + filename, + code: `new WeakRef().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new WeakRef().foo", + errors: [ + "Non-standard 'WeakRef.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new WeakRef().bar", + errors: [ + "Non-standard 'WeakRef.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new WeakRef()[0]", + errors: [ + "Non-standard 'WeakRef.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new WeakRef()['0']", + errors: [ + "Non-standard 'WeakRef.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new WeakRef()['01']", + errors: [ + "Non-standard 'WeakRef.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new WeakRef(); foo.foo", + errors: [ + "Non-standard 'WeakRef.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: [ + "Non-standard 'WeakRef.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/rules/no-nonstandard-weakset-prototype-properties.js b/tests/lib/rules/no-nonstandard-weakset-prototype-properties.js new file mode 100644 index 00000000..54f5486e --- /dev/null +++ b/tests/lib/rules/no-nonstandard-weakset-prototype-properties.js @@ -0,0 +1,138 @@ +"use strict" + +const path = require("path") +const RuleTester = require("../../tester") +const rule = require("../../../lib/rules/no-nonstandard-weakset-prototype-properties.js") +const { + weakSetPrototypeProperties, +} = require("../../../lib/util/well-known-properties") +const ruleId = "no-nonstandard-weakset-prototype-properties" + +new RuleTester().run(ruleId, rule, { + valid: [ + "foo", + "foo.toString", + "foo.foo", + ...[...weakSetPrototypeProperties].map((p) => `new WeakSet().${p}`), + { code: "new WeakSet().unknown()", options: [{ allow: ["unknown"] }] }, + ], + invalid: [ + { + code: "new WeakSet().unknown()", + errors: [ + "Non-standard 'WeakSet.prototype.unknown' property is forbidden.", + ], + }, + { + code: "new WeakSet().foo", + errors: [ + "Non-standard 'WeakSet.prototype.foo' property is forbidden.", + ], + }, + { + code: "new WeakSet().bar", + errors: [ + "Non-standard 'WeakSet.prototype.bar' property is forbidden.", + ], + }, + { + code: "new WeakSet()[0]", + errors: [ + "Non-standard 'WeakSet.prototype.0' property is forbidden.", + ], + }, + { + code: "new WeakSet()['0']", + errors: [ + "Non-standard 'WeakSet.prototype.0' property is forbidden.", + ], + }, + { + code: "new WeakSet()['01']", + errors: [ + "Non-standard 'WeakSet.prototype.01' property is forbidden.", + ], + }, + ], +}) + +// ----------------------------------------------------------------------------- +// TypeScript +// ----------------------------------------------------------------------------- +const parser = require("@typescript-eslint/parser") +const tsconfigRootDir = path.resolve(__dirname, "../../fixtures") +const project = "tsconfig.json" +const filename = path.join(tsconfigRootDir, "test.ts") + +new RuleTester({ + languageOptions: { + parser, + parserOptions: { + tsconfigRootDir, + project, + disallowAutomaticSingleRunInference: true, + }, + }, +}).run(`${ruleId} TS Full Type Information`, rule, { + valid: [ + { filename, code: "foo" }, + { filename, code: "foo.toString" }, + { filename, code: "foo.foo" }, + { filename, code: "let foo = {}; foo.foo" }, + ...[...weakSetPrototypeProperties].map((p) => ({ + filename, + code: `new WeakSet().${p}`, + })), + ], + invalid: [ + { + filename, + code: "new WeakSet().foo", + errors: [ + "Non-standard 'WeakSet.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "new WeakSet().bar", + errors: [ + "Non-standard 'WeakSet.prototype.bar' property is forbidden.", + ], + }, + { + filename, + code: "new WeakSet()[0]", + errors: [ + "Non-standard 'WeakSet.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new WeakSet()['0']", + errors: [ + "Non-standard 'WeakSet.prototype.0' property is forbidden.", + ], + }, + { + filename, + code: "new WeakSet()['01']", + errors: [ + "Non-standard 'WeakSet.prototype.01' property is forbidden.", + ], + }, + { + filename, + code: "let foo = new WeakSet(); foo.foo", + errors: [ + "Non-standard 'WeakSet.prototype.foo' property is forbidden.", + ], + }, + { + filename, + code: "function f>(a: T) { a.baz }", + errors: [ + "Non-standard 'WeakSet.prototype.baz' property is forbidden.", + ], + }, + ], +}) diff --git a/tests/lib/util/define-prototype-method-handler/object-type-checker.js b/tests/lib/util/type-checker/object-type-checker.js similarity index 99% rename from tests/lib/util/define-prototype-method-handler/object-type-checker.js rename to tests/lib/util/type-checker/object-type-checker.js index e415a9c0..2c62f8be 100644 --- a/tests/lib/util/define-prototype-method-handler/object-type-checker.js +++ b/tests/lib/util/type-checker/object-type-checker.js @@ -4,7 +4,7 @@ const RuleTester = require("../../../tester") const { deepStrictEqual } = require("assert") const { buildExpressionTypeProvider, -} = require("../../../../lib/util/define-prototype-method-handler/object-type-checker") +} = require("../../../../lib/util/type-checker/object-type-checker") const { getLinter } = require("eslint-compat-utils/linter") const Linter = getLinter()