Skip to content

Commit

Permalink
Set up knip (#37)
Browse files Browse the repository at this point in the history
* Clean up shared deps

* Set up knip

* Clean up imports

* Add basic knip config

* Improve Knip config

* Add some missing deps

* Add some missing deps

* Lift common to a true workspace

* Set up knip

* Trigger CodeQL

* Trigger CodeQL
  • Loading branch information
Jym77 authored Sep 3, 2024
1 parent 1864635 commit 0a7a62e
Show file tree
Hide file tree
Showing 28 changed files with 376 additions and 506 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ jobs:
- run: yarn dedupe --check
- run: yarn build
- run: yarn test
- run: yarn knip
20 changes: 20 additions & 0 deletions common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "http://json.schemastore.org/package",
"private": true,
"name": "common",
"exports": {
"./persist": "./persist.js",
"./persist.js": "./persist.js"
},
"devDependencies": {
"@siteimprove/alfa-act": "^0.81.0",
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-formatter": "^0.65.2",
"@siteimprove/alfa-hash": "^0.81.0",
"@siteimprove/alfa-mapper": "^0.81.0"
},
"dependencies": {
"@siteimprove/alfa-formatter-earl": "^0.65.2",
"@siteimprove/alfa-future": "^0.81.0"
}
}
39 changes: 39 additions & 0 deletions config/knip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { KnipConfig } from "knip";

const entry = ["test/**/*.spec.ts", "test/**/*.spec.tsx"];
const project = ["**/*.ts", "**/*.tsx"];

const config: KnipConfig = {
ignoreDependencies: ["prettier"],
workspaces: {
common: { entry: "persist.ts", project },
"custom-testing/*": { entry, project },
"custom-testing/crawling": { entry: ["crawling.ts"], project },
"custom-testing/measuring-performances": {
entry: ["performance.ts"],
project,
},
"custom-testing/scraping": { entry: ["scraping.ts"], project },
"end-to-end-testing/*": { entry, project },
"end-to-end-testing/cypress": {
cypress: {
config: "cypress.json",
entry: [...entry, "support.ts"],
project,
},
},
"end-to-end-testing/webdriver": {
"webdriver-io": { config: ["wdio.conf.ts"], entry, project },
ignoreDependencies: [
// imported through the config file
"chromedriver",
],
},
"unit-testing/*": { entry, project },
"unit-testing/angular": { entry: ["components/*.ts", "setup.ts"], project },
"unit-testing/react": { entry: ["components/*.tsx", "setup.ts"], project },
"unit-testing/vue": { entry: ["components/*.ts", "setup.ts"], project },
},
};

export default config;
1 change: 1 addition & 0 deletions custom-testing/adding-rules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.3.4",
"common": "workspace:^",
"mocha": "^8.3.2",
"playwright": "^1.10.0"
}
Expand Down
2 changes: 1 addition & 1 deletion custom-testing/adding-rules/test/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as alfa from "@siteimprove/alfa-chai";

import rules from "@siteimprove/alfa-rules";

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

const { and } = Refinement;

Expand Down
5 changes: 3 additions & 2 deletions custom-testing/answering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
},
"devDependencies": {
"@siteimprove/alfa-act": "^0.81.0",
"@siteimprove/alfa-chai": "^0.65.2",
"@siteimprove/alfa-css": "^0.81.0",
"@siteimprove/alfa-dom": "^0.81.0",
"@siteimprove/alfa-future": "^0.81.0",
"@siteimprove/alfa-hash": "^0.81.0",
"@siteimprove/alfa-option": "^0.81.0",
"@siteimprove/alfa-playwright": "^0.65.2",
"@siteimprove/alfa-refinement": "^0.81.0",
"@siteimprove/alfa-rules": "^0.81.0",
"@siteimprove/alfa-scraper": "^0.65.2",
"@siteimprove/alfa-style": "^0.81.0",
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.3.4",
"common": "workspace:^",
"mocha": "^8.3.2",
"playwright": "^1.10.0"
}
Expand Down
9 changes: 4 additions & 5 deletions custom-testing/answering/test/answering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,29 @@
/// <reference types="mocha" />

import * as act from "@siteimprove/alfa-act";
import { Color, RGB } from "@siteimprove/alfa-css";
import { Color } from "@siteimprove/alfa-css";
import { Element, Text } from "@siteimprove/alfa-dom";
import { Future } from "@siteimprove/alfa-future";
import { Hashable } from "@siteimprove/alfa-hash";
import { None, Some } from "@siteimprove/alfa-option";
import { Playwright } from "@siteimprove/alfa-playwright";
import { Refinement } from "@siteimprove/alfa-refinement";
import rules, { Question, Scope } from "@siteimprove/alfa-rules";
import { Resolver } from "@siteimprove/alfa-style";
import rules, { Question } from "@siteimprove/alfa-rules";

