Skip to content

Commit

Permalink
Merge pull request #165 from lishaduck/partial-sheriff
Browse files Browse the repository at this point in the history
Enable zero-config Sheriff
  • Loading branch information
AndreaPontrandolfo authored Jul 14, 2024
2 parents 25a4855 + 0fd4217 commit d1971c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-rules-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-config-sheriff': minor
---

feat: allow zero-config sheriff
13 changes: 4 additions & 9 deletions packages/eslint-config-sheriff/src/getExportableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getGitignorePatterns from 'eslint-config-flat-gitignore';
import lodash from 'lodash';
import type { FlatESLintConfig } from 'eslint-define-config';
import { SheriffSettings } from '@sherifforg/types';
import { ignores } from '@sherifforg/constants';
import { ignores, sheriffStartingOptions } from '@sherifforg/constants';
import { getReactConfig } from './getReactConfig';
import { getBaseConfig } from './getBaseConfig';
import { nextjsConfig } from './nextjsConfig';
Expand All @@ -15,23 +15,18 @@ import { prettierOverrides } from './prettierOverrides';
import { type TSESLint } from '@typescript-eslint/utils';

export const getExportableConfig = (
userConfigChoices: SheriffSettings,
userConfigChoices: SheriffSettings = sheriffStartingOptions,
areAllRulesForced?: boolean,
): FlatESLintConfig[] => {
if (!userConfigChoices) {
throw new Error('No settings provided.');
}

let exportableConfig: TSESLint.FlatConfig.ConfigArray = [
...getBaseConfig(userConfigChoices),
];

if (userConfigChoices.react || userConfigChoices.next) {
// we insert reactConfig this way because it's an array. It's an array because it contains multiple configs, currently: react, react-hooks, react-a11y and react-refresh.
exportableConfig = [
...exportableConfig,
exportableConfig.push(
...getReactConfig(userConfigChoices.pathsOverrides?.tsconfigLocation),
];
);
}

if (
Expand Down

0 comments on commit d1971c3

Please sign in to comment.