Skip to content

Commit

Permalink
fix: add names to flat configs
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Jun 13, 2024
1 parent fbc9fca commit f4237dd
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,19 @@ const index = {

/**
* @param {"warn"|"error"} warnOrError
* @param {boolean} [flat]
* @param {string} [flatName]
* @returns {import('eslint').Linter.FlatConfig}
*/
const createRecommendedRuleset = (warnOrError, flat) => {
const createRecommendedRuleset = (warnOrError, flatName) => {
return {
name: flatName,
// @ts-expect-error Ok
plugins: flat ? {
jsdoc: index,
} : [
'jsdoc',
],
plugins:
flatName ? {
jsdoc: index,
} : [
'jsdoc',
],
rules: {
'jsdoc/check-access': warnOrError,
'jsdoc/check-alignment': warnOrError,
Expand Down Expand Up @@ -199,11 +201,11 @@ const createRecommendedRuleset = (warnOrError, flat) => {

/**
* @param {"warn"|"error"} warnOrError
* @param {boolean} [flat]
* @param {string} [flatName]
* @returns {import('eslint').Linter.FlatConfig}
*/
const createRecommendedTypeScriptRuleset = (warnOrError, flat) => {
const ruleset = createRecommendedRuleset(warnOrError, flat);
const createRecommendedTypeScriptRuleset = (warnOrError, flatName) => {
const ruleset = createRecommendedRuleset(warnOrError, flatName);

return {
...ruleset,
Expand All @@ -227,11 +229,11 @@ const createRecommendedTypeScriptRuleset = (warnOrError, flat) => {

/**
* @param {"warn"|"error"} warnOrError
* @param {boolean} [flat]
* @param {string} [flatName]
* @returns {import('eslint').Linter.FlatConfig}
*/
const createRecommendedTypeScriptFlavorRuleset = (warnOrError, flat) => {
const ruleset = createRecommendedRuleset(warnOrError, flat);
const createRecommendedTypeScriptFlavorRuleset = (warnOrError, flatName) => {
const ruleset = createRecommendedRuleset(warnOrError, flatName);

return {
...ruleset,
Expand All @@ -256,11 +258,11 @@ index.configs['recommended-typescript-error'] = createRecommendedTypeScriptRules
index.configs['recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn');
index.configs['recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error');

index.configs['flat/recommended'] = createRecommendedRuleset('warn', true);
index.configs['flat/recommended-error'] = createRecommendedRuleset('error', true);
index.configs['flat/recommended-typescript'] = createRecommendedTypeScriptRuleset('warn', true);
index.configs['flat/recommended-typescript-error'] = createRecommendedTypeScriptRuleset('error', true);
index.configs['flat/recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn', true);
index.configs['flat/recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error', true);
index.configs['flat/recommended'] = createRecommendedRuleset('warn', 'flat/recommended');
index.configs['flat/recommended-error'] = createRecommendedRuleset('error', 'flat/recommended-error');
index.configs['flat/recommended-typescript'] = createRecommendedTypeScriptRuleset('warn', 'flat/recommended-typescript');
index.configs['flat/recommended-typescript-error'] = createRecommendedTypeScriptRuleset('error', 'flat/recommended-typescript-error');
index.configs['flat/recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn', 'flat/recommended-typescript-flavor');
index.configs['flat/recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error', 'flat/recommended-typescript-flavor-error');

export default index;

0 comments on commit f4237dd

Please sign in to comment.