Skip to content

Commit

Permalink
docs: add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Feb 7, 2020
1 parent 24702cb commit 6eaa9f3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/README.md
Expand Up @@ -141,7 +141,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int
| [`@typescript-eslint/prefer-nullish-coalescing`](./docs/rules/prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-optional-chain`](./docs/rules/prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | | :wrench: | |
| [`@typescript-eslint/prefer-readonly`](./docs/rules/prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-readonly-parameter-types`](./docs/rules/prefer-readonly-parameter-types.md) | TODO | | | :thought_balloon: |
| [`@typescript-eslint/prefer-readonly-parameter-types`](./docs/rules/prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: |
| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | :heavy_check_mark: | :wrench: | :thought_balloon: |
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | | :thought_balloon: |
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/configs/all.json
Expand Up @@ -78,6 +78,7 @@
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/prefer-readonly-parameter-types": "error",
"@typescript-eslint/prefer-regexp-exec": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
Expand Down
Expand Up @@ -9,7 +9,8 @@ export default util.createRule({
meta: {
type: 'suggestion',
docs: {
description: 'TODO',
description:
'Requires that function parameters are typed as readonly to prevent accidental mutation of inputs',
category: 'Possible Errors',
recommended: false,
requiresTypeChecking: true,
Expand Down
Expand Up @@ -26,6 +26,7 @@ const primitives = [
"'a'",
'number',
'1',
'symbol',
'any',
'unknown',
'never',
Expand Down Expand Up @@ -62,11 +63,18 @@ const weirdIntersections = [

ruleTester.run('prefer-readonly-parameter-types', rule, {
valid: [
'function foo(arg: { readonly a: string }) {}',
'function foo() {}',

// primitives
...primitives.map(type => `function foo(arg: ${type}) {}`),
`
const symb = Symbol('a');
function foo(arg: typeof symb) {}
`,
`
enum Enum { a, b }
function foo(arg: Enum) {}
`,

// arrays
...arrays.map(type => `function foo(arg: ${type}) {}`),
Expand Down

0 comments on commit 6eaa9f3

Please sign in to comment.