Skip to content

Commit

Permalink
chore: enable a couple more ESLint rules (#14686)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Nov 16, 2023
1 parent 540c239 commit a3320c4
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 113 deletions.
11 changes: 10 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ module.exports = {
],
},
},
{
files: 'e2e/coverage-remapping/covered.ts',
rules: {
'no-constant-binary-expression': 'off',
'no-constant-condition': 'off',
},
},

// 'eslint-plugin-jest' rules for test and test related files
{
Expand Down Expand Up @@ -218,6 +225,7 @@ module.exports = {
'jest/no-focused-tests': 'off',
'jest/require-to-throw-message': 'off',
'no-console': 'off',
'no-constant-condition': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'sort-keys': 'off',
Expand Down Expand Up @@ -489,7 +497,8 @@ module.exports = {
{allow: ['warn', 'error', 'time', 'timeEnd', 'timeStamp']},
],
'no-const-assign': 'error',
'no-constant-condition': 'off',
'no-constant-condition': 'error',
'no-constant-binary-expression': 'error',
'no-continue': 'off',
'no-control-regex': 'off',
'no-debugger': 'error',
Expand Down
15 changes: 10 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ logFilters:
nodeLinker: node-modules

packageExtensions:
"@algolia/autocomplete-core@*":
peerDependencies:
"@algolia/client-search": ^4.9.1
algoliasearch: ^4.18.0
"@algolia/autocomplete-plugin-algolia-insights@*":
peerDependencies:
"@algolia/client-search": ^4.9.1
algoliasearch: ^4.18.0
"@docsearch/react@*":
dependencies:
"@algolia/client-search": ^4.9.1
"@svgr/core@*":
babel-plugin-transform-flow-enums@*:
peerDependencies:
"@babel/core": ^7.1.6
psl@*:
dependencies:
punycode: ^2.1.1
"@babel/core": ^7.0.0
react-native@*:
peerDependencies:
"@babel/preset-env": ^7.1.6
Expand Down
28 changes: 14 additions & 14 deletions e2e/__tests__/__snapshots__/errorOnDeprecated.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ exports[`fail.test.js errors in errorOnDeprecated mode 1`] = `
Illegal usage of global \`fail\`, prefer throwing an error, or the \`done.fail\` callback.
9 | test('fail', () => {
10 | if (true) {
> 11 | fail('The truth hurts!');
10 | // eslint-disable-next-line no-constant-condition
11 | if (true) {
> 12 | fail('The truth hurts!');
| ^
12 | }
13 | });
14 |
13 | }
14 | });
15 |
at Object.fail (__tests__/fail.test.js:11:5)"
at Object.fail (__tests__/fail.test.js:12:5)"
`;
exports[`jasmine.addMatchers.test.js errors in errorOnDeprecated mode 1`] = `
Expand Down Expand Up @@ -173,15 +173,15 @@ exports[`pending.test.js errors in errorOnDeprecated mode 1`] = `
Illegal usage of global \`pending\`, prefer explicitly skipping a test using \`test.skip\`
9 | test('pending', () => {
10 | if (true) {
> 11 | pending('This test is pending.');
10 | // eslint-disable-next-line no-constant-condition
11 | if (true) {
> 12 | pending('This test is pending.');
| ^
12 | }
13 | expect(false).toBe(true);
14 | });
13 | }
14 | expect(false).toBe(true);
15 | });
at Object.pending (__tests__/pending.test.js:11:5)"
at Object.pending (__tests__/pending.test.js:12:5)"
`;
exports[`spyOn.test.js errors in errorOnDeprecated mode 1`] = `
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`moduleNameMapper wrong array configuration 1`] = `
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1172:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1174:17)
at Object.require (index.js:10:1)
at Object.require (__tests__/index.js:10:20)"
`;
Expand Down Expand Up @@ -71,7 +71,7 @@ exports[`moduleNameMapper wrong configuration 1`] = `
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1172:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1174:17)
at Object.require (index.js:10:1)
at Object.require (__tests__/index.js:10:20)"
`;
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/requireMissingExt.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`shows a proper error from deep requires 1`] = `
12 | test('dummy', () => {
13 | expect(1).toBe(1);
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:927:11)
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:929:11)
at Object.<anonymous> (node_modules/discord.js/src/index.js:21:12)
at Object.require (__tests__/test.js:10:1)"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`show error message with matching files 1`] = `
| ^
9 |
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:927:11)
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:929:11)
at Object.require (index.js:8:18)
at Object.require (__tests__/test.js:8:11)"
`;
2 changes: 1 addition & 1 deletion e2e/coverage-report/sumDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

require('path');

// eslint-disable-next-line prefer-template
// eslint-disable-next-line prefer-template, no-constant-condition
const uncoveredFunction = () => (true ? 1 + '5' : '999');

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions e2e/error-on-deprecated/__tests__/fail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'use strict';

test('fail', () => {
// eslint-disable-next-line no-constant-condition
if (true) {
fail('The truth hurts!');
}
Expand Down
1 change: 1 addition & 0 deletions e2e/error-on-deprecated/__tests__/pending.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'use strict';

test('pending', () => {
// eslint-disable-next-line no-constant-condition
if (true) {
pending('This test is pending.');
}
Expand Down
1 change: 1 addition & 0 deletions packages/jest-resolve/src/fileWalkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function findClosestPackageJson(start: string): string | undefined {
dir = dirname(dir);
}

// eslint-disable-next-line no-constant-condition
while (true) {
const pkgJsonFile = resolve(dir, './package.json');
const hasPackageJson = isFile(pkgJsonFile);
Expand Down
1 change: 1 addition & 0 deletions packages/jest-worker/src/PriorityQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class MinHeap<TItem extends HeapItem> {
nodes[0] = lastElement ?? null;
const element = nodes[0]!;

// eslint-disable-next-line no-constant-condition
while (true) {
let swapIndex = null;
const rightChildIndex = (index + 1) * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async function leakMemory() {
);

let i = Number.MAX_SAFE_INTEGER / 2;
// eslint-disable-next-line no-constant-condition
while (true) {
i++;

Expand Down
Loading

0 comments on commit a3320c4

Please sign in to comment.