Skip to content

feat(eslint-plugin): [member-ordering] add callback as an ordering type of node #3354

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

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 12 additions & 4 deletions packages/eslint-plugin/src/rules/member-ordering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const objectConfig = (memberTypes: string[]): JSONSchema.JSONSchema4 => ({
export const defaultOrder = [
// Index signature
'signature',
'call-signature',

// Fields
'public-static-field',
Expand Down Expand Up @@ -122,9 +123,13 @@ export const defaultOrder = [
'method',
];

const allMemberTypes = ['signature', 'field', 'method', 'constructor'].reduce<
string[]
>((all, type) => {
const allMemberTypes = [
'signature',
'field',
'method',
'call-signature',
'constructor',
].reduce<string[]>((all, type) => {
all.push(type);

['public', 'protected', 'private'].forEach(accessibility => {
Expand Down Expand Up @@ -170,13 +175,14 @@ const functionExpressions = [
* @param node the node to be evaluated.
*/
function getNodeType(node: Member): string | null {
// TODO: add missing TSCallSignatureDeclaration
switch (node.type) {
case AST_NODE_TYPES.TSAbstractMethodDefinition:
case AST_NODE_TYPES.MethodDefinition:
return node.kind;
case AST_NODE_TYPES.TSMethodSignature:
return 'method';
case AST_NODE_TYPES.TSCallSignatureDeclaration:
return 'call-signature';
case AST_NODE_TYPES.TSConstructSignatureDeclaration:
return 'constructor';
case AST_NODE_TYPES.TSAbstractClassProperty:
Expand Down Expand Up @@ -216,6 +222,8 @@ function getMemberName(
: util.getNameFromMember(node, sourceCode);
case AST_NODE_TYPES.TSConstructSignatureDeclaration:
return 'new';
case AST_NODE_TYPES.TSCallSignatureDeclaration:
return 'call';
case AST_NODE_TYPES.TSIndexSignature:
return util.getNameFromIndexSignature(node);
default:
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy