Skip to content

Commit 6ac51e9

Browse files
authored
chore: use cjs extension with scripts (#5877)
1 parent ec18db2 commit 6ac51e9

10 files changed

+136
-3
lines changed

.eslintrc.cjs

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// @ts-check
2+
const { defineConfig } = require('eslint-define-config')
3+
4+
module.exports = defineConfig({
5+
root: true,
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:node/recommended',
9+
'plugin:@typescript-eslint/recommended'
10+
],
11+
parser: '@typescript-eslint/parser',
12+
parserOptions: {
13+
sourceType: 'module',
14+
ecmaVersion: 2021
15+
},
16+
rules: {
17+
eqeqeq: ['warn', 'always', { null: 'never' }],
18+
'no-debugger': ['error'],
19+
'no-empty': ['warn', { allowEmptyCatch: true }],
20+
'no-process-exit': 'off',
21+
'no-useless-escape': 'off',
22+
'prefer-const': [
23+
'warn',
24+
{
25+
destructuring: 'all'
26+
}
27+
],
28+
29+
'node/no-missing-import': [
30+
'error',
31+
{
32+
allowModules: [
33+
'types',
34+
'estree',
35+
'testUtils',
36+
'less',
37+
'sass',
38+
'stylus'
39+
],
40+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
41+
}
42+
],
43+
'node/no-missing-require': [
44+
'error',
45+
{
46+
// for try-catching yarn pnp
47+
allowModules: ['pnpapi', 'vite'],
48+
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
49+
}
50+
],
51+
'node/no-restricted-require': [
52+
'error',
53+
Object.keys(require('./packages/vite/package.json').devDependencies).map(
54+
(d) => ({
55+
name: d,
56+
message:
57+
`devDependencies can only be imported using ESM syntax so ` +
58+
`that they are included in the rollup bundle. If you are trying to ` +
59+
`lazy load a dependency, use (await import('dependency')).default instead.`
60+
})
61+
)
62+
],
63+
'node/no-extraneous-import': [
64+
'error',
65+
{
66+
allowModules: ['vite', 'less', 'sass']
67+
}
68+
],
69+
'node/no-extraneous-require': [
70+
'error',
71+
{
72+
allowModules: ['vite']
73+
}
74+
],
75+
'node/no-deprecated-api': 'off',
76+
'node/no-unpublished-import': 'off',
77+
'node/no-unpublished-require': 'off',
78+
'node/no-unsupported-features/es-syntax': 'off',
79+
80+
'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
81+
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
82+
'@typescript-eslint/no-empty-function': [
83+
'error',
84+
{ allow: ['arrowFunctions'] }
85+
],
86+
'@typescript-eslint/no-empty-interface': 'off',
87+
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
88+
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
89+
'@typescript-eslint/no-inferrable-types': 'off',
90+
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
91+
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
92+
'@typescript-eslint/no-var-requires': 'off'
93+
},
94+
overrides: [
95+
{
96+
files: ['packages/vite/src/node/**'],
97+
rules: {
98+
'no-console': ['error']
99+
}
100+
},
101+
{
102+
files: ['packages/vite/types/**'],
103+
rules: {
104+
'node/no-extraneous-import': 'off'
105+
}
106+
},
107+
{
108+
files: ['packages/playground/**'],
109+
rules: {
110+
'node/no-extraneous-import': 'off',
111+
'node/no-extraneous-require': 'off'
112+
}
113+
},
114+
{
115+
files: ['packages/create-vite/template-*/**'],
116+
rules: {
117+
'node/no-missing-import': 'off'
118+
}
119+
},
120+
{
121+
files: ['*.js'],
122+
rules: {
123+
'@typescript-eslint/explicit-module-boundary-types': 'off'
124+
}
125+
},
126+
{
127+
files: ['*.d.ts'],
128+
rules: {
129+
'@typescript-eslint/triple-slash-reference': 'off'
130+
}
131+
}
132+
]
133+
})

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
"gitHooks": {
6363
"pre-commit": "lint-staged --concurrent false",
64-
"commit-msg": "node scripts/verifyCommit.js"
64+
"commit-msg": "node scripts/verifyCommit.cjs"
6565
},
6666
"lint-staged": {
6767
"*": [

packages/plugin-vue-jsx/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"types": "index.d.ts",
1212
"scripts": {
1313
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue-jsx",
14-
"release": "node ../../scripts/release.js --skipBuild"
14+
"release": "node ../../scripts/release.cjs --skipBuild"
1515
},
1616
"engines": {
1717
"node": ">=12.0.0"

packages/plugin-vue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js",
1717
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
1818
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue",
19-
"release": "node ../../scripts/release.js"
19+
"release": "node ../../scripts/release.cjs"
2020
},
2121
"engines": {
2222
"node": ">=12.0.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)