forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1const BANNED_IMPORT_PREFIXES = [
2 'alf/',
3 'components/',
4 'lib/',
5 'locale/',
6 'logger/',
7 'platform/',
8 'state/',
9 'storage/',
10 'view/',
11]
12
13module.exports = {
14 meta: {
15 type: 'suggestion',
16 docs: {
17 description: 'Enforce using prefixed imports for internal paths',
18 },
19 fixable: 'code',
20 schema: [],
21 },
22 create(context) {
23 return {
24 ImportDeclaration(node) {
25 const source = node.source
26 if (typeof source.value !== 'string') {
27 return
28 }
29 if (
30 BANNED_IMPORT_PREFIXES.some(banned => source.value.startsWith(banned))
31 ) {
32 context.report({
33 node: source,
34 message: `Use '#/${source.value}'`,
35 fix(fixer) {
36 return fixer.replaceText(source, `'#/${source.value}'`)
37 },
38 })
39 }
40 },
41 }
42 },
43}