Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(typescript-estree): forbid computedEnumMember#11232

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
fisker wants to merge9 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
fromfisker:non-computed-enum-member
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
enum Foo {
1 = 2
}

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

45 changes: 8 additions & 37 deletionspackages/ast-spec/src/element/TSEnumMember/spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { Identifier } from '../../expression/Identifier/spec';
import type { StringLiteral } from '../../expression/literal/StringLiteral/spec';
import type { Expression } from '../../unions/Expression';
import type {
PropertyNameComputed,
PropertyNameNonComputed,
} from '../../unions/PropertyName';

interfaceTSEnumMemberBase extends BaseNode {
exportinterfaceTSEnumMember extends BaseNode {
type: AST_NODE_TYPES.TSEnumMember;
computed: boolean;
id:
| PropertyNameComputed // this should only happen in semantically invalid code (ts error 1164)
| PropertyNameNonComputed;
id: Identifier | StringLiteral;
initializer: Expression | undefined;
/**
* @deprecated the enum member is always non-computed.
*/
computed: boolean;
}

/**
* this should only really happen in semantically invalid code (errors 1164 and 2452)
*
* @example
* ```ts
* // VALID:
* enum Foo { ['a'] }
*
* // INVALID:
* const x = 'a';
* enum Foo { [x] }
* enum Bar { ['a' + 'b'] }
* ```
*/
export interface TSEnumMemberComputedName extends TSEnumMemberBase {
computed: true;
id: PropertyNameComputed;
}

export interface TSEnumMemberNonComputedName extends TSEnumMemberBase {
computed: false;
id: PropertyNameNonComputed;
}

export type TSEnumMember =
| TSEnumMemberComputedName
| TSEnumMemberNonComputedName;

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

10 changes: 4 additions & 6 deletionspackages/eslint-plugin/src/rules/naming-convention.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -631,12 +631,10 @@ export default createRule<Options, MessageIds>({

// #region interface

'TSEnumMember[computed != true]': {
handler: (
node: TSESTree.TSEnumMemberNonComputedName,
validator,
): void => {
const id = node.id;
TSEnumMember: {
handler: (node: TSESTree.TSEnumMember, validator): void => {
// Unknown reason, can't get the correct type
const id = node.id as TSESTree.Identifier | TSESTree.StringLiteral;
Comment on lines +636 to +637
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I think the build script is using the published package instead of local one. I tried to useworkspace:^, but still can't build.

const modifiers = new Set<Modifiers>();

if (requiresQuoting(id, compilerOptions.target)) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp