Fixes #39383 - add no-magic-numbers js lint rule#11008
Conversation
14baf3e to
0239ad7
Compare
|
Thanks, updated to have export const MS_PER_SECOND = 1000;
export const PERCENT_MULTIPLIER = 100;
export const HTTP_STATUS_CODES = { ...Also changed the rule to be an error and not a warning so the git action will fail when magic numbers are used (for easier reviewing experience) |
0239ad7 to
ca04d1d
Compare
stejskalleos
left a comment
There was a problem hiding this comment.
A few last comments; plus it needs a rebase; otherwise, LGTM.
ca04d1d to
40d82f2
Compare
|
Thanks @stejskalleos - resolved the comments, rebased, and updated newly added numbers to use consts |
The Foreman linting requires constants to be declared instead of directly assigning numbers to variables. Otherwise, it will through the 'no-magic-numbers' error. Corresponding Foreman core PR: theforeman/foreman#11008 Co-Authored-By: OpenAI Codex
The Foreman linting requires constants to be declared instead of directly assigning numbers to variables. Otherwise, it will through the 'no-magic-numbers' error. Corresponding Foreman core PR: theforeman/foreman#11008 Co-Authored-By: OpenAI Codex
|
Looks like this made theforeman/foreman_rh_cloud#1231 fail because rh-cloud tests are not pinned to a particular version of foreman. |
|
@Odilhao I'll get to fixing the plugins, or plugins contributors can fix the errors themselves. There are 2 more PRs that effect plugin lint that are awaiting review/merge |
The Foreman linting requires constants to be declared instead of directly assigning numbers to variables. Otherwise, it will through the 'no-magic-numbers' error. Corresponding Foreman core PR: theforeman/foreman#11008 Co-Authored-By: OpenAI Codex
The Foreman linting requires constants to be declared instead of directly assigning numbers to variables. Otherwise, it will through the 'no-magic-numbers' error. Corresponding Foreman core PR: theforeman/foreman#11008 Co-Authored-By: OpenAI Codex
which PRs are those? |
* Fix no-magic-numbers lint errors Foreman core theforeman/foreman#11008 added the no-magic-numbers ESLint rule to the shared lint config used to lint plugin JS via `npm run lint:plugins`. Extract the affected numeric literals into named constants so foreman_rh_cloud's plugin lint check passes again. * Address review: dedupe SECONDS_PER_MINUTE/PERCENT_COMPLETE, document delays - Extract SECONDS_PER_MINUTE and PERCENT_COMPLETE into a shared TaskConstants module used by both TaskHistory and TaskProgress, instead of duplicating the constants in each file. - Add short comments explaining why the polling interval and form submit delay use their specific values, to make them easier to tune.
The Foreman linting requires constants to be declared instead of directly assigning numbers to variables. Otherwise, it will through the 'no-magic-numbers' error. Corresponding Foreman core PR: theforeman/foreman#11008 Co-Authored-By: OpenAI Codex
The Foreman linting requires constants to be declared instead of directly assigning numbers to variables. Otherwise, it will through the 'no-magic-numbers' error. Corresponding Foreman core PR: theforeman/foreman#11008 Co-Authored-By: OpenAI Codex
Add no-magic-numbers lint rule and fix violations
Adds
no-magic-numbersas awarnrule to ESLint config with common values ignored (0-8, pagination sizes, HTTP status codes, etc.).Extracts magic numbers into named constants across ~20 files (e.g.
MS_PER_SECOND,BYTES_PER_KB,TAB_WEIGHT_*, luminance coefficients).Also adds
unameto spellcheck skipWords.This PR was created with AI assistance.