Skip to content

Commit f6ef872

Browse files
authored
Merge pull request #3575 from element-hq/hs/lint-src-imports
Restrict importing src/lib in most cases for matrix- libs
2 parents 42b4c83 + 07de848 commit f6ef872

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.eslintrc.cjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ module.exports = {
4343
// To encourage good usage of RxJS:
4444
"rxjs/no-exposed-subjects": "error",
4545
"rxjs/finnish": ["error", { names: { "^this$": false } }],
46+
"no-restricted-imports": [
47+
"error",
48+
{
49+
paths: ["matrix-widget-api", "matrix-js-sdk"].flatMap((lib) =>
50+
["src", "src/", "src/index", "lib", "lib/", "lib/index"]
51+
.map((path) => `${lib}/${path}`)
52+
.map((name) => ({ name, message: `Please use ${lib} instead` })),
53+
),
54+
patterns: [
55+
...["matrix-widget-api"].map((lib) => ({
56+
group: ["src", "src/", "src/**", "lib", "lib/", "lib/**"].map(
57+
(path) => `${lib}/${path}`,
58+
),
59+
message: `Please use ${lib} instead`,
60+
})),
61+
// XXX: We use /lib in lots of places, so allow for now.
62+
...["matrix-js-sdk"].map((lib) => ({
63+
group: ["src", "src/", "src/**"].map((path) => `${lib}/${path}`),
64+
message: `Please use ${lib} instead`,
65+
})),
66+
],
67+
},
68+
],
4669
},
4770
overrides: [
4871
{

0 commit comments

Comments
 (0)