Skip to content

Commit 332c611

Browse files
authored
fix: disable jest/no-deprecated-functions is jest is not installed (#167)
1 parent 822d1c8 commit 332c611

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

recommended.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ const eslintJs = require('@eslint/js');
1717

1818
const base = require('./base');
1919

20+
// Some of the eslint-plugin-jest rules require jest to be installed and crashes ESLint if it's not present.
21+
// Exclude these rules if jest is not installed.
22+
// See https://github.com/salesforce/eslint-config-lwc/issues/161 and https://github.com/jest-community/eslint-plugin-jest/issues/1831 for more details.
23+
const jestRulesToDisable = () => {
24+
try {
25+
require.resolve('jest');
26+
return {};
27+
} catch {
28+
return {
29+
'jest/no-deprecated-functions': 'off',
30+
};
31+
}
32+
};
33+
2034
module.exports = [
2135
...base,
2236
eslintJs.configs.recommended,
@@ -35,6 +49,7 @@ module.exports = [
3549
},
3650
},
3751
rules: {
52+
...jestRulesToDisable(),
3853
// Possible errors
3954
// https://eslint.org/docs/rules/#possible-errors
4055
'no-await-in-loop': 'error',

0 commit comments

Comments
 (0)