Skip to content

Commit

Permalink
eslint-config: add rule for config to work properly (#41272)
Browse files Browse the repository at this point in the history
Summary:
add [no-global-assign](https://eslint.org/docs/latest/rules/no-global-assign#rule-details) to react-native/eslint-config package.

without this rule, redefine global variable there is no hint,
<img width="462" alt="截屏2023-11-01 14 20 40" src="https://github.com/facebook/react-native/assets/130942798/ff87633d-b1a1-4a8f-9f3f-e2e30f5b87ab">
with this rule enabled:
<img width="648" alt="截屏2023-11-01 14 27 09" src="https://github.com/facebook/react-native/assets/130942798/23ec322f-66e2-49a3-b6df-b3ba2549681b">

platform: vscode@latest, macos@14.0 (23A344)
## Changelog:

[General] [Fixed]  - eslint config global vars redefine there is no message tip

<!-- Help reviewers and the release process by writing your own changelog entry.
- add `no-global-assign` to eslint config to enable globals
Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #41272

Test Plan: tested locally

Reviewed By: yungsters

Differential Revision: D50893943

Pulled By: cipolleschi

fbshipit-source-id: 2d418e1ca64722ebf48b52c2c0fe36fb392d7cb9
  • Loading branch information
Rick authored and facebook-github-bot committed Nov 2, 2023
1 parent 22c4099 commit a2a219c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/eslint-config-react-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ module.exports = {

'no-catch-shadow': 1, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
'no-delete-var': 1, // disallow deletion of variables
'no-global-assign': 2, // disallow assignments to native objects or read-only global variables
'no-label-var': 1, // disallow labels that share a name with a variable
'no-shadow': 1, // disallow declaration of variables already declared in the outer scope
'no-shadow-restricted-names': 1, // disallow shadowing of names such as arguments
Expand Down

0 comments on commit a2a219c

Please sign in to comment.