Skip to content

chore: migrate to neostandard #2920#3201

Open
johns70 wants to merge 3 commits intoelastic:mainfrom
johns70:issue-#2920
Open

chore: migrate to neostandard #2920#3201
johns70 wants to merge 3 commits intoelastic:mainfrom
johns70:issue-#2920

Conversation

@johns70
Copy link
Copy Markdown

@johns70 johns70 commented Feb 28, 2026

@JoshMock and @margaretjgu @voxpelli 🙏

Hello! This is one of the few contributions I have made as a Junior. I did problem #2920 of moving the project from ts-standard to neostandard to support ESLint 9.

I set up the new eslint.config.mjs file and made sure to ignore the src/api/ folder as the guide says. I also fixed some warnings in the tests (like the descriptions of Symbol() and some any types) so that the linter would have 0 errors.

I reviewed everything with npm run test:unit and all 613 tests passed. I hope everything is correct!
Here is a screenshot of the tests passing locally:
test

@johns70 johns70 requested a review from JoshMock as a code owner February 28, 2026 04:28
@prodsecmachine
Copy link
Copy Markdown

prodsecmachine commented Feb 28, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Member

@JoshMock JoshMock left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution, @johns70! I left a few comments and suggestions.

I'll also note that you've dropped the comments disabling no-misused-new, no-extraneous-class and no-unused-vars from many of the code-generated files, but in some of those files the no-unused-vars disable is still present. Because those code files are 100% generated from the Elasticsearch spec, it will be easier to be consistent with what disable rules are kept at the top of each file.

})

export default [
// Cargamos la configuración de neostandard
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this repo targets English as its primary language, please ensure any comments are in English as well.

// Archivos a IGNORAR (Esto limpia la carpeta src/api)
{
ignores: [
'src/api/**',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While ignoring src/api/ seems helpful, we do want neostandard or eslint to auto-fix simple linting issues when these files are regenerated from the specification; the code generator does its best to output files in a consistent format but some rules around whitespace, line breaks, etc. are fixed by the linter before generated code is committed.

Copy link
Copy Markdown

@voxpelli voxpelli left a comment

Choose a reason for hiding this comment

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

Some comments from my phone on my way to work 🙂

Thanks for the effort!

{
plugins: {
// Esto extrae el plugin de la base para que las reglas de abajo funcionen
'@typescript-eslint': baseConfig.find(c => c.plugins?.['@typescript-eslint'])?.plugins['@typescript-eslint']
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We export the plugins for convenience, use that instead: https://github.com/neostandard/neostandard#usage-of-exported-plugin


// Archivos a IGNORAR (Esto limpia la carpeta src/api)
{
ignores: [
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

package.json Outdated
"@types/split2": "4.2.3",
"@types/stoppable": "1.1.3",
"@typescript-eslint/eslint-plugin": "^8.56.1",
"@typescript-eslint/parser": "^8.56.1",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do not add these directly, you must use the ones included in neostandard due to how ESLint handles deduping in configs

package.json Outdated
"license-checker": "25.0.1",
"minimist": "1.2.8",
"ms": "2.1.3",
"neostandard": "^0.12.2",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can upgrade to version 0.13.0 now 🥳

ts: true
})

export default [
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider using defineConfig here: neostandard/neostandard#308

{
files: ['**/*.ts', '**/*.cts', '**/*.mts', '**/*.tsx'],
rules: {
'import-x/export': 'off'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No longer needed in Neostandard 0.13

// Esto extrae el plugin de la base para que las reglas de abajo funcionen
'@typescript-eslint': baseConfig.find(c => c.plugins?.['@typescript-eslint'])?.plugins['@typescript-eslint']
},
rules: {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would recommend adding a comment on each rule change describing why it's necessary and/or better. This helps both project owners and us Neostandard maintainers.

package.json Outdated
"test:integration": "npm run test:integration-build && env tap run --jobs=1 --reporter=junit --reporter-file=report-junit.xml generated-tests/",
"lint": "ts-standard src",
"lint:fix": "ts-standard --fix src",
"lint": "eslint .",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
"lint": "eslint .",
"lint": "eslint",

This is enough nowadays

@johns70
Copy link
Copy Markdown
Author

johns70 commented Mar 4, 2026

Hello, I hope you are well, thank you for the corrections and the advice, my apologies for the inconvenience, I will make the change to the code right now

@johns70
Copy link
Copy Markdown
Author

johns70 commented Mar 7, 2026

A quick question: since neostandard 0.13 no longer provides the import/export rule, ESLint now throws Definition for rule 'import/export' was not found for the files generated in src/api.

Can I remove the /* eslint-disable import/export */ comments from the generated files, or re-add the plugin in the configuration? @voxpelli

@voxpelli
Copy link
Copy Markdown

voxpelli commented Mar 9, 2026

@johns70 Remove the disable comments 👍

@johns70
Copy link
Copy Markdown
Author

johns70 commented Mar 13, 2026

Hi @JoshMock and @voxpelli ,

I hope you’re doing well. First of all, I want to apologize for how long it has taken me to make progress on this task; I haven’t had much time, and I try to use the minutes I have to move forward with my responsibilities. This task is very important to me.

The purpose of this message is to share some difficulties I’ve encountered with the linter regarding the auto-generated code in the lib and esm folders.

I’ve noticed that every time I run npm run test or npm run build, the files in lib and esm are regenerated automatically (I assume this is due to rimraf or another build mechanism, especially when running tests).

Because of this, when I try to use npx eslint . --fix, many style errors reappear—particularly indentation, semi, camelcase, and no-void. The --fix option cannot preserve changes in files that are regenerated.

So far, the only viable solutions I’ve found are:

Run npx eslint . --fix within the test script so that the auto-generated code is formatted automatically before running tests.

Completely ignore these folders in the ignore, although I’m somewhat hesitant because this could hide unexpected errors or break project consistency.

I’m not sure if I’m missing something in the Neostandard documentation that allows the linter to be permissive enough in certain cases with auto-generated code syntax. So far, I haven’t found another solution that is consistent and reliable.

My main question: is --fix intended to apply only to src files, or should it also work on generated code? And if it is expected to work on generated files, is there a recommended way to integrate it without having to ignore entire folders or run eslint --fix inside the tests?

Thank you for your time and guidance.

Best regards,

@JoshMock
Copy link
Copy Markdown
Member

Completely ignore these folders in the ignore

This is the correct approach. We only need linting to cover code in src, test and scripts.

@johns70
Copy link
Copy Markdown
Author

johns70 commented Mar 25, 2026

@voxpelli, @JoshMock. Hello guys, I hope you are very well. I just uploaded the changes you asked me for. If there is any detail or problem, do not hesitate to tell me so I can correct it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants