Skip to content

Commit

Permalink
Pre-work to update to ESLint 8 (#5699)
Browse files Browse the repository at this point in the history
This PR slightly took on scope creep (from the initial ask to just update `eslint-shared-config` to major version 15. Here's my thought process:

1. First, I bumped the above
2. Then, this causes an error with `eslint-plugin-jest`. I could resolve this by manually reinstalling it as a dev dependency. **I'm not sure if this is the right move**; if it isn't, let me know and I can move this commit out of the PR.
3. Finally, I address the newly enabled [`jest/prefer-to-be`](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-to-be.md) rule, which was a simple find-and-replace.

Let me know if we'd prefer dependabot to handle. I'm using node 16 to generate the new `package-lock`, and we stay on lockfile v2.
  • Loading branch information
mattxwang committed Nov 8, 2021
1 parent fe4efc2 commit 76f6fe0
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 176 deletions.
6 changes: 3 additions & 3 deletions lib/__tests__/cli.test.js
Expand Up @@ -290,7 +290,7 @@ describe('CLI', () => {
fixturesPath('empty-block-with-disables.css'),
]);

expect(process.exitCode).toEqual(1);
expect(process.exitCode).toBe(1);

expect(process.stderr.write).toHaveBeenCalledTimes(1);
expect(process.stderr.write).toHaveBeenCalledWith(
Expand All @@ -307,7 +307,7 @@ describe('CLI', () => {
fixturesPath('empty-block.css'),
]);

expect(process.exitCode).toEqual(2);
expect(process.exitCode).toBe(2);

expect(process.stdout.write).toHaveBeenCalledTimes(1);
const output = JSON.parse(process.stdout.write.mock.calls[0][0]);
Expand All @@ -329,7 +329,7 @@ describe('CLI', () => {
fixturesPath('empty-block.css'),
]);

expect(process.exitCode).toEqual(2);
expect(process.exitCode).toBe(2);

expect(process.stdout.write).toHaveBeenCalledTimes(0);
});
Expand Down
16 changes: 8 additions & 8 deletions lib/__tests__/standalone-globs.test.js
Expand Up @@ -38,7 +38,7 @@ describe('standalone globbing', () => {
});

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand All @@ -58,7 +58,7 @@ describe('standalone globbing', () => {
});

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand All @@ -77,7 +77,7 @@ describe('standalone globbing', () => {
});

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand All @@ -103,7 +103,7 @@ describe('standalone globbing', () => {
expect(results[0].source).toEqual(expect.stringContaining('lint-this-file.css'));

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('standalone globbing', () => {
});

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand All @@ -155,7 +155,7 @@ describe('standalone globbing', () => {
});

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand All @@ -180,7 +180,7 @@ describe('standalone globbing', () => {
});

expect(results).toHaveLength(1);
expect(results[0].errored).toEqual(true);
expect(results[0].errored).toBe(true);
expect(results[0].warnings[0]).toEqual(
expect.objectContaining({
rule: 'block-no-empty',
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('standalone globbing', () => {
// });

// expect(results).toHaveLength(1);
// expect(results[0].errored).toEqual(true);
// expect(results[0].errored).toBe(true);
// expect(results[0].warnings[0]).toEqual(
// expect.objectContaining({
// rule: 'block-no-empty',
Expand Down
4 changes: 2 additions & 2 deletions lib/__tests__/writeOutputFile.test.js
Expand Up @@ -10,7 +10,7 @@ describe('writeOutputFile', () => {

await writeOutputFile('test content', filePath);

expect((await fs.readFile(filePath)).toString()).toEqual('test content');
expect((await fs.readFile(filePath)).toString()).toBe('test content');

await fs.unlink(filePath);
});
Expand All @@ -20,7 +20,7 @@ describe('writeOutputFile', () => {

await writeOutputFile('test content', filePath);

expect((await fs.readFile(filePath)).toString()).toEqual('test content');
expect((await fs.readFile(filePath)).toString()).toBe('test content');

await fs.rmdir(path.dirname(filePath), { recursive: true });
});
Expand Down
Expand Up @@ -10,7 +10,7 @@ describe('isRectangular is', () => {
['a', 'a', '.'],
['.', 'b', 'c'],
]),
).toEqual(true);
).toBe(true);
});

test('false when not-rectangular', () => {
Expand All @@ -20,6 +20,6 @@ describe('isRectangular is', () => {
['a', 'a'],
['.', 'b', 'a'],
]),
).toEqual(false);
).toBe(false);
});
});
32 changes: 15 additions & 17 deletions lib/utils/__tests__/validateOptions.test.js
Expand Up @@ -23,7 +23,7 @@ describe('validateOptions for primary options', () => {
actual: 'd',
});
expect(result.warn).toHaveBeenCalledTimes(1);
expect(result.warn.mock.calls[0][0]).toEqual('Invalid option value "d" for rule "foo"');
expect(result.warn.mock.calls[0][0]).toBe('Invalid option value "d" for rule "foo"');
});

it('passing boolean equivalence', () => {
Expand All @@ -40,7 +40,7 @@ describe('validateOptions for primary options', () => {
actual: 'a',
});
expect(result.warn).toHaveBeenCalledTimes(1);
expect(result.warn.mock.calls[0][0]).toEqual('Invalid option value "a" for rule "foo"');
expect(result.warn.mock.calls[0][0]).toBe('Invalid option value "a" for rule "foo"');
});

it('passing evaluation', () => {
Expand All @@ -57,7 +57,7 @@ describe('validateOptions for primary options', () => {
actual: 1,
});
expect(result.warn).toHaveBeenCalledTimes(1);
expect(result.warn.mock.calls[0][0]).toEqual('Invalid option value "1" for rule "bar"');
expect(result.warn.mock.calls[0][0]).toBe('Invalid option value "1" for rule "bar"');
});

it('undefined `actual` with `possible` values and no `optional` option', () => {
Expand All @@ -66,7 +66,7 @@ describe('validateOptions for primary options', () => {
actual: undefined,
});
expect(result.warn).toHaveBeenCalledTimes(1);
expect(result.warn.mock.calls[0][0]).toEqual('Expected option value for rule "foo"');
expect(result.warn.mock.calls[0][0]).toBe('Expected option value for rule "foo"');
});
});

Expand Down Expand Up @@ -98,10 +98,10 @@ describe('validateOptions for secondary options objects', () => {
actual: { foo: 'neveer', bar: false },
});
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
expect(result.warn.mock.calls[0][0]).toBe(
'Invalid value "neveer" for option "foo" of rule "bar"',
);
expect(result.warn.mock.calls[1][0]).toEqual(
expect(result.warn.mock.calls[1][0]).toBe(
'Invalid value "false" for option "bar" of rule "bar"',
);
result.warn.mockClear();
Expand All @@ -111,7 +111,7 @@ describe('validateOptions for secondary options objects', () => {
actual: { foo: 'never', barr: 1 },
});
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual('Invalid option name "barr" for rule "bar"');
expect(result.warn.mock.calls[0][0]).toBe('Invalid option name "barr" for rule "bar"');
});

it('undefined `actual` with `possible` values and an `optional` option', () => {
Expand All @@ -129,7 +129,7 @@ describe('validateOptions for secondary options objects', () => {
actual: 2,
});
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
expect(result.warn.mock.calls[0][0]).toBe(
'Invalid option value 2 for rule "foo": should be an object',
);
});
Expand All @@ -141,7 +141,7 @@ describe('validateOptions for secondary options objects', () => {
});

expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
expect(result.warn.mock.calls[0][0]).toBe(
'Incorrect configuration for rule "foo". Rule should have "possible" values for options validation',
);
});
Expand All @@ -165,9 +165,7 @@ it('validateOptions for secondary options objects with subarrays', () => {
actual: { bar: ['one', 'three', 'floor'] },
});
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
'Invalid value "floor" for option "bar" of rule "foo"',
);
expect(result.warn.mock.calls[0][0]).toBe('Invalid value "floor" for option "bar" of rule "foo"');
});

describe('validateOptions for `*-no-*` rule with no valid options', () => {
Expand All @@ -193,7 +191,7 @@ describe('validateOptions for `*-no-*` rule with no valid options', () => {
actual: 'foo',
});
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
expect(result.warn.mock.calls[0][0]).toBe(
'Unexpected option value "foo" for rule "no-dancing"',
);
result.warn.mockClear();
Expand All @@ -202,7 +200,7 @@ describe('validateOptions for `*-no-*` rule with no valid options', () => {
actual: false,
});
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
expect(result.warn.mock.calls[0][0]).toBe(
'Unexpected option value "false" for rule "no-dancing"',
);
});
Expand Down Expand Up @@ -242,8 +240,8 @@ it('validateOptions for multiple actual/possible pairs, checking return value',

expect(invalidOptions).toBe(false);
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual('Invalid option value "onne" for rule "foo"');
expect(result.warn.mock.calls[1][0]).toEqual('Invalid option value "threee" for rule "foo"');
expect(result.warn.mock.calls[0][0]).toBe('Invalid option value "onne" for rule "foo"');
expect(result.warn.mock.calls[1][0]).toBe('Invalid option value "threee" for rule "foo"');
});

describe("validateOptions with a function for 'possible'", () => {
Expand Down Expand Up @@ -312,7 +310,7 @@ describe("validateOptions with a function for 'possible'", () => {

expect(invalidObject).toBe(false);
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toEqual(
expect(result.warn.mock.calls[0][0]).toBe(
'Invalid option "{"properties":["one"]}" for rule foo',
);
});
Expand Down
12 changes: 6 additions & 6 deletions lib/utils/__tests__/vendor.test.js
Expand Up @@ -5,13 +5,13 @@ const vendor = require('../vendor');
const VALUE = '-1px -1px 1px rgba(0, 0, 0, 0.2) inset';

it('returns prefix', () => {
expect(vendor.prefix('-moz-color')).toEqual('-moz-');
expect(vendor.prefix('color')).toEqual('');
expect(vendor.prefix(VALUE)).toEqual('');
expect(vendor.prefix('-moz-color')).toBe('-moz-');
expect(vendor.prefix('color')).toBe('');
expect(vendor.prefix(VALUE)).toBe('');
});

it('returns unprefixed version', () => {
expect(vendor.unprefixed('-moz-color')).toEqual('color');
expect(vendor.unprefixed('color')).toEqual('color');
expect(vendor.unprefixed(VALUE)).toEqual(VALUE);
expect(vendor.unprefixed('-moz-color')).toBe('color');
expect(vendor.unprefixed('color')).toBe('color');
expect(vendor.unprefixed(VALUE)).toBe(VALUE);
});

0 comments on commit 76f6fe0

Please sign in to comment.