Skip to content

Commit

Permalink
Fix some rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Oct 27, 2024
1 parent 53b7bfb commit 656fcff
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,28 @@ const typeScriptRules = {
],
}

// TODO: remove once the following is released to `@eslint/compat`
// https://github.com/eslint/rewrite/issues/127
const fixupOldPluginRules = ({ rules, ...plugin }) => ({
...plugin,
rules: Object.fromEntries(
Object.entries(rules).map(([ruleName, rule]) => [
ruleName,
fixupOldPluginRule(rule),
]),
),
})

const fixupOldPluginRule = (rule) => ({
...rule,
create: typeof rule === 'function' ? rule : rule.create,
schema: undefined,
meta: {
...rule.meta,
schema: rule.schema ?? rule.create?.schema ?? [{}],
},
})

export default [
importPlugin.flatConfigs.errors,
{
Expand All @@ -235,8 +257,8 @@ export default [
'@stylistic/plus': stylisticPlus,
ava,
'eslint-comments': fixupPluginRules(eslintComments),
filenames: fixupPluginRules(filenames),
fp: fixupPluginRules(fp),
filenames: fixupPluginRules(fixupOldPluginRules(filenames)),
fp: fixupPluginRules(fixupOldPluginRules(fp)),
markdown,
'prefer-arrow-functions': preferArrowFunctions,
unicorn,
Expand Down Expand Up @@ -453,8 +475,16 @@ export default [
'no-delete-var': 2,
'fp/no-delete': 2,
'fp/no-mutating-assign': 2,
// Setting options to `eslint-plugin-fp` does not work with ESLint 9
'fp/no-mutating-methods': 0,
'fp/no-mutating-methods': [
2,
{
allowedObjects: [
...mutableObjects,
// gulp.watch() is flagged as mutable otherwise
'gulp',
],
},
],
'no-useless-assignment': 2,
// This is too strict
'fp/no-unused-expression': 0,
Expand Down Expand Up @@ -885,8 +915,8 @@ export default [

// Filenames
// Setting options to eslint-plugin-filenames does not work with ESLint 9
'filenames/match-regex': 0,
'filenames/match-exported': 0,
'filenames/match-regex': [2, '^[a-zA-Z_][a-zA-Z0-9_.]+$'],
'filenames/match-exported': [2, 'snake'],
'filenames/no-index': 2,
'unicorn/filename-case': [2, { case: 'snakeCase' }],
'unicorn/no-empty-file': 2,
Expand Down

0 comments on commit 656fcff

Please sign in to comment.