Having trouble with @typescript-eslint/member-ordering feature not functioning properly?

Ensuring a precise ordering in TypeScript classes is my goal, with a specific emphasis on enforcing alphabetical order within groups.

To achieve this, I am refering to the following documentation:

Shown below is the member-ordering configuration extracted from my .eslintrc file:

"@typescript-eslint/member-ordering": [
      "error",
      {
          "default": {
            "memberTypes": [
              "public-static-field",
              "protected-static-field",
              "private-static-field",
              "public-instance-field",
              "public-decorated-field",
              "public-abstract-field",
              "protected-instance-field",
              "protected-decorated-field",
              "protected-abstract-field",
              "private-instance-field",
              "private-decorated-field",
              "private-abstract-field",
              "static-field",
              "public-field",
              "instance-field",
              "protected-field",
              "private-field",
              "abstract-field",
              "constructor",
              "public-static-method",
              "protected-static-method",
              "private-static-method",
              "public-method",
              "protected-method",
              "private-method"
            ],
            "order": "alphabetically"
          }
      }
    ],

In my current setup, no errors are being generated despite expecting 2 errors: incorrect member ordering (private should come after public) and incorrect alphabetical sequence.

Eslint is successfully running as I'm receiving other error notifications related to naming conventions and more.

Answer №1

Upon further examination, I have discovered that categorizing memberTypes and ordering separately is effective. Initially, it seemed as though the documentation combined these two properties, but now I suspect it may be a bug.

In my text editor:

Answer №2

Here is a collection of ordering rules influenced by this particular source:

// Index signature
"signature",
"call-signature&quOt;,

// Fields
"public-static-field&Quot;,
"protected-static-field&quoT;,
"private-static-field&QUOte;,
"#private-static-field&qUoT;&Comma;

"public-decorated-field"e;',
"protected-decorated-field"",
"private-decorated-field&qUOt;,

"public-instance-field&qUOf;&Comma;
"protected-instance-field&QuOT,;
"private-Instance-field&qquot;;;
"#private-inStAnCe-fiElD&sEMIquot;s

"publIc-entity-fielD&compLICAt;iOn&SemicolonS;
.......</answer2>
    </div></answer2>
<exanswer2><div class="answer" i="75024648" l="4.0" c="1672944072" v="-3" a="TS5TaGFo" ai="7798447">
<p>Explore this list inspired by <a href="https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/member-ordering.md#default-configuration" rel="nofollow noreferrer">this resource link</a>:</p>
<pre><code>// Index signature
"signature",
"call-signature",

// Fields
"public-static-field",
"protected-static-field",
"private-static-field&quoRt;,
"#private-stAtic-field",

"public-decorated-field&quOt;,
"protected-decorated-field&qUoT;,
"private-decorated-field&QUot;,

"public-instance-field",
"protected-instaNce-field",
"private-InstAnCe-fielD&qUoT;,
"#privAte-inStANcE-fiEld",

"public-abSTract-field",
"protecTed-aBStract-fIeld",

"pubLic-fiELd&QUoT;&Comma;
"prOTECTed-fIElD"&COmma;
"priVATe-FIELD&qUoT;&commA;
"#priVaTE-FieLd&qUoT;&CoMMA;

"statiC-fiElD&qUOT;&CoMmA;
"instAncE-fiELD"&coMMa;
"aBStraCT-FIelD&qUOT;&coMmA;

"dECOrateD-fiEld"&comMa;

"fiEld&qUOt;&compLaCE;

// Static initialization
"statIC-initiALization&qUot;&COMMA;

// Constructors
"puBliC-ConSTruCtor"&coMmA;
"protECTEd-coNsTructOR"&Comma;
"privatE-conStruCtoR&QuOt;&coMmA;

"cONstruCTor&qUOta&Cute;;

// Getters
"public-Static-get&quoT;&coMmA;
"ProtectED-sTaTiC-gEt&QuOT;&CoMmA;
"prIVAte-stAtiC-get&qUOt;&CoMMA;
"#PriVAte-STatic-gET&qUOt;&CoMmA;

"PubLiC-DecoRaTed-Get&qUOf;&CoplaSS;
"PROTECTED-DecORATEd-GET&QUOrd;&COmmasS;
"PRIVATE-DECorATED-GEt&qUSAnd;&comMAS;

