Skip to content
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

#6778: Fail CI on dependency cycles and remove madge #6857

Merged
merged 7 commits into from
Nov 14, 2023
Merged

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Nov 11, 2023

What does this PR do?

Reviewer Tips

  • The second commit here fails to demonstrate that it works.
  • I looked for ways to execute only this rule, but
    • eslint never provided a way
    • eslint-nibble --rule import/no-cycle lasts longer than the full lint

Checklist

Copy link

codecov bot commented Nov 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d31895f) 70.42% compared to head (ea9aa48) 70.42%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6857   +/-   ##
=======================================
  Coverage   70.42%   70.42%           
=======================================
  Files        1195     1195           
  Lines       37140    37140           
  Branches     6968     6968           
=======================================
  Hits        26154    26154           
  Misses      10986    10986           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

.eslintrc.js Outdated
// Enabled for the IDE, but it's disabled in the `lint` script
"import/no-cycle": "warn",
// Enabled on CI and in the IDE, but it's disabled in the local `lint` script because it's excessively slow
"import/no-cycle": "error",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I move it to the shared config?

.eslintrc.js Outdated
@@ -92,8 +92,8 @@ module.exports = {
// Rules that depend on https://github.com/pixiebrix/pixiebrix-extension/issues/775
"@typescript-eslint/restrict-template-expressions": "warn",

// Enabled for the IDE, but it's disabled in the `lint` script
"import/no-cycle": "warn",
// Enabled on CI and in the IDE, but it's disabled in the local `lint` script because it's excessively slow
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can continue this way because:

  • it's shown in the IDE as an error
  • it fails on CI if found
  • it does not slow down every npm run lint (in some cases this rule doubles the time)

# Fixed version to avoid random breaks. Not in package.json due to #1084
- run: npm install --global madge@5.0.1
- run: npm run madge:circular
name: Detect circular dependencies
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped Madge because it's now redundant

@@ -214,6 +214,7 @@
"@types/json-stringify-safe": "^5.0.2",
"@types/lodash": "^4.14.200",
"@types/mark.js": "^8.11.10",
"@types/marked": "^6.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fixes one of the issues reported by:

@twschiller twschiller changed the title #6778: Fail CI on dependency cycles #6778: Fail CI on dependency cycles and remove madge Nov 11, 2023
Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@@ -91,9 +91,6 @@ module.exports = {

// Rules that depend on https://github.com/pixiebrix/pixiebrix-extension/issues/775
"@typescript-eslint/restrict-template-expressions": "warn",

// Enabled for the IDE, but it's disabled in the `lint` script
"import/no-cycle": "warn",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ✅ Moved to shared config as suggested.
  • ⚠️ The app has 8 warnings that would need to be fixed in the next update
    • or they can be temporarily disabled via eslint-disable-next-line
    • or "import/no-cycle": "warn", can be added there

for (const ruleName of importRules) {
module.exports.rules[`import/${ruleName}`] = "off";
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore from pixiebrix/eslint-config-pixiebrix#122

nr lint:fast 115s
nr lint 212s (+84%) 😰
nr lint:full 408s (+355%) 😱

lint:fast is useful when addressing issues across the codebase that are not related to import

Side note, still applies:

@fregante fregante enabled auto-merge (squash) November 14, 2023 10:43
@fregante fregante merged commit 6823904 into main Nov 14, 2023
10 checks passed
@fregante fregante deleted the F/lint/cycle branch November 14, 2023 10:49
@grahamlangford grahamlangford added this to the 1.8.3 milestone Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable import cycle detection on CI
3 participants