Skip to content

Commit aa8acd2

Browse files
authored
Added no-undef rule (#1419)
1 parent 3f080f0 commit aa8acd2

25 files changed

+78
-96
lines changed

eslint.config.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { defineConfig } from 'eslint/config';
44
import importPlugin from 'eslint-plugin-import';
55
import prettierRecommended from 'eslint-plugin-prettier/recommended';
66
import unusedImports from 'eslint-plugin-unused-imports';
7+
import globals from 'globals';
78

89
export default defineConfig([
910
js.configs.recommended,
@@ -52,8 +53,30 @@ export default defineConfig([
5253
},
5354
},
5455

56+
// globals
5557
{
56-
files: ['**/*.{js,mjs}'],
58+
files: ['test/**/*.js'],
59+
languageOptions: { globals: { ...globals.mocha } },
60+
},
61+
62+
{
63+
files: ['src/**/*.{js,cjs}', 'test/**/*.js'],
64+
languageOptions: { globals: { ...globals.browser } },
65+
},
66+
67+
{
68+
files: [
69+
'src/server/**/*.js',
70+
'src/react-native/**/*.js',
71+
'test/**/server.*.js',
72+
'scripts/**/*.js',
73+
],
74+
languageOptions: { globals: { ...globals.node } },
75+
},
76+
77+
// sources
78+
{
79+
files: ['**/*.js'],
5780
languageOptions: {
5881
sourceType: 'module',
5982
parser: babelParser,
@@ -64,26 +87,22 @@ export default defineConfig([
6487
rules: {
6588
strict: ['error', 'safe'],
6689
'no-prototype-builtins': 'off',
67-
'no-undef': 'off',
6890
},
6991
},
7092

93+
// cjs
7194
{
7295
files: ['**/*.cjs'],
73-
languageOptions: {
74-
sourceType: 'commonjs',
75-
},
76-
rules: {
77-
strict: 'off',
78-
},
96+
languageOptions: { sourceType: 'commonjs' },
97+
rules: { strict: 'off' },
7998
},
8099

100+
// scripts
81101
{
82-
files: ['scripts/**/*.{js,mjs,cjs}'],
83-
rules: {
84-
'no-console': 'off',
85-
},
102+
files: ['scripts/**/*.{js,cjs}'],
103+
rules: { 'no-console': 'off' },
86104
},
105+
87106
{
88107
ignores: ['dist', 'examples', 'node_modules', 'vendor', 'coverage'],
89108
},

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"eslint-plugin-unused-imports": "^4.3.0",
108108
"express": "^4.21.2",
109109
"glob": "^5.0.14",
110+
"globals": "^16.5.0",
110111
"mocha": "^11.1.0",
111112
"nock": "^11.9.1",
112113
"node-libs-browser": "^0.5.2",

test/browser.transport.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,28 @@ describe('post', function () {
151151
it('should use fetch when requested', function (done) {
152152
var callback = function (err, _resp) {
153153
expect(window.fetchStub.called).to.be.ok;
154-
expect(server.requests.length).to.eql(0);
154+
expect(window.server.requests.length).to.eql(0);
155155
done(err);
156156
};
157157
stubFetchResponse();
158158
stubXhrResponse();
159-
server.requests.length = 0;
159+
window.server.requests.length = 0;
160160
options.transport = 'fetch';
161161
t.post({ accessToken, options, payload, callback });
162162
});
163163
it('should use xhr when requested', function (done) {
164164
var callback = function (err, _resp) {
165165
expect(window.fetchStub.called).to.not.be.ok;
166-
expect(server.requests.length).to.eql(1);
166+
expect(window.server.requests.length).to.eql(1);
167167
done(err);
168168
};
169169
stubFetchResponse();
170170
stubXhrResponse();
171-
server.requests.length = 0;
171+
window.server.requests.length = 0;
172172
options.transport = 'xhr';
173173
t.post({ accessToken, options, payload, callback });
174174
setTimeout(function () {
175-
server.respond();
175+
window.server.respond();
176176
}, 1);
177177
});
178178
});

test/server.lambda.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* globals describe */
2-
/* globals it */
3-
/* globals beforeEach */
4-
51
import { expect } from 'chai';
62
import sinon from 'sinon';
73

test/server.locals.constructor.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* globals describe */
2-
/* globals it */
3-
41
import { expect } from 'chai';
52

63
import logger from '../src/logger.js';

test/server.locals.error-handling.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* globals describe */
2-
/* globals it */
3-
/* globals beforeEach */
4-
/* globals afterEach */
5-
61
import { expect } from 'chai';
72
import sinon from 'sinon';
83

@@ -18,7 +13,7 @@ import {
1813
nodeThrowWithNestedLocals,
1914
nodeThrowRecursionError,
2015
verifyRejectedPromise,
21-
} from './server.locals.test-utils.mjs';
16+
} from './server.locals.test-utils.js';
2217

2318
describe('server.locals error handling', function () {
2419
let mochaExceptionHandlers;

test/server.locals.merge.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* globals describe */
2-
/* globals it */
3-
/* globals afterEach */
4-
51
import { expect } from 'chai';
62
import sinon from 'sinon';
73

File renamed without changes.

test/server.parser.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* globals describe */
2-
/* globals it */
3-
/* globals beforeEach */
4-
51
import { expect } from 'chai';
62

73
import * as p from '../src/server/parser.js';

0 commit comments

Comments
 (0)