Skip to content

feat: add rule 'prefer-readonly-props', closes #590 #614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v1.5.22 (Draft)

### ✨ New

- Add rule `prefer-read-only-props`.

### 🪄 Improvements

- Downgrade `@typescript-eslint`'s packages to v7, due to stability issues with v8.

## v1.5.21 (Wed 3 Jul 2024)

### 🐞 Fixes
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@
"@tsconfig/node20": "20.1.4",
"@tsconfig/strictest": "2.0.5",
"@types/node": "20.14.9",
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.40",
"@typescript-eslint/parser": "8.0.0-alpha.40",
"@typescript-eslint/rule-tester": "8.0.0-alpha.40",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "7.15.0",
"@typescript-eslint/parser": "7.15.0",
"@typescript-eslint/rule-tester": "7.15.0",
"@vitest/ui": "1.6.0",
"bun": "1.1.18",
"bun-types": "1.1.18",
Expand All @@ -90,6 +92,8 @@
"markdownlint": "0.34.0",
"pathe": "1.1.2",
"publint": "0.2.8",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"skott": "0.35.2",
"sort-package-json": "2.10.0",
"tiny-invariant": "1.3.3",
Expand Down Expand Up @@ -132,6 +136,7 @@
"object.hasown": "npm:@nolyfill/object.hasown@^1",
"object.values": "npm:@nolyfill/object.values@^1",
"string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@^1",
"ts-api-utils": "^1.3.0",
"typedarray": "npm:@nolyfill/typedarray@^1",
"typedoc": "0.26.3",
"typedoc-plugin-markdown": "4.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"@eslint-react/tools": "workspace:*",
"@eslint-react/types": "workspace:*",
"@eslint-react/var": "workspace:*",
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
"@typescript-eslint/types": "8.0.0-alpha.40",
"@typescript-eslint/utils": "8.0.0-alpha.40"
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/type-utils": "7.15.0",
"@typescript-eslint/types": "7.15.0",
"@typescript-eslint/utils": "7.15.0"
},
"devDependencies": {
"effect": "3.4.7",
Expand Down
10 changes: 5 additions & 5 deletions packages/plugins/eslint-plugin-react-debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default [

## Rules

| Rule | Description | 💼 | 💭 | ❌ |
| :----------------------------------------------------- | :----------------------------- | :-: | :-: | :-: |
| [`debug/class-component`](debug-class-component) | Print all class components. | 🐞 | | |
| [`debug/function-component`](debug-function-component) | Print all function components. | 🐞 | | |
| [`debug/react-hooks`](debug-react-hooks) | Print all react hooks. | 🐞 | | |
| Rule | Description | 💼 | 💭 | ❌ |
| :----------------- | :----------------------------- | :-: | :-: | :-: |
| class-component | Print all class components. | 🐞 | | |
| function-component | Print all function components. | 🐞 | | |
| react-hooks | Print all react hooks. | 🐞 | | |
8 changes: 4 additions & 4 deletions packages/plugins/eslint-plugin-react-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"@eslint-react/shared": "workspace:*",
"@eslint-react/tools": "workspace:*",
"@eslint-react/types": "workspace:*",
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
"@typescript-eslint/types": "8.0.0-alpha.40",
"@typescript-eslint/utils": "8.0.0-alpha.40",
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/type-utils": "7.15.0",
"@typescript-eslint/types": "7.15.0",
"@typescript-eslint/utils": "7.15.0",
"string-ts": "^2.2.0"
},
"devDependencies": {
Expand Down
26 changes: 13 additions & 13 deletions packages/plugins/eslint-plugin-react-dom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ export default [

## Rules

| Rule | Description | 💼 | 💭 | ❌ |
| :------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- | :-: | :-: | :-: |
| [`dom/no-children-in-void-dom-elements`](dom-no-children-in-void-dom-elements) | Prevents the use of `children` in void `DOM elements`. | ✔️ | | |
| [`dom/no-dangerously-set-innerhtml`](dom-no-dangerously-set-innerhtml) | Prevents `DOM element` using `dangerouslySetInnerHTML`. | 🔒 | | |
| [`dom/no-dangerously-set-innerhtml-with-children`](dom-no-dangerously-set-innerhtml-with-children) | Prevents `DOM element` using `dangerouslySetInnerHTML` and `children` at the same time. | ✔️ | | |
| [`dom/no-find-dom-node`](dom-no-find-dom-node) | Prevents usage of `findDOMNode`. | ⛔ | | |
| [`dom/no-missing-button-type`](dom-no-missing-button-type) | Enforces explicit `button` type `attribute` for `<button>` elements. | ✔️ | | |
| [`dom/no-missing-iframe-sandbox`](dom-no-missing-iframe-sandbox) | Enforces explicit `sandbox` attribute for `iframe` elements. | 🔒 | | |
| [`dom/no-namespace`](dom-no-namespace) | Enforces the absence of a `namespace` in React elements. | ✔️ | | |
| [`dom/no-render-return-value`](no-render-return-value) | Prevents usage of the return value of `ReactDOM.render`. | ⛔ | | |
| [`dom/no-script-url`](dom-no-script-url) | Prevents usage of `javascript:` URLs as the value of certain attributes. | 🔒 | | |
| [`dom/no-unsafe-iframe-sandbox`](dom-no-unsafe-iframe-sandbox) | Enforces `sandbox` attribute for `iframe` elements is not set to unsafe combinations. | 🔒 | | |
| [`dom/no-unsafe-target-blank`](dom-no-unsafe-target-blank) | Prevents the use of `target="_blank"` without `rel="noreferrer noopener"`. | 🔒 | | |
| Rule | Description | 💼 | 💭 | ❌ |
| :----------------------------------------- | :-------------------------------------------------------------------------------------- | :-: | :-: | :-: |
| no-children-in-void-dom-elements | Prevents the use of `children` in void `DOM elements`. | ✔️ | | |
| no-dangerously-set-innerhtml | Prevents `DOM element` using `dangerouslySetInnerHTML`. | 🔒 | | |
| no-dangerously-set-innerhtml-with-children | Prevents `DOM element` using `dangerouslySetInnerHTML` and `children` at the same time. | ✔️ | | |
| no-find-dom-node | Prevents usage of `findDOMNode`. | ⛔ | | |
| no-missing-button-type | Enforces explicit `button` type `attribute` for `<button>` elements. | ✔️ | | |
| no-missing-iframe-sandbox | Enforces explicit `sandbox` attribute for `iframe` elements. | 🔒 | | |
| no-namespace | Enforces the absence of a `namespace` in React elements. | ✔️ | | |
| no-render-return-value | Prevents usage of the return value of `ReactDOM.render`. | ⛔ | | |
| no-script-url | Prevents usage of `javascript:` URLs as the value of certain attributes. | 🔒 | | |
| no-unsafe-iframe-sandbox | Enforces `sandbox` attribute for `iframe` elements is not set to unsafe combinations. | 🔒 | | |
| no-unsafe-target-blank | Prevents the use of `target="_blank"` without `rel="noreferrer noopener"`. | 🔒 | | |
6 changes: 3 additions & 3 deletions packages/plugins/eslint-plugin-react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"@eslint-react/tools": "workspace:*",
"@eslint-react/types": "workspace:*",
"@eslint-react/var": "workspace:*",
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
"@typescript-eslint/types": "8.0.0-alpha.40",
"@typescript-eslint/utils": "8.0.0-alpha.40"
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/types": "7.15.0",
"@typescript-eslint/utils": "7.15.0"
},
"devDependencies": {
"dedent": "1.5.3",
Expand Down
12 changes: 6 additions & 6 deletions packages/plugins/eslint-plugin-react-hooks-extra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export default [

## Rules

| Rule | Description | 💼 | 💭 | ❌ |
| :--------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- | :-: | :-: | :-: |
| [`hooks-extra/ensure-custom-hooks-using-other-hooks`](hooks-extra-ensure-custom-hooks-using-other-hooks) | Warns when custom Hooks that don't use other Hooks. | ✔️ | | |
| [`hooks-extra/ensure-use-callback-has-non-empty-deps`](hooks-extra-ensure-use-callback-has-non-empty-deps) | Warns when `useCallback` is called with empty dependencies array. | 🧐 | | |
| [`hooks-extra/ensure-use-memo-has-non-empty-deps`](hooks-extra-ensure-use-memo-has-non-empty-deps) | Warns when `useMemo` is called with empty dependencies array. | 🧐 | | |
| [`hooks-extra/prefer-use-state-lazy-initialization`](hooks-extra-prefer-use-state-lazy-initialization) | Warns function calls made inside `useState` calls. | 🚀 | | |
| Rule | Description | 💼 | 💭 | ❌ |
| :------------------------------------- | :---------------------------------------------------------------- | :-: | :-: | :-: |
| ensure-custom-hooks-using-other-hooks | Warns when custom Hooks that don't use other Hooks. | ✔️ | | |
| ensure-use-callback-has-non-empty-deps | Warns when `useCallback` is called with empty dependencies array. | 🧐 | | |
| ensure-use-memo-has-non-empty-deps | Warns when `useMemo` is called with empty dependencies array. | 🧐 | | |
| prefer-use-state-lazy-initialization | Warns function calls made inside `useState` calls. | 🚀 | | |
8 changes: 4 additions & 4 deletions packages/plugins/eslint-plugin-react-hooks-extra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"@eslint-react/tools": "workspace:*",
"@eslint-react/types": "workspace:*",
"@eslint-react/var": "workspace:*",
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
"@typescript-eslint/types": "8.0.0-alpha.40",
"@typescript-eslint/utils": "8.0.0-alpha.40"
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/type-utils": "7.15.0",
"@typescript-eslint/types": "7.15.0",
"@typescript-eslint/utils": "7.15.0"
},
"devDependencies": {
"dedent": "1.5.3",
Expand Down
12 changes: 6 additions & 6 deletions packages/plugins/eslint-plugin-react-naming-convention/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export default [

## Rules

| Rule | Description | 💼 | 💭 | ❌ |
| :----------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :-: | :-: | :-: |
| [`naming-convention/component-name`](naming-convention-component-name) | Enforces naming conventions for components. | 📖 | | |
| [`naming-convention/filename`](naming-convention-filename) | Enforces naming convention for JSX files. | 📖 | | |
| [`naming-convention/filename-extension`](naming-convention-filename-extension) | Enforces consistent use of the JSX file extension. | 📖 | | |
| [`naming-convention/use-state`](naming-convention-use-state) | Enforces destructuring and symmetric naming of `useState` hook value and setter variables. | 📖 | | |
| Rule | Description | 💼 | 💭 | ❌ |
| :----------------- | :----------------------------------------------------------------------------------------- | :-: | :-: | :-: |
| component-name | Enforces naming conventions for components. | 📖 | | |
| filename | Enforces naming convention for JSX files. | 📖 | | |
| filename-extension | Enforces consistent use of the JSX file extension. | 📖 | | |
| use-state | Enforces destructuring and symmetric naming of `useState` hook value and setter variables. | 📖 | | |
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"@eslint-react/shared": "workspace:*",
"@eslint-react/tools": "workspace:*",
"@eslint-react/types": "workspace:*",
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
"@typescript-eslint/types": "8.0.0-alpha.40",
"@typescript-eslint/utils": "8.0.0-alpha.40"
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/type-utils": "7.15.0",
"@typescript-eslint/types": "7.15.0",
"@typescript-eslint/utils": "7.15.0"
},
"devDependencies": {
"dedent": "1.5.3",
Expand Down
Loading
Loading