Skip to content

Fixes #39383 - add no-magic-numbers js lint rule#11008

Open
MariaAga wants to merge 1 commit into
theforeman:developfrom
MariaAga:lint-magic-numbers
Open

Fixes #39383 - add no-magic-numbers js lint rule#11008
MariaAga wants to merge 1 commit into
theforeman:developfrom
MariaAga:lint-magic-numbers

Conversation

@MariaAga
Copy link
Copy Markdown
Member

@MariaAga MariaAga commented May 28, 2026

Add no-magic-numbers lint rule and fix violations

Adds no-magic-numbers as a warn rule 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 uname to spellcheck skipWords.


This PR was created with AI assistance.

Comment thread script/lint/@theforeman/eslint-plugin-foreman/lint_generic_config.js Outdated
@stejskalleos stejskalleos self-assigned this May 29, 2026
@MariaAga MariaAga force-pushed the lint-magic-numbers branch from 14baf3e to 0239ad7 Compare June 1, 2026 09:03
@MariaAga MariaAga marked this pull request as ready for review June 1, 2026 09:03
@MariaAga
Copy link
Copy Markdown
Member Author

MariaAga commented Jun 1, 2026

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)

@MariaAga MariaAga force-pushed the lint-magic-numbers branch from 0239ad7 to ca04d1d Compare June 1, 2026 09:06
@MariaAga MariaAga changed the title Fix magic numbers and add no-magic-numbers rule Fixes #39383 - add no-magic-numbers js lint rule Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants