Closed dependabot[bot] closed 3 years ago
It seems nice to add the following new rules for keeping code consistency:
The following is an experiment on the stylelint/stylelint (v14
) repository using npm run lint:js -- --fix
:
diff --git a/lib/__tests__/cli.test.js b/lib/__tests__/cli.test.js
index 263cc1b0..d5f119ad 100644
--- a/lib/__tests__/cli.test.js
+++ b/lib/__tests__/cli.test.js
@@ -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(
@@ -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]);
@@ -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);
});
diff --git a/lib/__tests__/standalone-globs.test.js b/lib/__tests__/standalone-globs.test.js
index e5fc550a..4516a87b 100644
--- a/lib/__tests__/standalone-globs.test.js
+++ b/lib/__tests__/standalone-globs.test.js
@@ -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',
@@ -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',
@@ -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',
@@ -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',
@@ -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',
@@ -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',
@@ -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',
diff --git a/lib/rules/named-grid-areas-no-invalid/utils/__tests__/isRectangular.test.js b/lib/rules/named-grid-areas-no-invalid/utils/__tests__/isRectangular.test.js
index 3b720841..b21ad014 100644
--- a/lib/rules/named-grid-areas-no-invalid/utils/__tests__/isRectangular.test.js
+++ b/lib/rules/named-grid-areas-no-invalid/utils/__tests__/isRectangular.test.js
@@ -10,7 +10,7 @@ describe('isRectangular is', () => {
['a', 'a', '.'],
['.', 'b', 'c'],
]),
- ).toEqual(true);
+ ).toBe(true);
});
test('false when not-rectangular', () => {
@@ -20,6 +20,6 @@ describe('isRectangular is', () => {
['a', 'a'],
['.', 'b', 'a'],
]),
- ).toEqual(false);
+ ).toBe(false);
});
});
diff --git a/lib/utils/__tests__/validateOptions.test.js b/lib/utils/__tests__/validateOptions.test.js
index d7dccbc0..ac41ab66 100644
--- a/lib/utils/__tests__/validateOptions.test.js
+++ b/lib/utils/__tests__/validateOptions.test.js
@@ -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', () => {
@@ -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', () => {
@@ -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', () => {
@@ -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"');
});
});
@@ -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();
@@ -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', () => {
@@ -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',
);
});
@@ -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',
);
});
@@ -165,7 +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(
+ expect(result.warn.mock.calls[0][0]).toBe(
'Invalid value "floor" for option "bar" of rule "foo"',
);
});
@@ -193,7 +193,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();
@@ -202,7 +202,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"',
);
});
@@ -242,8 +242,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'", () => {
@@ -312,7 +312,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',
);
});
diff --git a/lib/utils/__tests__/vendor.test.js b/lib/utils/__tests__/vendor.test.js
index 27e95f7b..7e4ecdb4 100644
--- a/lib/utils/__tests__/vendor.test.js
+++ b/lib/utils/__tests__/vendor.test.js
@@ -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('-moz-color')).toBe('color');
+ expect(vendor.unprefixed('color')).toBe('color');
expect(vendor.unprefixed(VALUE)).toEqual(VALUE);
});
diff --git a/package.json b/package.json
index 0d98e57b..dbe0a68d 100644
--- a/package.json
+++ b/package.json
@@ -66,7 +66,11 @@
"require": true,
"testRule": true
},
- "root": true
+ "root": true,
+ "rules": {
+ "jest/prefer-expect-resolves": "error",
+ "jest/prefer-to-be": "error"
+ }
},
"remarkConfig": {
"plugins": [
@@ -113,6 +117,7 @@
"balanced-match": "^2.0.0",
"cosmiconfig": "^7.0.1",
"debug": "^4.3.2",
+ "eslint-plugin-jest": "^24.5.2",
"execall": "^2.0.0",
"fast-glob": "^3.2.7",
"fastest-levenshtein": "^1.0.12",
I'll create a new PR to turn on the rules!
Oh, eslint-plugin-jest
has been prepared for the next major version 25.0.0, so I guess we'd better wait. See below:
Bumps eslint-plugin-jest from 24.4.0 to 24.5.0.
Release notes
Sourced from eslint-plugin-jest's releases.
Changelog
Sourced from eslint-plugin-jest's changelog.
Commits
84688e9
chore(release): 24.5.0 [skip ci]2556020
feat: createprefer-expect-resolves
rule (#822)3a64aea
feat: createprefer-to-be
rule (#864)6940488
fix(no-deprecated-functions): removeprocess.cwd
from resolve paths (#889)ffc9392
feat(valid-title): allow custom matcher messages (#913)14a2d13
feat(require-top-level-describe): support enforcing max num of describes (#912)a41a40e
fix(no-identical-title): always consider.each
titles unique (#910)bcc8176
chore(release): 24.4.3 [skip ci]4798005
fix(valid-expect-in-promise): support additional test functions (#915)9c89855
fix(valid-expect-in-promise): supportfinally
(#914)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)