Skip to content

Commit 4162bbf

Browse files
authored
fix: correctly import jest flat configs (#365)
* fix: correctly import jest flat configs * put algolia rules at the end
1 parent 67166ab commit 4162bbf

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed
+3-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
/* eslint-disable import/no-commonjs */
22
const jestPlugin = require('eslint-plugin-jest');
3-
const globals = require('globals');
43

54
const jestRules = require('../rules/jest');
65

76
module.exports = [
8-
jestRules,
97
{
108
...jestPlugin.configs['flat/recommended'],
9+
},
10+
{
1111
...jestPlugin.configs['flat/style'],
12-
languageOptions: {
13-
globals: {
14-
...globals.jest,
15-
},
16-
},
1712
},
13+
jestRules,
1814
];

packages/test/eslint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ module.exports = [
1515
project: 'tsconfig.json',
1616
},
1717
},
18+
linterOptions: {
19+
reportUnusedDisableDirectives: 'error',
20+
},
1821
},
1922
];

packages/test/src/connect.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default function connect(mapStateToProps) {
3030
}
3131
}
3232

33-
// eslint-disable-next-line camelcase
3433
UNSAFE_componentWillReceiveProps(nextProps) {
3534
this.setState(mapStateToProps(this.context.algoliaStore.getState(), nextProps));
3635
}

packages/test/src/simple.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('simple tests', () => {
2+
// Test a rule from the Algolia config
3+
// eslint-disable-next-line jest/consistent-test-it
4+
test('should do simple maths', () => {
5+
expect(Math.pow(2, 8)).toBe(256);
6+
});
7+
8+
// Test a rule from the recommended config (https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-commented-out-tests.md)
9+
// eslint-disable-next-line jest/no-commented-out-tests
10+
// it('foo', () => {});
11+
12+
it('should do simple comparison', () => {
13+
// Test a rule from the style config (https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-to-be.md)
14+
// eslint-disable-next-line jest/prefer-to-be
15+
expect(0).toEqual(0);
16+
});
17+
});

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2861,12 +2861,12 @@ __metadata:
28612861

28622862
"eslint-config-algolia@file:../eslint-config-algolia::locator=test%40workspace%3Apackages%2Ftest":
28632863
version: 23.2.0
2864-
resolution: "eslint-config-algolia@file:../eslint-config-algolia#../eslint-config-algolia::hash=792dff&locator=test%40workspace%3Apackages%2Ftest"
2864+
resolution: "eslint-config-algolia@file:../eslint-config-algolia#../eslint-config-algolia::hash=5dc416&locator=test%40workspace%3Apackages%2Ftest"
28652865
peerDependencies:
28662866
"@stylistic/eslint-plugin": ^2.6.4
28672867
eslint: ^5.16.0 || ^6.8.0 || ^7.2.0 || ^8.0.0 || ^9.0.0
28682868
prettier: ^3.0.0
2869-
checksum: 10c0/d01694d1a43cfce890f3f5b6dccad74e1e8ef5714f2a820d7f44caa6f8c36d58d51d33979a019d3dfcbc4c4bea272f3ab1b96a9d51f161e318c15380065dccd4
2869+
checksum: 10c0/a9d3f9824735bfa89570b1bb4ad1df4027ca0f4cba977edb376ad4a812253560a26a94c2c05cfef3ec4ce8d3bb16385ff91e7cf156e1b651396eed25ec3d3399
28702870
languageName: node
28712871
linkType: hard
28722872

0 commit comments

Comments
 (0)