mirror of
https://github.com/facebook/react.git
synced 2026-02-23 20:23:02 +00:00
Lint rule for unminified errors (#15757)
* Lint rule for unminified errors Add a lint rule that fails if an invariant message is not part of the error code map. The goal is to be more disciplined about adding and modifiying production error codes. Error codes should be consistent across releases even if their wording changes, for continuity in logs. Currently, error codes are added to the error code map via an automated script that runs right before release. The problem with this approach is that if someone modifies an error message in the source, but neglects to modify the corresponding message in the error code map, then the message will be assigned a new error code, instead of reusing the existing one. Because the error extraction script only runs before a release, people rarely modify the error code map in practice. By moving the extraction step to the PR stage, it forces the author to consider whether the message should be assigned a new error code. It also allows the reviewer to review the changes. The trade off is that it requires more effort and context to land new error messages, or to modify existing ones, particular for new contributors who are not familiar with our processes. Since we already expect users to lint their code, I would argue the additional burden is marginal. Even if they forget to run the lint command locally, they will get quick feedback from the CI lint job, which typically finishes within 2-3 minutes. * Add unreleased error messages to map
This commit is contained in:
@@ -222,7 +222,6 @@
|
||||
"220": "Container does not support insertBefore operation",
|
||||
"221": "Tried to register two views with the same name %s",
|
||||
"222": "View config not found for name %s",
|
||||
"223": "Trying to release an event instance into a pool of a different type.",
|
||||
"224": "Can't read from currently-mounting component. This error is likely caused by a bug in React. Please file an issue.",
|
||||
"225": "Unexpected object passed to ReactTestInstance constructor (tag: %s). This is probably a bug in React.",
|
||||
"226": "Unsupported component type %s in test renderer. This is probably a bug in React.",
|
||||
@@ -321,5 +320,18 @@
|
||||
"319": "A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.",
|
||||
"320": "Expected ReactFiberErrorDialog.showErrorDialog to be a function.",
|
||||
"321": "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.",
|
||||
"322": "forwardRef requires a render function but was given %s."
|
||||
"322": "forwardRef requires a render function but was given %s.",
|
||||
"323": "React has blocked a javascript: URL as a security precaution.%s",
|
||||
"324": "An event responder context was used outside of an event cycle. Use context.setTimeout() to use asynchronous responder context outside of event cycle .",
|
||||
"325": "addRootEventTypes() found a duplicate root event type of \"%s\". This might be because the event type exists in the event responder \"rootEventTypes\" array or because of a previous addRootEventTypes() using this root event type.",
|
||||
"326": "Expected a valid priority level",
|
||||
"327": "Should not already be working.",
|
||||
"328": "Should have a work-in-progress.",
|
||||
"329": "Unknown root exit status.",
|
||||
"330": "Should be working on an effect.",
|
||||
"331": "Cannot flush passive effects while already rendering.",
|
||||
"332": "Unknown priority level.",
|
||||
"333": "This should have a parent host component initialized. This error is likely caused by a bug in React. Please file an issue.",
|
||||
"334": "accumulate(...): Accumulated items must not be null or undefined.",
|
||||
"335": "ReactDOMServer does not yet support the event API."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user