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

#570: Extract and deduplicate webpack resolution config #761

Merged
merged 4 commits into from
Jul 12, 2021

Conversation

fregante
Copy link
Collaborator

@fregante fregante commented Jul 11, 2021

This was low priority but the solution was pretty simple:

  • extract resolutions into shared file
  • point eslint to this file
  • import file from both webpack.browsers.js and webpack.scripts.js

In the future:

Side note: The plugin is quite buggy in general (350 open issues for a single eslint plugin) so we might not always be able to follow its suggestions.

.eslintrc Outdated

// TODO: Restore these after https://github.com/benmosher/eslint-plugin-import/issues/1931
// TODO: Restore this after linting the codebase
// "plugin:import/errors",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This PR does not attempt to lint the codebase, so I can't enable this preset yet because it will fail the build. Also it's just possible that it's because YAML isn't working with eslint even without the shared configuration. Example:

   24:3   error    Schema not found in '@cfworker/json-schema'                                                                                                                                                                                                                    import/named
   25:3   error    ValidationResult not found in '@cfworker/json-schema'                                                                                                                                                                                                          import/named

Copy link
Contributor

Choose a reason for hiding this comment

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

that it's because YAML isn't working with eslint

The @cfworker/json-schema package is written in Typescript: https://github.com/cfworker/cfworker/tree/main/packages/json-schema/src

Not sure what you mean by YAML isn't working?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

YAML isn't working with eslint

I mean that import './file.yaml' has a behavior defined by a webpack loader, it means nothing in node/JS, and my guess was that those imports were causing errors with this plugin for this reason.

However the errors were because the import/named rule doesn't understand type imports. Schema is just a type and it cannot find it. Since these are handled by TypeScript, I now disabled the rule.

I ended up fixing the one remaining issue so import/errors is now fully enabled.

@fregante fregante marked this pull request as ready for review July 11, 2021 21:05
Copy link
Contributor

@twschiller twschiller left a comment

Choose a reason for hiding this comment

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

Move the comment back to avoid future confusion: #761 (comment)

@twschiller
Copy link
Contributor

@fregante Approved - go ahead an merge when ready

image

@fregante fregante merged commit e355c90 into main Jul 12, 2021
@fregante fregante deleted the dev/enable-eslint-import-rules branch July 12, 2021 14:54
@fregante
Copy link
Collaborator Author

That's a charming way to say ":shipit:"

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.

Re-enable eslint import plugin
2 participants