oui icon indicating copy to clipboard operation
oui copied to clipboard

Add scripts to `lint-es` script

Open BSFishy opened this issue 2 years ago • 9 comments

Currently, lint-es only lints src and src-docs. It would be nice to also have the scripts directory linted by this script too.

BSFishy avatar Oct 16 '23 19:10 BSFishy

Hi, can I take this issue? Thank you!

MadaniKK avatar Oct 16 '23 20:10 MadaniKK

Hi, can I take this issue? Thank you!

Sure! This should be pretty easy. Feel free to ping if you run into any issues!

BSFishy avatar Oct 16 '23 20:10 BSFishy

I

Hi, can I take this issue? Thank you!

Sure! This should be pretty easy. Feel free to ping if you run into any issues!

Is it just adding one line in the .sass_lint.yml? I am not very familiar with linter..

MadaniKK avatar Oct 17 '23 04:10 MadaniKK

Nope, this should just be updating the lint-es script in package.json:

https://github.com/opensearch-project/oui/blob/ae0171d5fd0ffb9237367d2d8e351be9d4638623/package.json#L25

Currently we are checking directories {src,src-docs}, but we want {src,src-docs,scripts}. This will also most likely involve running yarn lint-es-fix, as we previously weren't linting that folder, so there is most likely some places where the linter will snag

BSFishy avatar Oct 17 '23 17:10 BSFishy

Ah, that makes sense! Thank you for your instructions! Also right now running yarn lint-es --fix returned some errors. It looks like the .js files in scripts/ should be using import statements instead of require. Should I disable this specific es-lint rule or should I change all the requires? image

MadaniKK avatar Oct 18 '23 02:10 MadaniKK

Should I disable this specific es-lint rule or should I change all the requires?

I don't think we want to disable the ESLint rule, as that will disable it for the entire project, which we don't want. Why don't you test and see if the import statement will work? I'm usually a little scared to use import statements in scripts run directly by Node, but we should be at a late enough version that they work as expected.

BSFishy avatar Oct 18 '23 17:10 BSFishy

I don't think we want to disable the ESLint rule, as that will disable it for the entire project, which we don't want. Why don't you test and see if the import statement will work? I'm usually a little scared to use import statements in scripts run directly by Node, but we should be at a late enough version that they work as expected.

I tried changing them into import, but it looks like it will break a lot of things when running yarn start..... I am using node 18.18.0... I tried setting the package.json file "type": "module" to use ESM... but that will break other things too So now I am not sure what to do. image

MadaniKK avatar Oct 18 '23 22:10 MadaniKK

Yeah I was worrying we would see something like that. Not sure about how to go forward in that case... Looping in @AMoo-Miki and @joshuarrrr

BSFishy avatar Oct 19 '23 01:10 BSFishy

Summary from office hours: let's convert the imports back into the require syntax and figure out how to conditionally suppress the @typescript-eslint/no-var-requires for the scripts directory.

BSFishy avatar Nov 01 '23 17:11 BSFishy