Skip to content

Commit 886af51

Browse files
chore: lint against runtime imports of devDependencies (#852)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d6bc8a0 commit 886af51

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

.eslintrc.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,28 @@ module.exports = {
1313
plugins: [
1414
'@typescript-eslint',
1515
'no-only-tests',
16-
'github'
16+
'github',
17+
'import'
1718
],
1819
extends: [
1920
'eslint:all',
2021
'plugin:@typescript-eslint/all'
2122
],
2223
rules: {
24+
//fail if a runtime source file imports a package that isn't listed in `dependencies`.
25+
//this catches the case where a package used at runtime is only present in `devDependencies`,
26+
//which gets stripped when the extension is packaged into a .vsix (see the dayjs regression).
27+
//devDependencies are only permitted in the test/tooling globs listed below.
28+
'import/no-extraneous-dependencies': ['error', {
29+
devDependencies: [
30+
'scripts/**',
31+
'benchmarks/**',
32+
'.eslintrc.js',
33+
'**/*.config.*'
34+
],
35+
optionalDependencies: false,
36+
peerDependencies: true
37+
}],
2338
'@typescript-eslint/parameter-properties': 'off',
2439
'@typescript-eslint/array-type': 'off',
2540
'@typescript-eslint/consistent-type-assertions': 'off',
@@ -202,6 +217,8 @@ module.exports = {
202217
}, {
203218
files: ['*.spec.ts'],
204219
rules: {
220+
//spec files only run with devDependencies installed, so extraneous-dependency checks don't apply
221+
'import/no-extraneous-dependencies': 'off',
205222
'@typescript-eslint/no-extraneous-class': 'off',
206223
'@typescript-eslint/no-unsafe-assignment': 'off',
207224
'@typescript-eslint/no-unsafe-call': 'off',

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"iconv-lite": "0.4.24",
7171
"jszip": "^3.10.1",
7272
"just-throttle": "^4.0.1",
73+
"lodash": "^4.17.21",
7374
"md5": "^2.3.0",
7475
"minimatch": "^3.1.2",
7576
"node-cache": "^4.2.0",
@@ -122,8 +123,8 @@
122123
"deferred": "^0.7.11",
123124
"eslint": "^8.10.0",
124125
"eslint-plugin-github": "^4.3.5",
126+
"eslint-plugin-import": "^2.26.0",
125127
"eslint-plugin-no-only-tests": "^2.6.0",
126-
"lodash": "^4.17.21",
127128
"mocha": "^10.8.2",
128129
"node-notifier": "^10.0.1",
129130
"nyc": "^15.0.0",

src/viewProviders/BaseWebviewViewProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export abstract class BaseWebviewViewProvider implements vscode.WebviewViewProvi
189189
try {
190190
let watcher;
191191
try {
192-
// eslint-disable-next-line @typescript-eslint/no-require-imports
192+
// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-extraneous-dependencies
193193
watcher = require('@parcel/watcher');
194194
} catch (e) {
195195
// Doing nothing if watcher does not exist

0 commit comments

Comments
 (0)