"PuBLIC-insTance-GET"&comMasS;
"PRoTecTED-instANCe-Get<CommAsS;
"PrIVatE-instaNCE-Ge####&coMmasss;
"#privAte-iNsTanCE-geT&quoT;,&commAsss;

"MTrixCC&assss";</answer2>
<exanswer2><div class="answer" i="75024648" l="4.0" c="1672944072" v="-3" a="TS5TaGFo" ai="7798447">
<p>Go through this arrangement list following <a href="https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/member-ordering.md#default-configuration" rel="nofollow noreferrer">https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/member-ordering.md#default-configuration</a>:</p>
<pre><code>// Index signature
"signature",
"call-signature",

// Fields
"public-static-field",
"protected-static-field",
"private-static-field",
"#private-static-field",

"public-decorated-field",
"protected-decorated-field",
"private-decorated-field",

"public-instance-field",
"protected-instance-field",
"private-instance-field",
"#private-instance-field",

"public-abstract-field",
"protected-abstract-field",

"public-field",
"protected-field",
"private-field",
"#private-field",

"static-field",
"instance-field",
"abstract-field",

"decorated-field",

"field",

// Static initialization
"static-initialization",

// Constructors
"public-constructor",
"protected-constructor",
"private-constructor",

"constructor",

// Getters
"public-static-get",
"protected-static-get",
"private-static-get",
"#private-static-get",

"public-decorated-get",
"protected-decorated-get",
"private-decorated-get",

"public-instance-get",
"protected-instance-get",
"private-instance-get",
"#private-instance-get",

"public-abstract-get",
"protected-abstract-get",

"public-get",
"protected-get",
"private-get",
"#private-get",

"static-get",
"instance-get",
"abstract-get",

"decorated-get",

"get",

// Setters
"public-static-set",
"protected-static-set",
"private-static-set",
"#private-static-set",

"public-decorated-set",
"protected-decorated-set",
"private-decorated-set",

"public-instance-set",
"protected-instance-set",
"private-instance-set",
"#private-instance-set",

"public-abstract-set",
"protected-abstract-set",

"public-set",
"protected-set",
"private-set",
"#private-set",

"static-set",
"instance-set",
"abstract-set",

"decorated-set",

"set",

// Methods
"public-static-method",
"protected-static-method",
"private-static-method",
"#private-static-method",

"public-decorated-method",
"protected-decorated-method",
"private-decorated-method",

"public-instance-method",
"protected-instance-method",
"private-instance-method",
"#private-instance-method",

"public-abstract-method",
"protected-abstract-method",

"public-method",
"protected-method",
"private-method",
"#private-method",

"static-method",
"instance-method",
"abstract-method",

"decorated-method",

"method"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issues with Webpack and TypeScript CommonsChunkPlugin functionality not functioning as expected

Despite following various tutorials on setting up CommonsChunkPlugin, I am unable to get it to work. I have also gone through the existing posts related to this issue without any success. In my project, I have three TypeScript files that require the same ...

Creating a fresh ngx-translate pipeline (comparing pure and impure methods)

Edit: I am looking to enhance the functionality of ngx-translate's pipe by extending it. Here is an example of how I achieved this: import { Pipe, PipeTransform } from '@angular/core'; import { TranslatePipe } from "@ngx-translate/core"; @ ...

Retrieving node information from a local variable using d3

Is it possible to generate a d3 graph using a local variable jsonNodes (JSON data) instead of reading from a file? An example I found interesting is on Andrew-Reid’s bl.ocks page. Here's the code snippet I'm experimenting with. The 'Go&ap ...

Sending the HTML input value to a Knockout view

Can someone assist me with a dilemma I'm facing? Within CRM on Demand, I have a view that needs to extract values from CRM input fields to conduct a search against CRM via web service. If duplicate records are found, the view should display them. Be ...

Struggling to successfully pass a function as an argument to the setTimeout method within an array in node.js using TypeScript

