-
Notifications
You must be signed in to change notification settings - Fork 150
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
Linting #1337
Linting #1337
Conversation
781032c
to
4b70a76
Compare
8a60d1a
to
7b2ae6b
Compare
d27c817
to
e760a1a
Compare
@goosewobbler think this looks good. just to be clear, this just puts the rules in place but doesnt run them or enforce anything yet? |
@mholtzman that's correct. The original plan was to merge fixes into this branch but I think smaller PRs is better. I just removed the pre-commit hook so we can merge this and see the output on running the lint script. The config changes a fair bit in #1346 but that's fine and I think that PR is close too, just need to resolve the noop and the other remaining issues which I listed here. We can then follow up with the other items in the TODO above as separate PRs, one by one. The rules will be enforced when we enable the pre-commit hook. |
Socket Security Pull Request Report👍 No new dependency issues detected in pull request Pull request report summary
Bot CommandsTo ignore an alert, reply with a comment starting with Ignoring: Powered by socket.dev |
@SocketSecurity ignore core-js@3.29.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lgtm, just a couple minor nits
eslint.config.mjs
Outdated
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
process: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want process
to be available globally in all browser type files? seems like this might be a good case for one-of exceptions in individual files if we have any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's available everywhere in the renderer process though
https://www.electronjs.org/docs/latest/api/process#sandbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't a global, it's Electron's process object which gets imported from the Electron library like import { process } from 'electron
'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was sure that some renderer files have a global, anyway I'll try the exception route and put what I find here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, here are the renderer files where we're accessing a global process:
Line 15 in 9250bbf
if (process.env.NODE_ENV !== 'development') { |
Line 15 in 9250bbf
if (process.env.NODE_ENV !== 'development') { |
Line 15 in 9250bbf
if (process.env.NODE_ENV !== 'development') { |
Line 15 in 9250bbf
if (process.env.NODE_ENV !== 'development') { |
Entry points basically - I'll add an entry for these as the global isn't available any further up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we must be doing something to inject this value somewhere, though I'm not sure where. when I try to print process.env
to the console it shows undefined
, but process.env.NODE_ENV
shows "development". are we somehow mapping this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think it's due to bullet point #4 here: https://en.parceljs.org/env.html#%F0%9F%8C%B3-environment-variables
Follow-up to #1310 with reduced scope and improved config, cutting the number of issues by ~75%. Most issues to fix are things like unused vars. I believe this is a nice balance between fixing low-risk, low-hanging fruit and having a good base to build on - as we rewrite bits of Frame and convert more of the codebase to TS we can gradually enable more rules, remove exemptions and generally tighten things up.
Enabling ESLint in VS Code
Install the ESLint extension, switch it to the pre-release version (they are slow with official releases it seems) and add the following config to your
.vscode/settings.json
in the Frame repo you want to lint:These config items shouldn't be required when ESLint v9 is released and when Eslint supports
eslint.config.mjs
, see the following issues for context:eslint/eslint#16580
microsoft/vscode-eslint#1518
Config & Plugins
As per previous PR, but reduced.
@typescript-eslint/eslint-plugin
- flags TS issues, especially around type safety (basic config used for now)eslint-plugin-jest
- flags antipatterns in our tests (rules disabled for now)eslint-plugin-react
- flags antipatterns in React usageeslint-plugin-react-hooks
- flags misuse of hooks in Reacteslint-plugin-testing-library
- flags issue & provides tips aroundtesting-library
usage - all issues fixed by #1334Future work (tickets to be added to maintenance scope)
@typescript-eslint/recommended-requiring-type-checking
(address issues - refactoring likely, requires stricter use of TS)eslint-plugin-react
&eslint-plugin-react-hooks
for TSX (when we start using TS in renderer)eslint-plugin-import
(imports - blocked by flat config support - tracked in [Feature Request] Support new ESLint flat config import-js/eslint-plugin-import#2556)eslint-plugin-comments
(keeps track of eslint comment usage - abandoned, eventually will move to eslint-community org)eslint-plugin-n
(node - lifeboat from abandonedeslint-plugin-node
, eventually...maybe another year...will be unforked)eslint-plugin-promise
(promises)eslint-plugin-jsx-a11y
(jsx accessibility)eslint-plugin-security
(node security)eslint-plugin-markdown
(markdown, useful if we end up expanding our repo docs)eslint-plugin-sonarjs
(bugs & suspicious patterns)eslint-plugin-unicorn
(misc rules)TODO (* can be punted to a follow-up in order to reduce PR size)
.eslintrc
support will be removed in Eslint v9).jsx
extension in all files using it - Parcel should ensure this just works (tm)