-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
chore: update eslint to fix linting issues #29988
Conversation
// if (process.env.NODE_ENV !== `test`) { | ||
// ignore.push(`**/__tests__`) | ||
// } |
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 breaks linting as babel will return an empty ast. Packages should be build with babel src --out-dir . --ignore \"**/__tests__\"
"prettier/flowtype", | ||
"prettier/react", |
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.
these are now inside prettier
], | ||
plugins: ["flowtype", "prettier", "react", "filenames"], | ||
plugins: [`flowtype`, `prettier`, `react`, `filenames`, `@babel`], |
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.
Added @babel to augment the this rules
"prefer-promise-reject-errors": `warn`, | ||
"no-prototype-builtins": `warn`, | ||
"guard-for-in": `warn`, |
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.
These are new rules and moved them to warnings because there were too many.
.eslintrc.js
Outdated
"prefer-promise-reject-errors": `warn`, | ||
"no-prototype-builtins": `warn`, | ||
"guard-for-in": `warn`, | ||
"spaced-comment": [`error`, `always`, { markers: [`/`] }], |
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.
enable typescript /// referrence
comments
camelcase: [ | ||
`error`, | ||
{ | ||
properties: `never`, | ||
ignoreDestructuring: true, | ||
allow: [`^unstable_`], | ||
}, | ||
], |
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 have no idea why this wasn't necessary before 🤷
@@ -1,4 +1,4 @@ | |||
/* global __PATH_PREFIX__ CMS_PUBLIC_PATH */ | |||
/* global CMS_PUBLIC_PATH */ |
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.
PATH_PREFIX is in the global globals list
if (node.url.indexOf(`images.ctfassets.net`) === -1) { | ||
return resolve() | ||
} |
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 is really weird and I'm astonished that this hasn't lead to any bugs.
@@ -71,12 +71,12 @@ const doesConfigChangeRequireRestart = ( | |||
const getDebugPort = (port?: number): number => port ?? 9229 | |||
|
|||
export const getDebugInfo = (program: IProgram): IDebugInfo | null => { | |||
if (program.hasOwnProperty(`inspect`)) { | |||
if (Object.prototype.hasOwnProperty.call(program, `inspect`)) { |
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 fixing this rule but eventually moved to warning.
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.
Can you explain why this is needed?
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.
https://eslint.org/docs/rules/no-prototype-builtins
It's a security risk as technically program could have overwritten hasOwnProperty
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.
Neat. I'd not thought of that
@@ -784,7 +784,7 @@ export const createWebpackUtils = ( | |||
], | |||
...eslintConfig(schema, jsxRuntimeExists), | |||
} | |||
//@ts-ignore | |||
// @ts-ignore |
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.
Now I'm wondering why our ts rules are allowing 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.
Do we have a lint rule for the space in typescript?
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.
No, but we do have a rule that requires a description when there's a ts-ignore comment
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.
It's only a warning :)
"@typescript-eslint/ban-ts-comment": [
`warn`,
{ "ts-ignore": `allow-with-description` },
],
Co-authored-by: Matt Kane <[email protected]>
* chore: update eslint to fix linting issues * cleanup * remove / * Update packages/gatsby/src/commands/serve.ts Co-authored-by: Matt Kane <[email protected]> * update config * update circle to keep babel-preset-gatsby-package so we can use it in our babel config * fix unit tests * fix snapshot * fix thigns * update gatsby-node Co-authored-by: Matt Kane <[email protected]>
Description
Upgraded eslint to latest and fixed rules along the way.
Documentation
Related Issues