import * as chai from "chai";
import * as playwright from "playwright";

import * as alfa from "@siteimprove/alfa-chai";

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

const { and } = Refinement;

// Creating a Chai plugin which uses all rules.
chai.use(
alfa.Chai.createPlugin(
(value: Playwright.Type) => Future.from(Playwright.toPage(value)),
rules.filter(rule => !rule.uri.includes("r111")),
rules.filter((rule) => !rule.uri.includes("r111")),
[persist(() => "test/outcomes/page.spec.json")]
)
);
Expand Down
1 change: 1 addition & 0 deletions custom-testing/filtering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.3.4",
"common": "workspace:^",
"mocha": "^8.3.2",
"playwright": "^1.10.0"
}
Expand Down
4 changes: 2 additions & 2 deletions custom-testing/filtering/test/filtering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import * as alfa from "@siteimprove/alfa-chai";

import rules, { Scope } from "@siteimprove/alfa-rules";

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

const { and } = Refinement;

// Creating a Chai plugin which uses all rules.
chai.use(
alfa.Chai.createPlugin(
(value: Playwright.Type) => Future.from(Playwright.toPage(value)),
rules.filter(rule => !rule.uri.includes("r111")),
rules.filter((rule) => !rule.uri.includes("r111")),
[persist(() => "test/outcomes/filtering.spec.json")]
)
);
Expand Down
1 change: 1 addition & 0 deletions custom-testing/interacting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.3.4",
"common": "workspace:^",
"mocha": "^8.3.2",
"playwright": "^1.10.0"
}
Expand Down
2 changes: 1 addition & 1 deletion custom-testing/interacting/test/interacting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as alfa from "@siteimprove/alfa-chai";
import { Rules } from "@siteimprove/alfa-rules";
const R69 = Rules.get("R69").getUnsafe();

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

