Skip to content

Commit

Permalink
feat: add support for flat configs
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Mar 13, 2024
1 parent 3a7f95f commit 429db04
Show file tree
Hide file tree
Showing 46 changed files with 731 additions and 458 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,52 +106,52 @@ The [below section](#rules) gives details on which rules are enabled by each rul

### Currying

| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 | |
| :----------------------------------------------------------- | :----------------------------- | :------------------------ | :--- | :--- | :--- | :--- | :--- | :--- |
| [functional-parameters](docs/rules/functional-parameters.md) | Enforce functional parameters. | ☑️ ✅ 🔒 ![badge-currying][] | | | | | | |
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
| :----------------------------------------------------------- | :----------------------------- | :-------------------------- | :- | :- | :- | :- | :- | :- |
| [functional-parameters](docs/rules/functional-parameters.md) | Enforce functional parameters. | ☑️ ✅ 🔒 ![badge-currying][] | | | | | | |

### No Exceptions

| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 | |
| :------------------------------------------------------- | :----------------------------------------------------- | :----------------------------- | :--- | :--- | :--- | :--- | :--- | :--- |
| [no-promise-reject](docs/rules/no-promise-reject.md) | Disallow rejecting promises. | | | | | | | |
| [no-throw-statements](docs/rules/no-throw-statements.md) | Disallow throwing exceptions. | ☑️ ✅ 🔒 ![badge-no-exceptions][] | | | | | | |
| [no-try-statements](docs/rules/no-try-statements.md) | Disallow try-catch[-finally] and try-finally patterns. | 🔒 ![badge-no-exceptions][] | | ☑️ ✅ | | | | |
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
| :------------------------------------------------------- | :----------------------------------------------------- | :------------------------------- | :- | :--- | :- | :- | :- | :- |
| [no-promise-reject](docs/rules/no-promise-reject.md) | Disallow rejecting promises. | | | | | | | |
| [no-throw-statements](docs/rules/no-throw-statements.md) | Disallow throwing exceptions. | ☑️ ✅ 🔒 ![badge-no-exceptions][] | | | | | | |
| [no-try-statements](docs/rules/no-try-statements.md) | Disallow try-catch[-finally] and try-finally patterns. | 🔒 ![badge-no-exceptions][] | | ☑️ ✅ | | | | |

### No Mutations

| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 | |
| :--------------------------------------------------------------------------- | :-------------------------------------------------------------- | :---------------------------- | :--- | :--- | :--- | :--- | :--- | :--- |
| [immutable-data](docs/rules/immutable-data.md) | Enforce treating data as immutable. | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | | | 💭 | |
| [no-let](docs/rules/no-let.md) | Disallow mutable variables. | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | | | | |
| [prefer-immutable-types](docs/rules/prefer-immutable-types.md) | Require function parameters to be typed as certain immutability | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | 🔧 | 💡 | 💭 | |
| [prefer-readonly-type](docs/rules/prefer-readonly-type.md) | Prefer readonly types over mutable types. | | | | 🔧 | | 💭 | |
| [type-declaration-immutability](docs/rules/type-declaration-immutability.md) | Enforce the immutability of types based on patterns. | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | 🔧 | | 💭 | |
| Name                          | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
| :--------------------------------------------------------------------------- | :-------------------------------------------------------------- | :------------------------------ | :- | :- | :- | :- | :- | :- |
| [immutable-data](docs/rules/immutable-data.md) | Enforce treating data as immutable. | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | | | 💭 | |
| [no-let](docs/rules/no-let.md) | Disallow mutable variables. | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | | | | |
| [prefer-immutable-types](docs/rules/prefer-immutable-types.md) | Require function parameters to be typed as certain immutability | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | 🔧 | 💡 | 💭 | |
| [prefer-readonly-type](docs/rules/prefer-readonly-type.md) | Prefer readonly types over mutable types. | | | | 🔧 | | 💭 ||
| [type-declaration-immutability](docs/rules/type-declaration-immutability.md) | Enforce the immutability of types based on patterns. | ☑️ ✅ 🔒 ![badge-no-mutations][] | | | 🔧 | | 💭 | |

### No Other Paradigms

| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 | |
| :------------------------------------------------------- | :------------------------------------------------------------------------ | :---------------------------------- | :--- | :--- | :--- | :--- | :--- | :--- |
| [no-classes](docs/rules/no-classes.md) | Disallow classes. | ☑️ ✅ 🔒 ![badge-no-other-paradigms][] | | | | | | |
| [no-mixed-types](docs/rules/no-mixed-types.md) | Restrict types so that only members of the same kind are allowed in them. | ☑️ ✅ 🔒 ![badge-no-other-paradigms][] | | | | | 💭 | |
| [no-this-expressions](docs/rules/no-this-expressions.md) | Disallow this access. | 🔒 ![badge-no-other-paradigms][] | | ☑️ ✅ | | | | |
| Name                | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
| :------------------------------------------------------- | :------------------------------------------------------------------------ | :------------------------------------ | :- | :--- | :- | :- | :- | :- |
| [no-classes](docs/rules/no-classes.md) | Disallow classes. | ☑️ ✅ 🔒 ![badge-no-other-paradigms][] | | | | | | |
| [no-mixed-types](docs/rules/no-mixed-types.md) | Restrict types so that only members of the same kind are allowed in them. | ☑️ ✅ 🔒 ![badge-no-other-paradigms][] | | | | | 💭 | |
| [no-this-expressions](docs/rules/no-this-expressions.md) | Disallow this access. | 🔒 ![badge-no-other-paradigms][] | | ☑️ ✅ | | | | |

### No Statements

| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 | |
| :------------------------------------------------------------------- | :--------------------------------------------- | :----------------------------- | :--- | :--- | :--- | :--- | :--- | :--- |
| [no-conditional-statements](docs/rules/no-conditional-statements.md) | Disallow conditional statements. | ✅ 🔒 ![badge-no-statements][] | | ☑️ | | | 💭 | |
| [no-expression-statements](docs/rules/no-expression-statements.md) | Disallow expression statements. | ✅ 🔒 ![badge-no-statements][] | | ☑️ | | | 💭 | |
| [no-loop-statements](docs/rules/no-loop-statements.md) | Disallow imperative loops. | ☑️ ✅ 🔒 ![badge-no-statements][] | | | | | | |
| [no-return-void](docs/rules/no-return-void.md) | Disallow functions that don't return anything. | ☑️ ✅ 🔒 ![badge-no-statements][] | | | | | 💭 | |
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
| :------------------------------------------------------------------- | :--------------------------------------------- | :------------------------------- | :- | :- | :- | :- | :- | :- |
| [no-conditional-statements](docs/rules/no-conditional-statements.md) | Disallow conditional statements. | ✅ 🔒 ![badge-no-statements][] | | ☑️ | | | 💭 | |
| [no-expression-statements](docs/rules/no-expression-statements.md) | Disallow expression statements. | ✅ 🔒 ![badge-no-statements][] | | ☑️ | | | 💭 | |
| [no-loop-statements](docs/rules/no-loop-statements.md) | Disallow imperative loops. | ☑️ ✅ 🔒 ![badge-no-statements][] | | | | | | |
| [no-return-void](docs/rules/no-return-void.md) | Disallow functions that don't return anything. | ☑️ ✅ 🔒 ![badge-no-statements][] | | | | | 💭 | |

### Stylistic

| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 | |
| :--------------------------------------------------------------------- | :--------------------------------------------------------------------- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| [prefer-property-signatures](docs/rules/prefer-property-signatures.md) | Prefer property signatures over method signatures. | 🎨 | | | | | 💭 | |
| [prefer-tacit](docs/rules/prefer-tacit.md) | Replaces `x => f(x)` with just `f`. | | 🎨 | | | 💡 | 💭 | |
| [readonly-type](docs/rules/readonly-type.md) | Require consistently using either `readonly` keywords or `Readonly<T>` | 🎨 | | | 🔧 | | 💭 | |
| Name                       | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
| :--------------------------------------------------------------------- | :--------------------------------------------------------------------- | :- | :- | :- | :- | :- | :- | :- |
| [prefer-property-signatures](docs/rules/prefer-property-signatures.md) | Prefer property signatures over method signatures. | 🎨 | | | | | 💭 | |
| [prefer-tacit](docs/rules/prefer-tacit.md) | Replaces `x => f(x)` with just `f`. | | 🎨 | | | 💡 | 💭 | |
| [readonly-type](docs/rules/readonly-type.md) | Require consistently using either `readonly` keywords or `Readonly<T>` | 🎨 | | | 🔧 | | 💭 | |

<!-- end auto-generated rules list -->
<!-- markdownlint-restore -->
Expand Down
20 changes: 19 additions & 1 deletion eslint-doc-generator.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@ import { format } from "prettier";

export default {
configEmoji: [["lite", "☑️"]],
ignoreConfig: ["all", "off", "disable-type-checked"],
ignoreConfig: [
"all",
"off",
"disable-type-checked",
"flat/all",
"flat/currying",
"flat/disable-type-checked",
"flat/external-typescript-recommended",
"flat/external-vanilla-recommended",
"flat/lite",
"flat/no-exceptions",
"flat/no-mutations",
"flat/no-other-paradigms",
"flat/no-statements",
"flat/off",
"flat/recommended",
"flat/strict",
"flat/stylistic",
],
ruleDocSectionInclude: ["Rule Details"],
ruleListSplit: "meta.docs.category",
postprocess: (doc) => format(doc, { parser: "markdown" }),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"@typescript-eslint/rule-tester": "7.2.0",
"@vitest/coverage-c8": "0.33.0",
"@vitest/coverage-istanbul": "1.3.1",
"@vitest/coverage-v8": "1.3.1",
"chalk": "4.1.2",
Expand Down
44 changes: 44 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 13 additions & 43 deletions src/configs/all.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
import { type Linter } from "@typescript-eslint/utils/ts-eslint";
import { type FlatConfig } from "@typescript-eslint/utils/ts-eslint";

import * as functionalParameters from "#eslint-plugin-functional/rules/functional-parameters";
import * as immutableData from "#eslint-plugin-functional/rules/immutable-data";
import * as noClasses from "#eslint-plugin-functional/rules/no-classes";
import * as noConditionalStatements from "#eslint-plugin-functional/rules/no-conditional-statements";
import * as noExpressionStatements from "#eslint-plugin-functional/rules/no-expression-statements";
import * as noLet from "#eslint-plugin-functional/rules/no-let";
import * as noLoopStatements from "#eslint-plugin-functional/rules/no-loop-statements";
import * as noMixedTypes from "#eslint-plugin-functional/rules/no-mixed-types";
import * as noPromiseReject from "#eslint-plugin-functional/rules/no-promise-reject";
import * as noReturnVoid from "#eslint-plugin-functional/rules/no-return-void";
import * as noThisExpressions from "#eslint-plugin-functional/rules/no-this-expressions";
import * as noThrowStatements from "#eslint-plugin-functional/rules/no-throw-statements";
import * as noTryStatements from "#eslint-plugin-functional/rules/no-try-statements";
import * as preferImmutableTypes from "#eslint-plugin-functional/rules/prefer-immutable-types";
import * as preferPropertySignatures from "#eslint-plugin-functional/rules/prefer-property-signatures";
import * as preferTacit from "#eslint-plugin-functional/rules/prefer-tacit";
import * as readonlyType from "#eslint-plugin-functional/rules/readonly-type";
import * as typeDeclarationImmutability from "#eslint-plugin-functional/rules/type-declaration-immutability";
import { rules } from "#eslint-plugin-functional/rules";
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc";

const config: Linter.Config = {
rules: {
[`functional/${functionalParameters.name}`]: "error",
[`functional/${immutableData.name}`]: "error",
[`functional/${noClasses.name}`]: "error",
[`functional/${noConditionalStatements.name}`]: "error",
[`functional/${noExpressionStatements.name}`]: "error",
[`functional/${noLet.name}`]: "error",
[`functional/${noLoopStatements.name}`]: "error",
[`functional/${noMixedTypes.name}`]: "error",
[`functional/${noPromiseReject.name}`]: "error",
[`functional/${noReturnVoid.name}`]: "error",
[`functional/${noThisExpressions.name}`]: "error",
[`functional/${noThrowStatements.name}`]: "error",
[`functional/${noTryStatements.name}`]: "error",
[`functional/${preferImmutableTypes.name}`]: "error",
[`functional/${preferPropertySignatures.name}`]: "error",
[`functional/${preferTacit.name}`]: "warn",
[`functional/${readonlyType.name}`]: "error",
[`functional/${typeDeclarationImmutability.name}`]: "error",
},
};

export default config;
export default {
...Object.fromEntries(
Object.entries(rules)
.filter(([, rule]) => rule.meta.deprecated !== true)
.map(([name, rule]) => [
`${ruleNameScope}/${name}`,
rule.meta.docs.recommendedSeverity,
]),
),
} satisfies FlatConfig.Config["rules"];
Loading

0 comments on commit 429db04

Please sign in to comment.