Skip to content

Commit fe27912

Browse files
Enable 'new-cap' ESLint rule (#2762)
1 parent db57982 commit fe27912

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ rules:
313313
max-statements: off
314314
max-statements-per-line: off
315315
multiline-comment-style: off
316-
new-cap: off # TODO
316+
new-cap: error
317317
no-array-constructor: error
318318
no-bitwise: off
319319
no-continue: off

resources/benchmark.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const maxTime = 5;
1717
// The minimum sample size required to perform statistical analysis.
1818
const minSamples = 5;
1919

20-
function LOCAL_DIR(...paths) {
20+
function localDir(...paths) {
2121
return path.join(__dirname, '..', ...paths);
2222
}
2323

@@ -27,7 +27,7 @@ function prepareRevision(revision) {
2727
console.log(`🍳 Preparing ${revision}...`);
2828

2929
if (revision === LOCAL) {
30-
return babelBuild(LOCAL_DIR());
30+
return babelBuild(localDir());
3131
}
3232

3333
// Returns the complete git hash for a given git revision reference.
@@ -40,12 +40,12 @@ function prepareRevision(revision) {
4040
exec(`git archive "${hash}" | tar -xC "${dir}"`);
4141
exec('npm ci', { cwd: dir });
4242

43-
for (const file of findFiles(LOCAL_DIR('src'), '*/__tests__/*')) {
44-
const from = LOCAL_DIR('src', file);
43+
for (const file of findFiles(localDir('src'), '*/__tests__/*')) {
44+
const from = localDir('src', file);
4545
const to = path.join(dir, 'src', file);
4646
fs.copyFileSync(from, to);
4747
}
48-
exec(`cp -R "${LOCAL_DIR()}/src/__fixtures__/" "${dir}/src/__fixtures__/"`);
48+
exec(`cp -R "${localDir()}/src/__fixtures__/" "${dir}/src/__fixtures__/"`);
4949

5050
return babelBuild(dir);
5151
}
@@ -259,7 +259,7 @@ async function prepareAndRunBenchmarks(benchmarkPatterns, revisions) {
259259

260260
// Find all benchmark tests to be run.
261261
function matchBenchmarks(patterns) {
262-
let benchmarks = findFiles(LOCAL_DIR('src'), '*/__tests__/*-benchmark.js');
262+
let benchmarks = findFiles(localDir('src'), '*/__tests__/*-benchmark.js');
263263
if (patterns.length > 0) {
264264
benchmarks = benchmarks.filter((benchmark) =>
265265
patterns.some((pattern) => path.join('src', benchmark).includes(pattern)),

src/utilities/__tests__/coerceInputValue-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ describe('coerceInputValue', () => {
260260
});
261261

262262
describe('for GraphQLInputObject with default value', () => {
263-
const TestInputObject = (defaultValue) =>
263+
const makeTestInputObject = (defaultValue) =>
264264
new GraphQLInputObjectType({
265265
name: 'TestInputObject',
266266
fields: {
@@ -272,22 +272,22 @@ describe('coerceInputValue', () => {
272272
});
273273

274274
it('returns no errors for valid input value', () => {
275-
const result = coerceValue({ foo: 5 }, TestInputObject(7));
275+
const result = coerceValue({ foo: 5 }, makeTestInputObject(7));
276276
expectValue(result).to.deep.equal({ foo: 5 });
277277
});
278278

279279
it('returns object with default value', () => {
280-
const result = coerceValue({}, TestInputObject(7));
280+
const result = coerceValue({}, makeTestInputObject(7));
281281
expectValue(result).to.deep.equal({ foo: 7 });
282282
});
283283

284284
it('returns null as value', () => {
285-
const result = coerceValue({}, TestInputObject(null));
285+
const result = coerceValue({}, makeTestInputObject(null));
286286
expectValue(result).to.deep.equal({ foo: null });
287287
});
288288

289289
it('returns NaN as value', () => {
290-
const result = coerceValue({}, TestInputObject(NaN));
290+
const result = coerceValue({}, makeTestInputObject(NaN));
291291
expectValue(result).to.have.property('foo').that.satisfy(Number.isNaN);
292292
});
293293
});

src/validation/rules/KnownArgumentNamesRule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
*/
2222
export function KnownArgumentNamesRule(context: ValidationContext): ASTVisitor {
2323
return {
24+
// eslint-disable-next-line new-cap
2425
...KnownArgumentNamesOnDirectivesRule(context),
2526
Argument(argNode) {
2627
const argDef = context.getArgument();

src/validation/rules/ProvidedRequiredArgumentsRule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function ProvidedRequiredArgumentsRule(
2525
context: ValidationContext,
2626
): ASTVisitor {
2727
return {
28+
// eslint-disable-next-line new-cap
2829
...ProvidedRequiredArgumentsOnDirectivesRule(context),
2930
Field: {
3031
// Validate on leave to allow for deeper errors to appear first.

0 commit comments

Comments
 (0)