Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit fa116b5

Browse files
committed
Add env property types
1 parent 761bcb0 commit fa116b5

File tree

4 files changed

+153
-6
lines changed

4 files changed

+153
-6
lines changed

.eslintrc.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,23 @@ module.exports = defineConfig({
8080
'warn',
8181
{
8282
minLength: 3,
83-
skipWords: ['backtick', 'backticks', 'ecma']
83+
skipWords: [
84+
'amd',
85+
'applescript',
86+
'atomtest',
87+
'backtick',
88+
'backticks',
89+
'browserify',
90+
'commonjs',
91+
'ecma',
92+
'embertest',
93+
'globals',
94+
'greasemonkey',
95+
'nashorn',
96+
'phantomjs',
97+
'prototypejs',
98+
'webextensions'
99+
]
84100
}
85101
],
86102

.vscode/settings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
{
2-
"cSpell.words": ["Quadflieg", "backticks", "readonly", "typeof"],
2+
"cSpell.words": [
3+
"Quadflieg",
4+
"applescript",
5+
"atomtest",
6+
"backticks",
7+
"embertest",
8+
"greasemonkey",
9+
"nashorn",
10+
"prototypejs",
11+
"qunit",
12+
"readonly",
13+
"serviceworker",
14+
"typeof",
15+
"webextensions"
16+
],
317
"eslint.validate": ["javascript", "typescript"],
418
"typescript.tsdk": "node_modules/typescript/lib"
519
}

src/env.ts

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,119 @@
11
/**
2+
* An environment provides predefined global variables.
23
*
4+
* @see [Environments](https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments)
35
*/
4-
export interface Env {
5-
es6?: boolean;
6+
export interface Environments extends Partial<Record<string, boolean>> {
7+
/*
8+
* Browser global variables.
9+
*/
10+
browser?: boolean;
11+
/*
12+
* Node.js global variables and Node.js scoping.
13+
*/
614
node?: boolean;
15+
/*
16+
* CommonJS global variables and CommonJS scoping (use this for browser-only code that uses Browserify/WebPack).
17+
*/
18+
commonjs?: boolean;
19+
/*
20+
* Globals common to both Node.js and Browser.
21+
*/
22+
'shared-node-browser'?: boolean;
23+
/*
24+
* Enable all ECMAScript 6 features except for modules (this automatically sets the ecmaVersion parser option to 6).
25+
*/
26+
es6?: boolean;
27+
/*
28+
* Adds all ECMAScript 2017 globals and automatically sets the ecmaVersion parser option to 8.
29+
*/
30+
es2017?: boolean;
31+
/*
32+
* Adds all ECMAScript 2020 globals and automatically sets the ecmaVersion parser option to 11.
33+
*/
34+
es2020?: boolean;
35+
/*
36+
* Adds all ECMAScript 2021 globals and automatically sets the ecmaVersion parser option to 12.
37+
*/
38+
es2021?: boolean;
39+
/*
40+
* Web workers global variables.
41+
*/
42+
worker?: boolean;
43+
/*
44+
* Defines `require()` and `define()` as global variables as per the amd spec.
45+
*/
46+
amd?: boolean;
47+
/*
48+
* Adds all of the Mocha testing global variables.
49+
*/
50+
mocha?: boolean;
51+
/*
52+
* Adds all of the Jasmine testing global variables for version 1.3 and 2.0.
53+
*/
54+
jasmine?: boolean;
55+
/*
56+
* Jest global variables.
57+
*/
58+
jest?: boolean;
59+
/*
60+
* PhantomJS global variables.
61+
*/
62+
phantomjs?: boolean;
63+
/*
64+
* Protractor global variables.
65+
*/
66+
protractor?: boolean;
67+
/*
68+
* QUnit global variables.
69+
*/
70+
qunit?: boolean;
71+
/*
72+
* jQuery global variables.
73+
*/
74+
jquery?: boolean;
75+
/*
76+
* Prototype.js global variables.
77+
*/
78+
prototypejs?: boolean;
79+
/*
80+
* ShellJS global variables.
81+
*/
82+
shelljs?: boolean;
83+
/*
84+
* Meteor global variables.
85+
*/
86+
meteor?: boolean;
87+
/*
88+
* MongoDB global variables.
89+
*/
90+
mongo?: boolean;
91+
/*
92+
* AppleScript global variables.
93+
*/
94+
applescript?: boolean;
95+
/*
96+
* Java 8 Nashorn global variables.
97+
*/
98+
nashorn?: boolean;
99+
/*
100+
* Service Worker global variables.
101+
*/
102+
serviceworker?: boolean;
103+
/*
104+
* Atom test helper globals.
105+
*/
106+
atomtest?: boolean;
107+
/*
108+
* Ember test helper globals.
109+
*/
110+
embertest?: boolean;
111+
/*
112+
* WebExtensions globals.
113+
*/
114+
webextensions?: boolean;
115+
/*
116+
* GreaseMonkey globals.
117+
*/
118+
greasemonkey?: boolean;
7119
}

src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Env } from './env';
1+
import type { Environments } from './env';
22
import type { Overrides } from './overrides';
33
import type { ParserOptions } from './parser-options';
44
import type { Rules } from './rules';
@@ -10,7 +10,12 @@ import type { Settings } from './settings';
1010
export interface EslintConfig {
1111
root?: boolean;
1212
ignorePatterns?: string[];
13-
env?: Env;
13+
/**
14+
* An environment provides predefined global variables.
15+
*
16+
* @see [Environments](https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments)
17+
*/
18+
env?: Environments;
1419
extends?: string[];
1520
parser?: string;
1621
parserOptions?: ParserOptions;

0 commit comments

Comments
 (0)