Skip to content

Commit d747b37

Browse files
committed
chore: review comments
1 parent f9e15d3 commit d747b37

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ export default defineConfig([
136136
},
137137
},
138138
{
139-
name: 'Bundle import guard',
139+
name: 'Source files',
140140
files: ['src/**/*.ts'],
141141
rules: {
142142
'@local/no-direct-third-party-imports': 'error',
143143
},
144144
},
145-
{
145+
{
146146
name: 'Tests',
147147
files: ['**/*.test.ts'],
148148
rules: {

scripts/eslint_rules/no-direct-third-party-imports-rule.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
*/
2323

2424
import {readdirSync, readFileSync} from 'node:fs';
25-
import {join, dirname} from 'node:path';
26-
import {fileURLToPath} from 'node:url';
25+
import {join} from 'node:path';
2726

28-
const __dirname = dirname(fileURLToPath(import.meta.url));
29-
const THIRD_PARTY_DIR = join(__dirname, '..', '..', 'src', 'third_party');
27+
const THIRD_PARTY_DIR = join(
28+
import.meta.dirname,
29+
'..',
30+
'..',
31+
'src',
32+
'third_party',
33+
);
3034

3135
/**
3236
* Parse all .ts files in src/third_party/ and extract the bare package names
@@ -60,7 +64,9 @@ function discoverBundledPackages() {
6064
}
6165
// Extract the bare package name (handle scoped packages like @foo/bar).
6266
const parts = source.split('/');
63-
const pkg = source.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
67+
const pkg = source.startsWith('@')
68+
? parts.slice(0, 2).join('/')
69+
: parts[0];
6470
packages.add(pkg);
6571
}
6672
}
@@ -100,7 +106,7 @@ export default {
100106
},
101107
defaultOptions: [],
102108
create(context) {
103-
const filename = context.getFilename();
109+
const filename = context.filename;
104110
if (isThirdPartyBarrel(filename)) {
105111
return {};
106112
}

0 commit comments

Comments
 (0)