Skip to content
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

Add support for linting example scripts #17225

Merged
merged 9 commits into from
Dec 22, 2019
Merged

Conversation

gkjohnson
Copy link
Collaborator

@gkjohnson gkjohnson commented Aug 9, 2019

I feel like I've see quite a few PRs that introduce code-style issues into the examples files -- this should make it easier to automatically catch those problems. This is can be changed to lint the module files (or both?) once #16920 is merged.

Note this is expected to fail until the linting issues are fixed.

In another PR we can enable linting on the HTML files

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 10, 2019

Note this is expected to fail until the linting issues are fixed.

Maybe it's better to first fix the styles before merging this. Otherwise travis will die for all PRs in the next time until somebody cleans everything up. I'd like to avoid that since everyone will ignore travis and miss real/important linter/test errors.

@gkjohnson
Copy link
Collaborator Author

Maybe it's better to first fix the styles before merging this.

Oh I definitely agree. I added this now just to propose the idea (and see how many linting errors there actually were).

I'd start fixing the issues now but with #16920 it seems unclear whether or not it's worth proposing new fixes to the js example files or waiting to lint the jsm ones. Any thoughts?

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 10, 2019

I think we can wait. The issue is not that urgent. I would proceed with this PR as soon as #16920 lands.

@gkjohnson gkjohnson mentioned this pull request Sep 2, 2019
3 tasks
@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 17, 2019

Okay, since #16920 will not be merged, it's okay to solve the linter issues for all js files and the run node/modularize.js.

It seems that almost all linter errors are produce in the js/shaders directory. Additional tabs are used to format the GLSL shader code. The problem is instead of this:

"void main() {",

    "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",

"}"

we would have to do this:

"void main() {",

"    gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",

"}"

So the padding is applied within the string. I'm not sure somebody want's to change all the files by hand...

@gkjohnson
Copy link
Collaborator Author

@Mugen87 Sounds good to me -- I'll update this PR when I get the chance and can start contributing linting fixes to the examples.

@gkjohnson
Copy link
Collaborator Author

Just updated the examples lint command -- once #17542 and #17541 are merged this should pass the CI check.

@gkjohnson
Copy link
Collaborator Author

Okay this should pass now -- it looks like there are still some linter warnings mostly of the "no-unused-vars" flavor but those shouldn't cause CI to break and can be fixed in subsequent PRs.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 18, 2019

I remember now that @mrdoob does not want to apply strict linter rules to the examples code in order to simplify contribution. I think we can get this merged if we let the current lint command unchanged (npm run lint) and just add npm run lint-examples.

@gkjohnson
Copy link
Collaborator Author

@Mugen87 Sounds good -- I've updated the PR so there are just lint and lint-examples scripts.

The lint script lints the js and ts files in /src and the lint-examples script lints the js and ts files in /examples/jsm!

@mrdoob
Copy link
Owner

mrdoob commented Dec 20, 2019

LGTM!

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 20, 2019

The lint script lints the js and ts files in /src

It actually lints the TS files in examples, too. I guess we should change tsconfig.lint.json so it works like you have described.

@gkjohnson
Copy link
Collaborator Author

It actually lints the TS files in examples, too. I guess we should change tsconfig.lint.json so it works like you have described.

Yup! Sorry looks like I forgot to commit that change. I've added it now!

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 20, 2019

@mrdoob This looks good now!

@Mugen87 Mugen87 added this to the r112 milestone Dec 21, 2019
@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 22, 2019

Let's merge this 👍

@Mugen87 Mugen87 merged commit 75cd81c into mrdoob:dev Dec 22, 2019
@mrdoob
Copy link
Owner

mrdoob commented Dec 22, 2019

Thanks!

@gkjohnson gkjohnson deleted the lint-examples branch January 4, 2020 01:54
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.

3 participants