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

Cleanup eslint config #562

Merged
merged 9 commits into from
Jun 21, 2021
Merged

Cleanup eslint config #562

merged 9 commits into from
Jun 21, 2021

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Jun 21, 2021

Setup for #536
Includes parts of #513

This PR ensures that the lint script actually runs without errors.

Before moving onto adding further plugins, I think it's best to fix existing errors first.

+ prettier on eslintrc
+ hides warning by updating eslint dependency
.eslintrc Show resolved Hide resolved
.eslintrc Show resolved Hide resolved
run: |
echo "::remove-matcher owner=eslint-compact::"
echo "::remove-matcher owner=eslint-stylish::"
npm run lint
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Codacy only tracks changes, but not existing files. I added this CI job to ensure that all files are affected by new rules.

Possible improvements:

  • Run this job only if the lockfile or eslint config has changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The workflow would be this, if interested, but I think it's best to just leave it running at all times. It costs nothing and it already passes thanks to this PR 🎉

lint.yml
name: Lint

on:
  push:
    branches:
      - "*"
    path:
      - .eslintrc
      - package-lock.json

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "14.x"
      - uses: bahmutov/npm-install@v1

      # Run eslint without GitHub Actions annotations
      # https://stackoverflow.com/a/65964721/288906
      - name: npm run lint
        run: |
          echo "::remove-matcher owner=eslint-compact::"
          echo "::remove-matcher owner=eslint-stylish::"
          npm run lint

import reactTemplate from "@contrib/templates/reader-react.txt";
import menuTemplate from "@contrib/templates/foundation-menu-item.txt";
import panelTemplate from "@contrib/templates/foundation-panel.txt";
import blueprintTemplate from "@contrib/templates/blueprint-menu.txt";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the docs:

asset/source exports the source code of the asset. Previously achievable by using raw-loader.

From a quick check of the dist/options.js, it seems to work, but a raw string is exported instead of a function. Can you run this code to ensure it still works?

Before

Screen Shot 21

After

Screen Shot 22

Copy link
Contributor

Choose a reason for hiding this comment

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

@fregante You can test this by 1) going to the workshop, 2) clicking create new brick, and 3) selecting a template from the dropdown

See documentation for more information on accessing: https://docs.pixiebrix.com/developer-guide/workshop-basics#202afa4a0c0b4c449031d30540ba9a5d

Copy link
Contributor Author

@fregante fregante Jun 21, 2021

Choose a reason for hiding this comment

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

Thanks! With your steps I'll find my way around the code base over time. As you said going from the UI to the code is as easy as searching a string, but code -> UI takes a bit more time.

Anyway, tested and it works 👍

Screen Shot

src/polyfills/registerPolyfill.ts Outdated Show resolved Hide resolved
@fregante fregante marked this pull request as ready for review June 21, 2021 11:16
@twschiller
Copy link
Contributor

@fregante see comment on how to test.

Also, I merged in the prettier PR you made, so you might need to re-run on these files? Do we need to fix the prettier configuration in pre-commit: http://github.com/pixiebrix/pixiebrix-extension/blob/7e46cde8f20cc265af7668d1d40c98a2bab9160a/.pre-commit-config.yaml#L13-L13?

@fregante
Copy link
Contributor Author

Prettier run, PR ready to merge.

@twschiller twschiller merged commit 354a632 into main Jun 21, 2021
@twschiller twschiller deleted the dx/eslint branch June 21, 2021 22:32
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.

2 participants