Skip to content

Commit f4addcf

Browse files
authored
chore: tidy up eslint config (#9468)
1 parent 22084a6 commit f4addcf

File tree

14 files changed

+58
-46
lines changed

14 files changed

+58
-46
lines changed

.eslintrc.cjs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ module.exports = defineConfig({
4242
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
4343
}
4444
],
45-
'node/no-restricted-require': [
46-
'error',
47-
Object.keys(require('./packages/vite/package.json').devDependencies).map(
48-
(d) => ({
49-
name: d,
50-
message:
51-
`devDependencies can only be imported using ESM syntax so ` +
52-
`that they are included in the rollup bundle. If you are trying to ` +
53-
`lazy load a dependency, use (await import('dependency')).default instead.`
54-
})
55-
)
56-
],
5745
'node/no-extraneous-import': [
5846
'error',
5947
{
@@ -107,6 +95,30 @@ module.exports = defineConfig({
10795
]
10896
},
10997
overrides: [
98+
{
99+
files: ['packages/**'],
100+
excludedFiles: '**/__tests__/**',
101+
rules: {
102+
'no-restricted-globals': ['error', 'require', '__dirname', '__filename']
103+
}
104+
},
105+
{
106+
files: 'packages/vite/**/*.*',
107+
rules: {
108+
'node/no-restricted-require': [
109+
'error',
110+
Object.keys(
111+
require('./packages/vite/package.json').devDependencies
112+
).map((d) => ({
113+
name: d,
114+
message:
115+
`devDependencies can only be imported using ESM syntax so ` +
116+
`that they are included in the rollup bundle. If you are trying to ` +
117+
`lazy load a dependency, use (await import('dependency')).default instead.`
118+
}))
119+
]
120+
}
121+
},
110122
{
111123
files: ['packages/vite/src/node/**'],
112124
rules: {
@@ -120,9 +132,11 @@ module.exports = defineConfig({
120132
}
121133
},
122134
{
123-
files: ['packages/plugin-*/**/*'],
135+
files: ['packages/create-vite/template-*/**', '**/build.config.ts'],
124136
rules: {
125-
'no-restricted-globals': ['error', 'require', '__dirname', '__filename']
137+
'no-undef': 'off',
138+
'node/no-missing-import': 'off',
139+
'@typescript-eslint/explicit-module-boundary-types': 'off'
126140
}
127141
},
128142
{
@@ -132,7 +146,6 @@ module.exports = defineConfig({
132146
'node/no-extraneous-require': 'off',
133147
'node/no-missing-import': 'off',
134148
'node/no-missing-require': 'off',
135-
'no-undef': 'off',
136149
// engine field doesn't exist in playgrounds
137150
'node/no-unsupported-features/es-builtins': [
138151
'error',
@@ -145,17 +158,22 @@ module.exports = defineConfig({
145158
{
146159
version: '^14.18.0 || >=16.0.0'
147160
}
148-
]
161+
],
162+
'@typescript-eslint/explicit-module-boundary-types': 'off'
149163
}
150164
},
151165
{
152-
files: ['packages/create-vite/template-*/**', '**/build.config.ts'],
166+
files: ['playground/**'],
167+
excludedFiles: '**/__tests__/**',
153168
rules: {
154-
'node/no-missing-import': 'off'
169+
'no-undef': 'off',
170+
'no-empty': 'off',
171+
'no-constant-condition': 'off',
172+
'@typescript-eslint/no-empty-function': 'off'
155173
}
156174
},
157175
{
158-
files: ['playground/**', '*.js'],
176+
files: ['*.js'],
159177
rules: {
160178
'@typescript-eslint/explicit-module-boundary-types': 'off'
161179
}
@@ -165,12 +183,6 @@ module.exports = defineConfig({
165183
rules: {
166184
'@typescript-eslint/triple-slash-reference': 'off'
167185
}
168-
},
169-
{
170-
files: 'packages/vite/**/*.*',
171-
rules: {
172-
'no-restricted-globals': ['error', 'require', '__dirname', '__filename']
173-
}
174186
}
175187
],
176188
reportUnusedDisableDirectives: true

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"preinstall": "npx only-allow pnpm",
1717
"postinstall": "simple-git-hooks",
1818
"format": "prettier --write --cache .",
19-
"lint": "eslint --cache packages/*/{src,types,__tests__}/** playground/**/__tests__/**/*.ts scripts/**/*.ts",
19+
"lint": "eslint --cache .",
2020
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
2121
"test": "run-s test-unit test-serve test-build",
2222
"test-serve": "vitest run -c vitest.config.e2e.ts",
@@ -65,7 +65,7 @@
6565
"cross-env": "^7.0.3",
6666
"esbuild": "^0.14.47",
6767
"eslint": "^8.20.0",
68-
"eslint-define-config": "^1.5.1",
68+
"eslint-define-config": "^1.6.0",
6969
"eslint-plugin-import": "^2.26.0",
7070
"eslint-plugin-node": "^11.1.0",
7171
"execa": "^6.1.0",

packages/create-vite/template-lit-ts/src/my-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html, css, LitElement } from 'lit'
1+
import { LitElement, css, html } from 'lit'
22
import { customElement, property } from 'lit/decorators.js'
33
import litLogo from './assets/lit.svg'
44

packages/create-vite/template-lit/src/my-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html, css, LitElement } from 'lit'
1+
import { LitElement, css, html } from 'lit'
22
import litLogo from './assets/lit.svg'
33

44
/**

packages/vite/rollup.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import MagicString from 'magic-string'
1111
import colors from 'picocolors'
1212
import fg from 'fast-glob'
1313
import { sync as resolve } from 'resolve'
14-
import type { Plugin } from 'rollup'
14+
import type { Plugin, RollupOptions } from 'rollup'
1515
import { defineConfig } from 'rollup'
1616
import pkg from './package.json'
1717

@@ -185,7 +185,7 @@ function createCjsConfig(isProduction: boolean) {
185185
})
186186
}
187187

188-
export default (commandLineArgs: any) => {
188+
export default (commandLineArgs: any): RollupOptions[] => {
189189
const isDev = commandLineArgs.watch
190190
const isProduction = !isDev
191191

playground/css/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ text('.charset-css', charset)
4747
import './dep.css'
4848
import './glob-dep.css'
4949

50+
// eslint-disable-next-line import/order
5051
import { barModuleClasses } from 'css-js-dep'
5152
document
5253
.querySelector('.css-js-dep-module')

playground/css/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module.exports = {
33
}
44

55
const fs = require('fs')
6-
const glob = require('fast-glob')
76
const path = require('path')
7+
const glob = require('fast-glob')
88
const { normalizePath } = require('vite')
99

1010
/**

playground/json/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ async function createServer(
1515
/**
1616
* @type {import('vite').ViteDevServer}
1717
*/
18-
let vite
19-
vite = await require('vite').createServer({
18+
const vite = await require('vite').createServer({
2019
root,
2120
logLevel: isTest ? 'error' : 'info',
2221
server: {

playground/resolve/browser-field/relative.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-duplicates */
12
import ra from './no-ext'
23
import rb from './no-ext.js' // no substitution
34
import rc from './ext'

playground/tailwind/__test__/tailwind.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
2-
isBuild,
2+
browserLogs,
33
editFile,
4-
untilUpdated,
5-
getColor,
64
getBgColor,
7-
browserLogs,
8-
page
5+
getColor,
6+
isBuild,
7+
page,
8+
untilUpdated
99
} from '~utils'
1010

1111
test('should render', async () => {

playground/tailwind/src/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createWebHistory, createRouter } from 'vue-router'
1+
import { createRouter, createWebHistory } from 'vue-router'
22
import Page from './views/Page.vue'
33

44
const history = createWebHistory()

playground/wasm/worker.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import init from './add.wasm?init'
22
init().then(({ exports }) => {
3-
// eslint-disable-next-line no-undef
43
self.postMessage({ result: exports.add(1, 2) })
54
})

playground/worker/my-worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { msg as msgFromDep } from 'dep-to-optimize'
12
import { mode, msg } from './modules/workerImport'
23
import { bundleWithPlugin } from './modules/test-plugin'
3-
import { msg as msgFromDep } from 'dep-to-optimize'
44

55
self.onmessage = (e) => {
66
if (e.data === 'ping') {

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)