-
Notifications
You must be signed in to change notification settings - Fork 404
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: Updated eslint configuration #2851
Conversation
2374e99
to
89ff244
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2851 +/- ##
==========================================
- Coverage 97.27% 97.22% -0.06%
==========================================
Files 296 296
Lines 46625 46635 +10
==========================================
- Hits 45354 45340 -14
- Misses 1271 1295 +24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
89ff244
to
af3771d
Compare
e7d8868
to
1073db7
Compare
1073db7
to
f1eaef1
Compare
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 a very large PR, i went through most. you removed all the ignoring of the no console and it won't show this as a warning because lint is quiet but not sure if we want to restore those or not. i also noticed now that lint is quiet there are a few tests that are using t.diagnostic
and they should prob be removed
|
||
// Suppressing a warning on this regex because it is not obvious what this | ||
// regex does, and we don't want to break anything. | ||
// eslint-disable-next-line sonarjs/slow-regex, sonarjs/duplicates-in-character-class |
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 should prob log a ticket to fix these slow regex
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.
Noted.
@@ -95,6 +95,7 @@ function _headerToCamelCase(header) { | |||
const newHeader = header.charAt(0).toLowerCase() + header.slice(1) | |||
|
|||
// Converts headers in the form 'header-name' to be in the form 'headerName' | |||
// eslint-disable-next-line sonarjs/slow-regex | |||
return newHeader.replace(/[\W_]+(\w)/g, function capitalize(m, $1) { |
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 should prob log a ticket to fix these slow regex
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.
Noted.
@@ -7,16 +7,19 @@ | |||
|
|||
module.exports = obfuscate | |||
|
|||
// eslint-disable-next-line sonarjs/slow-regex |
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 should probably log a ticket to address these slow regexs
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.
Noted.
@@ -97,9 +97,8 @@ test('Agent API - instrumentLoadedModule', async (t) => { | |||
const EMPTY_MODULE = {} | |||
let mod = EMPTY_MODULE | |||
try { | |||
// eslint-disable-next-line node/no-missing-require |
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 know this switched to eslint-plugin-n
but this still should fail, not sure what's going on 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.
The current configuration applies the eslint-plugin-node
"recommended" rules. The configuration in this PR omits them. I experimented with adding them back in yesterday afternoon, but it flagged a whole bunch of things as not supported prior to Node 18/20. It was doing so because it thinks we are trying to target >=16
(the finally fallback as described in https://github.com/eslint-community/eslint-plugin-n?tab=readme-ov-file#configured-nodejs-version-range).
I have implemented some tweaking of the rules for this code base and included it in my latest commit.
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.
OIC, it doesn't define the no-missing-require
: https://github.com/neostandard/neostandard/blob/main/lib/configs/base.js#L160
Supposedly it was set as "warn" in the original configuration https://github.com/newrelic/eslint-config-newrelic/blob/c5780025fff0c92d6d9012e6132e84fb42ad2459/index.js#L54C1-L54C26
Can you clarify this for me? How does the quiet flag affect the I set the main lint script to quiet because we have been ignoring warnings anyway. Do we want the noise to return and just keep overlooking it? |
We can address the |
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 npm run lint:fix
has to be run again. There are a bunch of warnings around object-shorthand
that gets fixed by re-running
Ah, okay. Those have been there since we migrated to |
Yep, fixed in #2858 |
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.
LGTM, we can always tweak this as we go
This PR resolve #2852.
This PR updates the eslint configuration, and plugins, to the latest. I discovered that our shared configuration has not kept up-to-date on the packages that it uses. In particular:
eslint
released v9 that radically changes (and simplifies) how configuration is written and parsed.eslint-plugin-node
has been out-of-maintenance for a long time, replaced byeslint-plugin-n
The result was a difficult to update shared configuration package. Now that this PR is ready, I could go back and update the shared package to eslint@9 standards, but I'm not convinced the shared package is worth the maintenance cost. Most of the configuration is specific to the repository. I am quite certain that most of the packages we maintain can get by with the simple
neostandard
configuration.Having been out-of-date for so long, our code base has developed many "errors" in regard to linting. The sonarjs plugin saw a lot of additions that now trigger errors. So there are many files touched in this PR. I took the approach of overriding the majority of rules for the tests, but using inline comments in the actual library code. I think our tests can be more lenient, and that we can investigate on a case-by-case basis all of the manual overrides.
I think we should wait for the
next
branch to be merged tomain
, at which point I will rebase and update this branch, before we merge. But I'm open to merging this first if the team thinks it will not cause too much strife in keepingnext
synchronized.