+1
.eslintrc.js
+1
.eslintrc.js
+1
eslint/index.js
+1
eslint/index.js
+4
-4
eslint/use-exact-imports.js
+4
-4
eslint/use-exact-imports.js
···
1
-
/* eslint-disable bsky-internal/use-exact-imports */
2
1
const BANNED_IMPORTS = [
3
2
'@fortawesome/free-regular-svg-icons',
4
3
'@fortawesome/free-solid-svg-icons',
···
6
5
7
6
exports.create = function create(context) {
8
7
return {
9
-
Literal(node) {
10
-
if (typeof node.value !== 'string') {
8
+
ImportDeclaration(node) {
9
+
const source = node.source
10
+
if (typeof source.value !== 'string') {
11
11
return
12
12
}
13
-
if (BANNED_IMPORTS.includes(node.value)) {
13
+
if (BANNED_IMPORTS.includes(source.value)) {
14
14
context.report({
15
15
node,
16
16
message:
+39
eslint/use-prefixed-imports.js
+39
eslint/use-prefixed-imports.js
···
1
+
const BANNED_IMPORT_PREFIXES = [
2
+
'alf/',
3
+
'components/',
4
+
'lib/',
5
+
'locale/',
6
+
'logger/',
7
+
'platform/',
8
+
'state/',
9
+
'storage/',
10
+
'view/',
11
+
]
12
+
13
+
module.exports = {
14
+
meta: {
15
+
type: 'suggestion',
16
+
fixable: 'code',
17
+
},
18
+
create(context) {
19
+
return {
20
+
ImportDeclaration(node) {
21
+
const source = node.source
22
+
if (typeof source.value !== 'string') {
23
+
return
24
+
}
25
+
if (
26
+
BANNED_IMPORT_PREFIXES.some(banned => source.value.startsWith(banned))
27
+
) {
28
+
context.report({
29
+
node: source,
30
+
message: `Use '#/${source.value}'`,
31
+
fix(fixer) {
32
+
return fixer.replaceText(source, `'#/${source.value}'`)
33
+
},
34
+
})
35
+
}
36
+
},
37
+
}
38
+
},
39
+
}