chai.use(
alfa.Chai.createPlugin(
Expand Down
2 changes: 0 additions & 2 deletions custom-testing/navigating/test/navigating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import * as alfa from "@siteimprove/alfa-chai";
import { Rules } from "@siteimprove/alfa-rules";
const R69 = Rules.get("R69").getUnsafe();

import { persist } from "../../../common/persist";

// Creating a Chai plugin which only uses R69.
chai.use(
alfa.Chai.createPlugin(
Expand Down
2 changes: 1 addition & 1 deletion end-to-end-testing/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"skipLibCheck": true,
"types": ["cypress"]
},
"files": ["integration/page.spec.ts", "support.ts"]
"files": ["test/page.spec.ts", "support.ts"]
}
3 changes: 1 addition & 2 deletions end-to-end-testing/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
"test": "mocha --timeout 10000"
},
"devDependencies": {
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-chai": "^0.65.2",
"@siteimprove/alfa-formatter-earl": "^0.65.2",
"@siteimprove/alfa-future": "^0.81.0",
"@siteimprove/alfa-playwright": "^0.65.2",
"@siteimprove/alfa-rules": "^0.81.0",
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.3.4",
"common": "workspace:^",
"mocha": "^8.3.2",
"playwright": "^1.10.0"
}
Expand Down
4 changes: 2 additions & 2 deletions end-to-end-testing/playwright/test/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { Playwright } from "@siteimprove/alfa-playwright";
import * as alfa from "@siteimprove/alfa-chai";
import rules from "@siteimprove/alfa-rules";

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

chai.use(
alfa.Chai.createPlugin(
(value: Playwright.Type) => Future.from(Playwright.toPage(value)),
rules.filter(rule => !rule.uri.includes("r111")),
rules.filter((rule) => !rule.uri.includes("r111")),
[persist(() => "test/outcomes/page.spec.json")]
)
);
Expand Down
2 changes: 1 addition & 1 deletion end-to-end-testing/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"test": "mocha -t 10000"
},
"devDependencies": {
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-chai": "^0.65.2",
"@siteimprove/alfa-future": "^0.81.0",
"@siteimprove/alfa-puppeteer": "^0.65.2",
"@siteimprove/alfa-rules": "^0.81.0",
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.3.4",
"common": "workspace:^",
"mocha": "^8.3.2",
"puppeteer": "^8.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion end-to-end-testing/puppeteer/test/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Puppeteer } from "@siteimprove/alfa-puppeteer";
import * as alfa from "@siteimprove/alfa-chai";
import rules from "@siteimprove/alfa-rules";

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

chai.use(
alfa.Chai.createPlugin(
Expand Down
5 changes: 1 addition & 4 deletions end-to-end-testing/webdriver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@
"test": "wdio wdio.conf.js"
},
"devDependencies": {
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-chai": "^0.65.2",
"@siteimprove/alfa-future": "^0.81.0",
"@siteimprove/alfa-rules": "^0.81.0",
"@siteimprove/alfa-webdriver": "^0.65.2",
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"@wdio/cli": "^5.14.4",
"@wdio/local-runner": "^7.1.1",
"@wdio/mocha-framework": "^7.1.1",
"@wdio/spec-reporter": "^7.1.1",
"chai": "^4.3.4",
"chromedriver": "^119.0.1",
"common": "workspace:^",
"mocha": "^8.3.2",
"ts-node": "^9.1.1",
"wdio-chromedriver-service": "^7.0.0",
"webdriverio": "^7.3.1"
}
}
2 changes: 1 addition & 1 deletion end-to-end-testing/webdriver/test/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { WebElement } from "@siteimprove/alfa-webdriver";
import * as alfa from "@siteimprove/alfa-chai";
import rules from "@siteimprove/alfa-rules";

import { persist } from "../../../common/persist";
import { persist } from "common/persist";

chai.use(
alfa.Chai.createPlugin(
Expand Down
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@
"build": "tsc --build",
"watch": "tsc --build --watch",
"clean": "tsc --build --clean",
"knip": "knip -c config/knip.ts",
"test": "yarn workspaces foreach -v -p --exclude 'end-to-end-testing-{cypress,puppeteer,webdriver}' --exclude 'custom-testing-{crawling,scraping,measuring-performance}' --exclude 'unit-testing-angular' run test"
},
"workspaces": [
"common",
"custom-testing/*",
"end-to-end-testing/*",
"unit-testing/*"
],
"devDependencies": {
"@siteimprove/alfa-act": "^0.81.0",
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-formatter": "^0.65.2",
"@siteimprove/alfa-formatter-earl": "^0.65.2",
"@siteimprove/alfa-future": "^0.81.0",
"@siteimprove/alfa-hash": "^0.81.0",
"@siteimprove/alfa-mapper": "^0.81.0",
"@types/node": "^20.2.3",
"knip": "^5.29.1",
"prettier": "^2.2.1",
"typescript": "^5.0.4"
},
Expand Down
7 changes: 2 additions & 5 deletions unit-testing/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@
"verbose": true
},
"dependencies": {
"@angular/common": "^8.2.0",
"@angular/compiler": "^8.2.0",
"@angular/core": "^11.0.5",
"@angular/platform-browser": "^8.2.0",
"@angular/platform-browser-dynamic": "^8.2.0",
"core-js": "^3.10.1",
"rxjs": "^6.6.7",
"zone.js": "^0.11.4"
},
"devDependencies": {
"@siteimprove/alfa-angular": "^0.65.2",
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-future": "^0.81.0",
"@siteimprove/alfa-jest": "^0.65.2",
"@siteimprove/alfa-rules": "^0.81.0",
"@types/jest": "^29.5.1",
"common": "workspace:^",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-preset-angular": "^13.1.1"
Expand Down
2 changes: 1 addition & 1 deletion unit-testing/angular/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ global.TextEncoder = TextEncoder;
import { Rules } from "@siteimprove/alfa-rules";
const R12 = Rules.get("R12").getUnsafe();

import { persist } from "../../common/persist";
import { persist } from "common/persist";

alfa.Jest.createPlugin(
(value: Angular.Type) => Future.from(Angular.toPage(value)),
Expand Down
14 changes: 6 additions & 8 deletions unit-testing/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@
"js"
]
},
"dependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@siteimprove/alfa-assert": "^0.65.2",
"@siteimprove/alfa-enzyme": "^0.65.2",
"@siteimprove/alfa-jest": "^0.65.2",
"@siteimprove/alfa-rules": "^0.81.0",
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/jest": "^29.5.1",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"common": "workspace:^",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"jest": "^29.5.0"
"jest": "^29.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
2 changes: 1 addition & 1 deletion unit-testing/react/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const R12 = Rules.get("R12").getUnsafe();
import * as enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";

import { persist } from "../../common/persist";
import { persist } from "common/persist";

enzyme.configure({ adapter: new Adapter() });

Expand Down
Loading

0 comments on commit 0a7a62e

Please sign in to comment.