Here is an example that successfully demonstrates a function being called using setTimeout: function displayMessage(msg: string){ console.log(msg); } setTimeout(displayMessage, 1000, ["Hi!"]; After one second, it will print out "Hi!" to the console. ...

Encountering SUID Sandbox Helper Issue When Running "npm start" on WSL with Electron and Typescript

Can anyone help me with this issue? I have Node v8.10.0 and I'm attempting to follow a beginner tutorial on Electron + Typescript which can be found at the following link: https://github.com/electron/electron-quick-start-typescript Here is the full e ...

I encountered a problem while integrating antd and moment.js in my React project

I am currently using the antd date-picker in my React project with TypeScript. Encountered an error: Uncaught Type Error: moment is not a function. If anyone has a solution, please assist me. .tsx file:: const dateFormat = 'MM-DD-YYYY'; < ...

Hey there world! I seem to be stuck at the Loading screen while trying to use Angular

A discrepancy in the browsers log indicates node_modules/angular2/platform/browser.d.ts(78,90): error TS2314: Generic type 'Promise' is missing 2 type arguments. ...

Encountering a problem when launching the "vite-express" template on the Remix app (TSConfckParseError: error resolving "extends")

I recently launched a brand-new [email protected] project using the remix-run/remix/templates/vite-express template after executing this command: npx create-remix@latest --template remix-run/remix/templates/vite-express However, upon trying to run th ...

Using AngularJS Scope to Map an Array within a JSON Array

I'm attempting to extract the type and url values from the media2 object within this JSON array and assign them to an AngularJS scope Array. "results":[ { "session2":[ { "__type":"Object", "abou ...

Will a JavaScript source map file continue to function properly even after the source code file has been minified?

My experience I specialize in utilizing TypeScript and Visual Studio to transform highly organized code into functional JavaScript. My skills involve configuring the project and Visual Studio to perform various tasks: Merging multiple compiled JavaScrip ...

`Unable to update the checked prop in MUI switch component`

The value of RankPermission in the switchPermission function toggles from false to true, but for some reason, the MUI Switch component does not update in the browser. I haven't attempted any solutions yet and am unsure why it's not updating. I&ap ...

Exploring the power of jQuery Ajax with JSON Data

I've been struggling to extract a specific part of the JSON response, but I can't seem to figure it out. json = '{ "now": "2010-09-23 22:06:53 EST", "data":[ {"id":"1","year":"2010","month":"09","day":"23","hours":"08","minutes":"09","se ...

Utilizing TypeScript's Type Inference to Simplify Function Combinations

I'm facing a challenge with what should be simple. The types aren't coming through as expected when trying to combine a couple of functions. Is there a way to have TypeScript infer the types without explicitly specifying them? import { pipe, map ...

The TypeError encountered in an Ionic pipe states that the property 'toString' cannot be read as it is undefined

I have a news application built in Ionic 4. The pubDate property of the UutinenPage class is being asynchronously assigned a value of data.items[this.id].pubDate in the uutinen.page.ts file. The expected format of this value is something like 2019-02-19 04 ...

Angular 13: Issue with Http Interceptor Not Completing Request

In my app, I have implemented a HtppInterceptor to manage a progress bar that starts and stops for most Http requests. However, I encountered an issue with certain api calls where the HttpHandler never finalizes, causing the progress bar to keep running in ...

Verify if the data in the Express request is an array

Recently, I've been working on an Express 3.x API server and facing the challenge of implementing support for batch requests at a specific endpoint. Despite not having the control to upgrade to 4.x, I am determined to find a solution. Currently, the e ...

Updating data in Angular reactive forms using asynchronous dropdowns

I am currently developing an Angular application and have encountered an issue that I am unable to resolve by solely reading the documentation. One of the components in my application is responsible for displaying a form: https://i.stack.imgur.com/p5KEU. ...

Displaying images from JSON in an Android application

So I have a JSON file that contains the following code: { "gejala": "Does the rust appear as bright yellow towards the tip of the leaves", "gejala_kode": "GJL0025", "penyakit_kode": "PNY0012", "gambar_gejala":"rust_on_leaves", "child": null } "rust_ ...

The decoded data is different from the original get request

Greetings everyone, I am new to Perl but have some experience with other programming languages. Recently, I created a simple code that retrieves a JSON file from the internet for a Telegram bot. However, when I display the data, everything seems fine. But ...