Skip to content

Commit

Permalink
Sort error keys with ESLint (#13020)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Mar 18, 2021
1 parent 21e8e59 commit beb7cf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/babel-parser/src/plugins/jsx/index.js
Expand Up @@ -19,11 +19,12 @@ import { Errors } from "../../parser/error";
const HEX_NUMBER = /^[\da-fA-F]+$/;
const DECIMAL_NUMBER = /^\d+$/;

/* eslint sort-keys: "error" */
const JsxErrors = Object.freeze({
AttributeIsEmpty:
"JSX attributes must only be assigned a non-empty expression",
MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>",
MissingClosingTagElement: "Expected corresponding JSX closing tag for <%0>",
MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>",
UnexpectedSequenceExpression:
"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
UnsupportedJsxValue:
Expand All @@ -32,6 +33,7 @@ const JsxErrors = Object.freeze({
UnwrappedAdjacentJSXElements:
"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?",
});
/* eslint-disable sort-keys */

// Be aware that this file is always executed and not only when the plugin is enabled.
// Therefore this contexts and tokens do always exist.
Expand Down
6 changes: 4 additions & 2 deletions packages/babel-parser/src/plugins/typescript/index.js
Expand Up @@ -59,6 +59,7 @@ type ParsingContext =
| "TypeMembers"
| "TypeParametersOrArguments";

/* eslint sort-keys: "error" */
const TSErrors = Object.freeze({
AbstractMethodHasImplementation:
"Method '%0' cannot have an implementation because it is marked abstract.",
Expand All @@ -70,8 +71,8 @@ const TSErrors = Object.freeze({
"Initializers are not allowed in ambient contexts.",
DeclareFunctionHasImplementation:
"An implementation cannot be declared in ambient contexts.",
DuplicateModifier: "Duplicate modifier: '%0'",
DuplicateAccessibilityModifier: "Accessibility modifier already seen.",
DuplicateModifier: "Duplicate modifier: '%0'",
EmptyHeritageClauseType: "'%0' list cannot be empty.",
EmptyTypeArguments: "Type argument list cannot be empty.",
EmptyTypeParameters: "Type parameter list cannot be empty.",
Expand All @@ -82,9 +83,9 @@ const TSErrors = Object.freeze({
"Index signatures cannot have the 'abstract' modifier",
IndexSignatureHasAccessibility:
"Index signatures cannot have an accessibility modifier ('%0')",
IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier",
IndexSignatureHasDeclare:
"Index signatures cannot have the 'declare' modifier",
IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier",
InvalidModifierOnTypeMember: "'%0' modifier cannot appear on a type member.",
InvalidTupleMemberLabel:
"Tuple members must be labeled with a simple identifier.",
Expand Down Expand Up @@ -119,6 +120,7 @@ const TSErrors = Object.freeze({
UnsupportedSignatureParameterKind:
"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got %0",
});
/* eslint-disable sort-keys */

// Doesn't handle "void" or "null" because those are keywords, not identifiers.
// It also doesn't handle "intrinsic", since usually it's not a keyword.
Expand Down

0 comments on commit beb7cf8

Please sign in to comment.