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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

},
overrides: [
{
Expand Down Expand Up @@ -129,3 +126,12 @@ module.exports = {
},
],
};

// `npm run lint:fast` will skip the (slow) import/* rules
// Useful if you're trying to iterate fixes over other rules
if (process.env.ESLINT_NO_IMPORTS) {
const importRules = Object.keys(require("eslint-plugin-import").rules);
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:

16 changes: 1 addition & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,7 @@ jobs:
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run lint -- --quiet

circular-deps:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
# 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

- run: npm run lint:full

# https://pre-commit.com/#usage-in-continuous-integration
prettier:
Expand Down
52 changes: 32 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"scripts": {
"test": "TZ=UTC jest",
"test:watch": "TZ=UTC jest --watchAll",
"lint": "eslint src --ext js,jsx,ts,tsx --quiet --report-unused-disable-directives --rule '{\"import/no-cycle\": \"off\"}'",
"lint": "npm run lint:full -- --rule '{\"import/no-cycle\": \"off\"}'",
"lint:fast": "ESLINT_NO_IMPORTS=1 eslint src --ext js,jsx,ts,tsx --quiet",
"lint:full": "eslint src --ext js,jsx,ts,tsx --quiet --report-unused-disable-directives",
"fix": "npm run lint -- --fix",
"watch": "concurrently npm:watch:webpack 'npm:watch:*(!webpack) -- --preserveWatchOutput' -r",
"watch:webpack": "ENV_FILE='.env.development' webpack --mode development --watch",
Expand All @@ -18,8 +20,7 @@
"build:scripts": "webpack --config scripts/webpack.scripts.js",
"generate:headers": "NODE_OPTIONS=--stack-trace-limit=100 node scripts/bin/headers.js",
"storybook": "storybook dev -p 6006 -s public",
"build-storybook": "storybook build",
"madge:circular": "madge --extensions js,ts,tsx --circular src/** --ts-config tsconfig.json"
"build-storybook": "storybook build"
},
"engine-strict": true,
"engines": {
Expand Down Expand Up @@ -214,6 +215,7 @@
"@types/json-stringify-safe": "^5.0.2",
"@types/lodash": "^4.14.201",
"@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:

"@types/mustache": "^4.2.5",
"@types/nunjucks": "^3.2.5",
"@types/object-hash": "^2.1.1",
Expand Down Expand Up @@ -248,7 +250,7 @@
"css-minimizer-webpack-plugin": "^3.4.1",
"dotenv": "^16.3.1",
"eslint": "^8.53.0",
"eslint-config-pixiebrix": "^0.31.0",
"eslint-config-pixiebrix": "^0.32.0",
"eslint-plugin-local-rules": "^2.0.0",
"fake-indexeddb": "^5.0.1",
"identity-obj-proxy": "^3.0.0",
Expand Down
4 changes: 0 additions & 4 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ declare module "generate-schema" {
const json: (title: string, obj: unknown) => UnknownObject;
}

// The package breaks Madge, so we have to include a patch in tsconfig, which breaks the @types package.
// In the end, the types aren't even used.
declare module "marked";

// No types available
declare module "@pixiebrix/jq-web";
declare module "canvas-confetti";
Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
"@schemas/*": ["schemas/*"],
"@microsoft/applicationinsights-web/*": [
"src/contrib/uipath/quietLogger/*"
],

// Help Madge resolve this dependency
"marked": ["node_modules/marked/lib/marked.esm.js"]
]
},
"plugins": [{ "name": "typescript-plugin-css-modules" }]
},
Expand Down
Loading