Skip to content

Commit

Permalink
fix: correctly import jest flat configs (#365)
Browse files Browse the repository at this point in the history
* fix: correctly import jest flat configs
* put algolia rules at the end
  • Loading branch information
sbellone authored Oct 15, 2024
1 parent 67166ab commit 4162bbf
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
10 changes: 3 additions & 7 deletions packages/eslint-config-algolia/flat/jest.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/* eslint-disable import/no-commonjs */
const jestPlugin = require('eslint-plugin-jest');
const globals = require('globals');

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

module.exports = [
jestRules,
{
...jestPlugin.configs['flat/recommended'],
},
{
...jestPlugin.configs['flat/style'],
languageOptions: {
globals: {
...globals.jest,
},
},
},
jestRules,
];
3 changes: 3 additions & 0 deletions packages/test/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = [
project: 'tsconfig.json',
},
},
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
];
1 change: 0 additions & 1 deletion packages/test/src/connect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default function connect(mapStateToProps) {
}
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState(mapStateToProps(this.context.algoliaStore.getState(), nextProps));
}
Expand Down
17 changes: 17 additions & 0 deletions packages/test/src/simple.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('simple tests', () => {
// Test a rule from the Algolia config
// eslint-disable-next-line jest/consistent-test-it
test('should do simple maths', () => {
expect(Math.pow(2, 8)).toBe(256);
});

// Test a rule from the recommended config (https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-commented-out-tests.md)
// eslint-disable-next-line jest/no-commented-out-tests
// it('foo', () => {});

it('should do simple comparison', () => {
// Test a rule from the style config (https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-to-be.md)
// eslint-disable-next-line jest/prefer-to-be
expect(0).toEqual(0);
});
});
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2861,12 +2861,12 @@ __metadata:

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

Expand Down

0 comments on commit 4162bbf

Please sign in to comment.