Skip to content

Commit

Permalink
chore: handle different rule names depending on `@typescript-eslint/e…
Browse files Browse the repository at this point in the history
…slint-plugin` version
  • Loading branch information
G-Rath committed Aug 2, 2024
1 parent 69905c8 commit 56a7323
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
'use strict';

const {
version: typescriptESLintPluginVersion,
} = require('@typescript-eslint/eslint-plugin/package.json');
const semver = require('semver');
const globals = require('./src/globals.json');

const typescriptBanTypesRules = () => {
if (semver.major(typescriptESLintPluginVersion) === 8) {
return {
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
};
}

return {
'@typescript-eslint/ban-types': 'error',
};
};

module.exports = {
parser: require.resolve('@typescript-eslint/parser'),
extends: [
Expand Down Expand Up @@ -30,7 +48,7 @@ module.exports = {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/ban-types': 'error',
...typescriptBanTypesRules(),
'@typescript-eslint/consistent-type-imports': [
'error',
{ disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' },
Expand Down

0 comments on commit 56a7323

Please sign in to comment.