Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test for recommended rule doc notice #1619

Merged
merged 3 commits into from Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/rules/custom-error-definition.md
@@ -1,7 +1,5 @@
# Enforce correct `Error` subclassing

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*

Enforces the only valid way of `Error` subclassing. It works with any super class that ends in `Error`.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/import-index.md
@@ -1,7 +1,5 @@
# Enforce importing index files with `.`

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*

Enforces importing index file with `.` instead of `./`, `./index` or `./index.js`.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-keyword-prefix.md
@@ -1,7 +1,5 @@
# Disallow identifiers starting with `new` or `class`

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

`new Foo` and `newFoo` look very similar. Use alternatives that do not look like keyword usage.

## Fail
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-unsafe-regex.md
@@ -1,7 +1,5 @@
# Disallow unsafe regular expressions

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

Uses [safe-regex](https://github.com/substack/safe-regex) to disallow potentially [catastrophic](https://regular-expressions.mobi/catastrophic.html) [exponential-time](https://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html) regular expressions.

## Fail
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/no-unused-properties.md
@@ -1,7 +1,5 @@
# Disallow unused object properties

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

Unused properties, much like unused variables, are often a result of incomplete refactoring and may confuse readers.

This rule is primarily useful when you use objects to group constants or model enumerations. It is much harder to predict class properties usage, and practically impossible to predict reflective property access. This rule ignores cases like that.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/prefer-at.md
@@ -1,7 +1,5 @@
# Prefer `.at()` method for index access and `String#charAt()`

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*

Prefer [`Array#at()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at), [`String#at()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at), and `{TypedArray,NodeList,CSSRuleList,…}#at()` for index access and `String#charAt()`.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/prefer-object-has-own.md
@@ -1,7 +1,5 @@
# Prefer `Object.hasOwn(…)` over `Object.prototype.hasOwnProperty.call(…)`

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*

[`Object.hasOwn(…)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn) is more accessible than `Object.prototype.hasOwnProperty.call(…)`.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/prefer-string-replace-all.md
@@ -1,7 +1,5 @@
# Prefer `String#replaceAll()` over regex searches with the global flag

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*

The [`String#replaceAll()`](https://github.com/tc39/proposal-string-replaceall) method is both faster and safer as you don't have to escape the regex if the string is not a literal.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/prefer-top-level-await.md
@@ -1,7 +1,5 @@
# Prefer top-level await over top-level promises and async function calls

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

💡 *This rule provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*

[Top-level await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top-level-await) is more readable and can prevent unhandled rejections.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/require-post-message-target-origin.md
@@ -1,7 +1,5 @@
# Enforce using the `targetOrigin` argument with `window.postMessage()`

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

💡 *This rule provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*

When calling [`window.postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) without the `targetOrigin` argument, the message cannot be received by any window.
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/string-content.md
@@ -1,7 +1,5 @@
# Enforce better string content

✅ *This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*

Enforce certain things about the contents of strings. For example, you can enforce using `’` instead of `'` to avoid escaping. Or you could block some words. The possibilities are endless.
Expand Down
2 changes: 1 addition & 1 deletion test/package.mjs
Expand Up @@ -236,7 +236,7 @@ test('Every rule has a doc with the appropriate content', t => {
// Decide which notices should be shown at the top of the doc.
const expectedNotices = [];
const unexpectedNotices = [];
if (index.configs.recommended.rules[`unicorn/${ruleName}`]) {
if (['error', 'warn'].includes(index.configs.recommended.rules[`unicorn/${ruleName}`])) {
expectedNotices.push('configRecommended');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!= 'off',, I believe template-indent was configured as warn.

Copy link
Sponsor Contributor Author

@bmish bmish Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to switch to includes to avoid no-negated-condition.

} else {
unexpectedNotices.push('configRecommended');
Expand Down