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

feat!: add new rules for jest, react, and typescript #171

Merged
merged 6 commits into from
Oct 6, 2021

Conversation

Francois-Esquire
Copy link
Contributor

BREAKING CHANGE added

  • @typescript-eslint/no-non-null-asserted-nullish-coalescing
  • @typescript-eslint/no-restricted-imports
  • jest/prefer-expect-resolves
  • jest/prefer-to-be
  • react/no-namespace

Description

Adding the new rules introduced by the updates to the jest, react and typescript-eslint plugins.

Detail

There were three plugins that were updated that introduced new rules:

@typescript-eslint/eslint-plugin version 4.32.0 CHANGELOG

  • @typescript-eslint/no-non-null-asserted-nullish-coalescing
  • @typescript-eslint/no-restricted-imports

eslint-plugin-jest version 24.5.0 CHANGELOG

  • jest/prefer-expect-resolves
  • jest/prefer-to-be

** There were deprecations made to the rule jest/prefer-to-be-null and jest/prefer-to-be-undefined in favor of jest/prefer-to-be - more detail can be found in this PR

eslint-plugin-react version 7.26.0 CHANGELOG

  • react/no-namespace

BREAKING CHANGE added
- @typescript-eslint/no-non-null-asserted-nullish-coalescing
- @typescript-eslint/no-restricted-imports
- jest/prefer-expect-resolves
- jest/prefer-to-be
- react/no-namespace
@Francois-Esquire Francois-Esquire requested a review from a team as a code owner October 1, 2021 15:00
plugins/jest.js Outdated Show resolved Hide resolved
plugins/jest.js Outdated Show resolved Hide resolved
plugins/react.js Outdated Show resolved Hide resolved
Comment on lines 251 to 257
// disallows using the non-null assertion on the left operand of the nullish coalescing operator
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 2,
// allows to specify new option `allowTypeImport` for path or pattern
'@typescript-eslint/no-restricted-imports': [2, {
paths: [],
patterns: []
}]
Copy link
Member

Choose a reason for hiding this comment

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

Please note that no-restricted-imports is an Extension Rule. Correct handling for an extension is to zero-out the base eslint rule at the top of this file, and then add the corresponding @typescript-eslint/no-restricted-imports rule with the very same syntax that we see in

// restrict usage of specified node imports
'no-restricted-imports': 0,

Copy link
Member

Choose a reason for hiding this comment

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

and ditto re: alphabetical 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, thanks for sharing this.

Copy link
Member

Choose a reason for hiding this comment

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

fwiw, it might still be a nice touch to add the no-restricted-imports: 0 to the top of this file just as a documented indicator that we're going with the typescript version of the rule now. Even though they are all 0 throughout 😛

Copy link

@mtomcal mtomcal left a comment

Choose a reason for hiding this comment

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

LGTM. These seem helpful updates!

@@ -190,6 +192,8 @@ module.exports = {
'@typescript-eslint/no-redeclare': bestPractices['no-redeclare'],
// disallows invocation of `require()`
'@typescript-eslint/no-require-imports': 2,
// allows to specify new option `allowTypeImport` for path or pattern
'@typescript-eslint/no-restricted-imports': 0,
Copy link
Member

Choose a reason for hiding this comment

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

Please use '@typescript-eslint/no-restricted-imports': es6['no-restricted-imports'] and knock out the baseline no-restricted-imports by setting it to zero in the top block of this file.

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

🎉

@Francois-Esquire Francois-Esquire merged commit 82f34e8 into main Oct 6, 2021
@Francois-Esquire Francois-Esquire deleted the francois-esquire/eslint-additions branch October 6, 2021 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants