Skip to content

Commit f56664a

Browse files
authored
Revert "Remove globals from config (#2672)"
This reverts commit 36e3dda.
1 parent 36e3dda commit f56664a

File tree

6 files changed

+14
-78
lines changed

6 files changed

+14
-78
lines changed

docs/user-guide/index.md

+1-75
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ npm install --save-dev eslint eslint-plugin-vue
1111
Via [yarn](https://yarnpkg.com/):
1212

1313
```bash
14-
yarn add -D eslint eslint-plugin-vue globals
14+
yarn add -D eslint eslint-plugin-vue
1515
```
1616

1717
::: tip Requirements
@@ -31,8 +31,6 @@ Example **eslint.config.js**:
3131

3232
```js
3333
import pluginVue from 'eslint-plugin-vue'
34-
import globals from 'globals'
35-
3634
export default [
3735
// add more generic rulesets here, such as:
3836
// js.configs.recommended,
@@ -42,12 +40,6 @@ export default [
4240
rules: {
4341
// override/add rules settings here, such as:
4442
// 'vue/no-unused-vars': 'error'
45-
},
46-
languageOptions: {
47-
sourceType: 'module',
48-
globals: {
49-
...globals.browser
50-
}
5143
}
5244
}
5345
]
@@ -75,48 +67,6 @@ You can use the following configs by adding them to `eslint.config.js`.
7567
By default, all rules from **base** and **essential** categories report ESLint errors. Other rules - because they're not covering potential bugs in the application - report warnings. What does it mean? By default - nothing, but if you want - you can set up a threshold and break the build after a certain amount of warnings, instead of any. More information [here](https://eslint.org/docs/user-guide/command-line-interface#handling-warnings).
7668
:::
7769

78-
#### Specifying Globals (`eslint.config.js`)
79-
80-
Specify global objects depending on how you use Vue.js. More information on how to set globals can be found [here](https://eslint.org/docs/latest/use/configure/language-options#predefined-global-variables).
81-
82-
If you're writing an app that will only render on the browser, use `globals.browser`.
83-
84-
```js
85-
// ...
86-
import globals from 'globals'
87-
88-
export default [
89-
// ...
90-
{
91-
languageOptions: {
92-
globals: {
93-
...globals.browser
94-
}
95-
}
96-
}
97-
// ...
98-
]
99-
```
100-
101-
If you're writing an app that is rendered both server-side and on the browser, use `globals.shared-node-browser`.
102-
103-
```js
104-
// ...
105-
import globals from 'globals'
106-
107-
export default [
108-
// ...
109-
{
110-
languageOptions: {
111-
globals: {
112-
...globals['shared-node-browser']
113-
}
114-
}
115-
}
116-
// ...
117-
]
118-
```
119-
12070
#### Example configuration with [typescript-eslint](https://typescript-eslint.io/) and [Prettier](https://prettier.io/)
12171

12272
```bash
@@ -202,30 +152,6 @@ This plugin supports the basic syntax of Vue.js 3.2, `<script setup>`, and CSS v
202152
If you have issues with these, please also refer to the [FAQ](#does-not-work-well-with-script-setup). If you can't find a solution, search for the issue and if the issue doesn't exist, open a new issue.
203153
:::
204154

205-
#### Specifying Environments (`.eslintrc`)
206-
207-
Specify environments depending on how you use Vue.js. More information on how to set environments can be found [here](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-environments).
208-
209-
If you're writing an app that will only render on the browser, use `env.browser`.
210-
211-
```json
212-
{
213-
"env": {
214-
"browser": true
215-
}
216-
}
217-
```
218-
219-
If you're writing an app that is rendered both server-side and on the browser, use `env.shared-node-browser`.
220-
221-
```json
222-
{
223-
"env": {
224-
"shared-node-browser": true
225-
}
226-
}
227-
```
228-
229155
### Running ESLint from the command line
230156

231157
If you want to run `eslint` from the command line, ESLint will automatically check for the `.vue` extension if you use the config provided by the plugin.

lib/configs/base.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
* This file has been automatically generated,
44
* in order to update its content execute "npm run update"
55
*/
6+
const globals = require('globals')
67
module.exports = {
78
parserOptions: {
89
ecmaVersion: 'latest',
910
sourceType: 'module'
1011
},
12+
globals: globals.browser,
1113
plugins: ['vue'],
1214
rules: {
1315
'vue/comment-directive': 'error',

lib/configs/flat/base.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* This file has been automatically generated,
44
* in order to update its content execute "npm run update"
55
*/
6+
const globals = require('globals')
67
module.exports = [
78
{
89
name: 'vue/base/setup',
@@ -12,7 +13,8 @@ module.exports = [
1213
}
1314
},
1415
languageOptions: {
15-
sourceType: 'module'
16+
sourceType: 'module',
17+
globals: globals.browser
1618
}
1719
},
1820
{
@@ -25,7 +27,8 @@ module.exports = [
2527
},
2628
languageOptions: {
2729
parser: require('vue-eslint-parser'),
28-
sourceType: 'module'
30+
sourceType: 'module',
31+
globals: globals.browser
2932
},
3033
rules: {
3134
'vue/comment-directive': 'error',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
},
6060
"dependencies": {
6161
"@eslint-community/eslint-utils": "^4.4.0",
62+
"globals": "^15.14.0",
6263
"natural-compare": "^1.4.0",
6364
"nth-check": "^2.1.1",
6465
"postcss-selector-parser": "^6.0.15",
@@ -90,7 +91,6 @@
9091
"eslint-plugin-vue": "file:.",
9192
"espree": "^9.6.1",
9293
"events": "^3.3.0",
93-
"globals": "^15.14.0",
9494
"jsdom": "^22.0.0",
9595
"markdownlint-cli": "^0.42.0",
9696
"mocha": "^10.7.3",

tools/update-lib-configs.js

+2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ function formatCategory(category) {
5555
* This file has been automatically generated,
5656
* in order to update its content execute "npm run update"
5757
*/
58+
const globals = require('globals')
5859
module.exports = {
5960
parserOptions: {
6061
ecmaVersion: 'latest',
6162
sourceType: 'module'
6263
},
64+
globals: globals.browser,
6365
plugins: [
6466
'vue'
6567
],

tools/update-lib-flat-configs.js

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function formatCategory(category) {
5555
* This file has been automatically generated,
5656
* in order to update its content execute "npm run update"
5757
*/
58+
const globals = require('globals')
5859
module.exports = [
5960
{
6061
name: 'vue/base/setup',
@@ -65,6 +66,7 @@ module.exports = [
6566
},
6667
languageOptions: {
6768
sourceType: 'module',
69+
globals: globals.browser
6870
}
6971
},
7072
{
@@ -78,6 +80,7 @@ module.exports = [
7880
languageOptions: {
7981
parser: require('vue-eslint-parser'),
8082
sourceType: 'module',
83+
globals: globals.browser
8184
},
8285
rules: ${formatRules(category.rules, category.categoryId)},
8386
processor: 'vue/vue'

0 commit comments

Comments
 (0)