Skip to content

Commit ccbce0c

Browse files
feat: new messages endpoint (#287)
* revert: openapi-ts upgrade * feat: show all alerts in dashboard table * refactor: continue replace alerts with messages * fix(project structure): issues with cross-feature leakage * fix layout, and beging building conversation summary functionality * deduplicate alerts & render secrets in conversation summary * fix: dial back de-duplication logic * chore: util function for MSW endpoint * chore: apply msw endpoint to handlers * chore: mockers for API responses * chore: add eslint rule to enforce safe msw usage * chore: apply new MSW approach across codebase * fix: remove de-duplication logic * tidy up conversation detail with tabs, add tests * visual improvements to conversation view * fix: tests * chore: tidy ups * fix flaky test * fix vitest & istanbul mismatch causing flakiness
1 parent 7e66ff0 commit ccbce0c

File tree

116 files changed

+4363
-3202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+4363
-3202
lines changed

eslint.config.js

+109-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,66 @@
11
import js from "@eslint/js";
22
import globals from "globals";
3+
import importPlugin from "eslint-plugin-import";
34
import reactHooks from "eslint-plugin-react-hooks";
45
import reactRefresh from "eslint-plugin-react-refresh";
56
import tseslint from "typescript-eslint";
67
import tailwindPlugin from "eslint-plugin-tailwindcss";
8+
import path from "path";
9+
import fs from "fs";
10+
11+
const FEATURES_DIR = "./src/features";
12+
13+
/**
14+
* Traverse the features directory and return an array of restricted paths for
15+
* use in the `import/no-restricted-paths` rule.
16+
*
17+
* @example
18+
* ```js
19+
* [
20+
* {
21+
* except: [ './dependencies' ],
22+
* from: './src/features',
23+
* target: './src/features/dependencies'
24+
* },
25+
* {
26+
* except: [ './versions' ],
27+
* from: './src/features',
28+
* target: './src/features/versions'
29+
* },
30+
* {
31+
* except: [ './vulnerabilities' ],
32+
* from: './src/features',
33+
* target: './src/features/vulnerabilities'
34+
* }
35+
* ]
36+
* ```
37+
*/
38+
const getRestrictedPathsForFeatureDir = () => {
39+
const featureDirPath = path.resolve(FEATURES_DIR);
40+
/**
41+
* @type {Array<{except: `./${string}`[], from: './src/features', target: string}>}
42+
*/
43+
const restrictedPaths = [];
44+
45+
try {
46+
const featureDirs = fs.readdirSync(featureDirPath);
47+
48+
featureDirs.forEach((featureDir) => {
49+
const subPath = path.join(featureDirPath, featureDir);
50+
if (fs.lstatSync(subPath).isDirectory()) {
51+
restrictedPaths.push({
52+
except: [`./${featureDir}`],
53+
from: FEATURES_DIR,
54+
target: path.join(FEATURES_DIR, featureDir),
55+
});
56+
}
57+
});
58+
} catch (error) {
59+
console.error("Error reading features directory:", error);
60+
}
61+
62+
return restrictedPaths;
63+
};
764

865
const restrictedSyntax = {
966
reactQuery: {
@@ -24,15 +81,29 @@ export default tseslint.config(
2481
],
2582
files: ["**/*.{ts,tsx}"],
2683
languageOptions: {
27-
ecmaVersion: 2020,
28-
globals: globals.browser,
84+
parserOptions: {
85+
projectService: true,
86+
tsconfigRootDir: import.meta.dirname,
87+
ecmaFeatures: {
88+
jsx: true,
89+
},
90+
},
91+
globals: {
92+
...globals.browser,
93+
...globals.node,
94+
},
2995
},
3096
plugins: {
3197
"react-hooks": reactHooks,
3298
"react-refresh": reactRefresh,
99+
import: importPlugin,
33100
},
34-
35101
settings: {
102+
"import/resolver": {
103+
typescript: true,
104+
node: true,
105+
},
106+
36107
tailwindcss: {
37108
callees: ["tv", "twMerge"],
38109
config: "./tailwind.config.ts",
@@ -132,6 +203,40 @@ export default tseslint.config(
132203
],
133204
},
134205
],
206+
"import/no-restricted-paths": [
207+
"error",
208+
{
209+
zones: [
210+
// disables cross-feature imports:
211+
// eg. src/features/dashboard-alerts should not import from src/features/dashboard-messages, etc.
212+
...getRestrictedPathsForFeatureDir(),
213+
214+
// enforce unidirectional codebase:
215+
// e.g. src/routes can import from src/features but not the other way around
216+
{
217+
from: "./src/routes",
218+
target: "./src/features",
219+
},
220+
221+
// enforce unidirectional codebase:
222+
// e.g src/features and src/routes can import from these shared modules but not the other way around
223+
{
224+
from: ["./src/features", "./src/routes"],
225+
target: [
226+
"./src/components",
227+
"./src/constants",
228+
"./src/hooks",
229+
"./src/i18n",
230+
"./src/lib",
231+
"./src/mocks",
232+
"./src/trusty-api",
233+
"./src/types",
234+
"./src/utils",
235+
],
236+
},
237+
],
238+
},
239+
],
135240
},
136-
},
241+
}
137242
);

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

knip.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"entry": ["src/main.tsx"],
4+
"ignore": ["src/api/generated/**/*"],
5+
"ignoreDependencies": ["husky"],
6+
"project": ["src/**/*.{js,jsx,ts,tsx}"]
7+
}

knip.ts

-10
This file was deleted.

0 commit comments

Comments
 (0)