8000 Add `pre-commit` config for `eslint` by mattkram · Pull Request #259 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

Add pre-commit config for eslint #259

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 20 commits into from
May 9, 2022
Merged

Add pre-commit config for eslint #259

merged 20 commits into from
May 9, 2022

Conversation

mattkram
Copy link
Contributor
@mattkram mattkram commented May 6, 2022

Adds pre-commit configuration for eslint.

In my efforts to get this to work, I was unable to resolve a missing import in tsconfig.json. I was able to resolve this by replacing the extends field with three fields from the base template available at npm here.

After many commits, it ends up being a very simple PR 😄

@mattkram
Copy link
Contributor Author
mattkram commented May 6, 2022

I've exhausted my efforts to get this working. Open for help from anyone who knows more about eslint and Javascript tooling than me.

For reference, I have gotten so far as to have all the proper dependencies installed. However, with the project files as-is, I have two errors depending on whether this line is commented out or not. If it is commented out, this error is raised.

/code/pyscriptjs/examples/mario/js/bcoin.js
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: examples/mario/js/bcoin.js.
The file must be included in at least one of the projects provided

If it is not commented out, this error is raised.

/Users/mkramer/dev/pyscript/pyscriptjs/src/interpreter.ts
  0:0  error  Parsing error: File '@tsconfig/svelte/tsconfig.json' not found

@mattkram mattkram added the help wanted Extra attention is needed label May 6, 2022
@fpliger
Copy link
Contributor
fpliger commented May 6, 2022

Mmmm... does it work if you remove the Mario example?

@mattkram
Copy link
Contributor Author
mattkram commented May 7, 2022

Mmmm... does it work if you remove the Mario example?

That doesn't affect it. pre-commit runs on a file-by-file basis. This is a minimal command that reproduces the error I am getting:

$ pre-commit run eslint --files pyscriptjs/src/interpreter.ts

@mattkram
Copy link
Contributor Author
mattkram commented May 7, 2022

Update: I'm very close and I think will be able to resolve this

@mattkram mattkram force-pushed the mattkram/eslint-pre-commit branch from 27b3979 to 780ad9e Compare May 7, 2022 03:17
@mattkram
Copy link
Contributor Author
mattkram commented May 7, 2022

🎉 Time to clean things up 🎉

@@ -1,5 +1,7 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"$schema": "https://json.schemastore.org/tsconfig",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to replace this with values which were taken from the source npm package: https://www.npmjs.com/package/@tsconfig/svelte

This is because, while the import could be found locally when packages were installed in node_modules, it could not be found while pre-commit was running.

@mattkram mattkram marked this pull request as ready for review May 7, 2022 03:30
@mattkram
Copy link
Contributor Author
mattkram commented May 7, 2022

@fpliger we can also potentially remove lint.yaml, or we could leave it for a bit to ensure there are no lint errors let through by pre-commit.

@mattkram mattkram removed the help wanted Extra attention is needed label May 7, 2022
@jezdez
Copy link
Member
jezdez commented May 9, 2022

@mattkram +1 for removing it

@fpliger
Copy link
Contributor
fpliger commented May 9, 2022

@mattkram @jezdez In general, in this phase I'd like to lean towards action and if linting is on the way I'm +1 on removing it but capturing the intent to add it back after we worked on improving the current code state.

@pww217
Copy link
Contributor
pww217 commented May 9, 2022

This looks good to me @mattkram! Maybe let's merge for now and make sure it works fine in main, then we can remove lint.yml in this one #307

@mattkram
Copy link
Contributor Author
mattkram commented May 9, 2022

👍 Yeah, no harm duplicating lint.yaml in CI for now.

@mattkram mattkram merged commit 5332aad into main May 9, 2022
@mattkram mattkram deleted the mattkram/eslint-pre-commit branch May 9, 2022 19:55
KOSIDOCS pushed a commit to KOSIDOCS/pyscript that referenced this pull request May 10, 2022
* Add eslint config

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

5 participants
0