Skip to content

Commit 76f330b

Browse files
Alfred-Skybluesxzz
andcommitted
style: prefer node: protocol (#8584)
Co-authored-by: 丶远方 <[email protected]> Co-authored-by: 三咲智子 Kevin Deng <[email protected]>
1 parent f328d50 commit 76f330b

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

.eslintrc.cjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable no-restricted-globals */
22

3+
const { builtinModules } = require('node:module')
34
const DOMGlobals = ['window', 'document']
45
const NodeGlobals = ['module', 'require']
56

@@ -17,7 +18,7 @@ module.exports = {
1718
parserOptions: {
1819
sourceType: 'module'
1920
},
20-
plugins: ['jest'],
21+
plugins: ['jest', 'import'],
2122
rules: {
2223
'no-debugger': 'error',
2324
// most of the codebase are expected to be env agnostic
@@ -33,6 +34,10 @@ module.exports = {
3334
// still generates verbose helpers, so spread assignment is also prohiboted
3435
'ObjectExpression > SpreadElement',
3536
'AwaitExpression'
37+
],
38+
'import/no-nodejs-modules': [
39+
'error',
40+
{ allow: builtinModules.map(mod => `node:${mod}`) }
3641
]
3742
},
3843
overrides: [
@@ -91,6 +96,13 @@ module.exports = {
9196
'no-restricted-globals': 'off',
9297
'no-restricted-syntax': ['error', banConstEnum]
9398
}
99+
},
100+
// Import nodejs modules in compiler-sfc
101+
{
102+
files: ['packages/compiler-sfc/**'],
103+
rules: {
104+
'import/no-nodejs-modules': ['error', { allow: builtinModules }]
105+
}
94106
}
95107
]
96108
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"esbuild-plugin-polyfill-node": "^0.3.0",
8282
"eslint": "^8.55.0",
8383
"eslint-define-config": "^1.24.1",
84+
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
8485
"eslint-plugin-jest": "^27.6.0",
8586
"estree-walker": "^2.0.2",
8687
"execa": "^8.0.1",

pnpm-lock.yaml

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)