Skip to content

Commit ae868a6

Browse files
committed
feat: add rule 'prefer-readonly-props', closes #590
1 parent 068989b commit ae868a6

File tree

30 files changed

+582
-312
lines changed

30 files changed

+582
-312
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v1.5.22 (Draft)
2+
3+
### ✨ New
4+
5+
- Add rule `prefer-read-only-props`.
6+
7+
### 🪄 Improvements
8+
9+
- Downgrade `@typescript-eslint`'s packages to v7, due to stability issues with v8.
10+
111
## v1.5.21 (Wed 3 Jul 2024)
212

313
### 🐞 Fixes

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@
6161
"@tsconfig/node20": "20.1.4",
6262
"@tsconfig/strictest": "2.0.5",
6363
"@types/node": "20.14.9",
64-
"@typescript-eslint/eslint-plugin": "8.0.0-alpha.40",
65-
"@typescript-eslint/parser": "8.0.0-alpha.40",
66-
"@typescript-eslint/rule-tester": "8.0.0-alpha.40",
64+
"@types/react": "18.3.3",
65+
"@types/react-dom": "18.3.0",
66+
"@typescript-eslint/eslint-plugin": "7.15.0",
67+
"@typescript-eslint/parser": "7.15.0",
68+
"@typescript-eslint/rule-tester": "7.15.0",
6769
"@vitest/ui": "1.6.0",
6870
"bun": "1.1.18",
6971
"bun-types": "1.1.18",
@@ -90,6 +92,8 @@
9092
"markdownlint": "0.34.0",
9193
"pathe": "1.1.2",
9294
"publint": "0.2.8",
95+
"react": "^18.3.1",
96+
"react-dom": "^18.3.1",
9397
"skott": "0.35.2",
9498
"sort-package-json": "2.10.0",
9599
"tiny-invariant": "1.3.3",
@@ -132,6 +136,7 @@
132136
"object.hasown": "npm:@nolyfill/object.hasown@^1",
133137
"object.values": "npm:@nolyfill/object.values@^1",
134138
"string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@^1",
139+
"ts-api-utils": "^1.3.0",
135140
"typedarray": "npm:@nolyfill/typedarray@^1",
136141
"typedoc": "0.26.3",
137142
"typedoc-plugin-markdown": "4.1.1",

packages/core/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"@eslint-react/tools": "workspace:*",
4949
"@eslint-react/types": "workspace:*",
5050
"@eslint-react/var": "workspace:*",
51-
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
52-
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
53-
"@typescript-eslint/types": "8.0.0-alpha.40",
54-
"@typescript-eslint/utils": "8.0.0-alpha.40"
51+
"@typescript-eslint/scope-manager": "7.15.0",
52+
"@typescript-eslint/type-utils": "7.15.0",
53+
"@typescript-eslint/types": "7.15.0",
54+
"@typescript-eslint/utils": "7.15.0"
5555
},
5656
"devDependencies": {
5757
"effect": "3.4.7",

packages/plugins/eslint-plugin-react-debug/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export default [
4040

4141
## Rules
4242

43-
| Rule | Description | 💼 | 💭 ||
44-
| :----------------------------------------------------- | :----------------------------- | :-: | :-: | :-: |
45-
| [`debug/class-component`](debug-class-component) | Print all class components. | 🐞 | | |
46-
| [`debug/function-component`](debug-function-component) | Print all function components. | 🐞 | | |
47-
| [`debug/react-hooks`](debug-react-hooks) | Print all react hooks. | 🐞 | | |
43+
| Rule | Description | 💼 | 💭 ||
44+
| :----------------- | :----------------------------- | :-: | :-: | :-: |
45+
| class-component | Print all class components. | 🐞 | | |
46+
| function-component | Print all function components. | 🐞 | | |
47+
| react-hooks | Print all react hooks. | 🐞 | | |

packages/plugins/eslint-plugin-react-debug/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
"@eslint-react/shared": "workspace:*",
4848
"@eslint-react/tools": "workspace:*",
4949
"@eslint-react/types": "workspace:*",
50-
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
51-
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
52-
"@typescript-eslint/types": "8.0.0-alpha.40",
53-
"@typescript-eslint/utils": "8.0.0-alpha.40",
50+
"@typescript-eslint/scope-manager": "7.15.0",
51+
"@typescript-eslint/type-utils": "7.15.0",
52+
"@typescript-eslint/types": "7.15.0",
53+
"@typescript-eslint/utils": "7.15.0",
5454
"string-ts": "^2.2.0"
5555
},
5656
"devDependencies": {

packages/plugins/eslint-plugin-react-dom/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ export default [
4949

5050
## Rules
5151

52-
| Rule | Description | 💼 | 💭 ||
53-
| :------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- | :-: | :-: | :-: |
54-
| [`dom/no-children-in-void-dom-elements`](dom-no-children-in-void-dom-elements) | Prevents the use of `children` in void `DOM elements`. | ✔️ | | |
55-
| [`dom/no-dangerously-set-innerhtml`](dom-no-dangerously-set-innerhtml) | Prevents `DOM element` using `dangerouslySetInnerHTML`. | 🔒 | | |
56-
| [`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. | ✔️ | | |
57-
| [`dom/no-find-dom-node`](dom-no-find-dom-node) | Prevents usage of `findDOMNode`. || | |
58-
| [`dom/no-missing-button-type`](dom-no-missing-button-type) | Enforces explicit `button` type `attribute` for `<button>` elements. | ✔️ | | |
59-
| [`dom/no-missing-iframe-sandbox`](dom-no-missing-iframe-sandbox) | Enforces explicit `sandbox` attribute for `iframe` elements. | 🔒 | | |
60-
| [`dom/no-namespace`](dom-no-namespace) | Enforces the absence of a `namespace` in React elements. | ✔️ | | |
61-
| [`dom/no-render-return-value`](no-render-return-value) | Prevents usage of the return value of `ReactDOM.render`. || | |
62-
| [`dom/no-script-url`](dom-no-script-url) | Prevents usage of `javascript:` URLs as the value of certain attributes. | 🔒 | | |
63-
| [`dom/no-unsafe-iframe-sandbox`](dom-no-unsafe-iframe-sandbox) | Enforces `sandbox` attribute for `iframe` elements is not set to unsafe combinations. | 🔒 | | |
64-
| [`dom/no-unsafe-target-blank`](dom-no-unsafe-target-blank) | Prevents the use of `target="_blank"` without `rel="noreferrer noopener"`. | 🔒 | | |
52+
| Rule | Description | 💼 | 💭 ||
53+
| :----------------------------------------- | :-------------------------------------------------------------------------------------- | :-: | :-: | :-: |
54+
| no-children-in-void-dom-elements | Prevents the use of `children` in void `DOM elements`. | ✔️ | | |
55+
| no-dangerously-set-innerhtml | Prevents `DOM element` using `dangerouslySetInnerHTML`. | 🔒 | | |
56+
| no-dangerously-set-innerhtml-with-children | Prevents `DOM element` using `dangerouslySetInnerHTML` and `children` at the same time. | ✔️ | | |
57+
| no-find-dom-node | Prevents usage of `findDOMNode`. || | |
58+
| no-missing-button-type | Enforces explicit `button` type `attribute` for `<button>` elements. | ✔️ | | |
59+
| no-missing-iframe-sandbox | Enforces explicit `sandbox` attribute for `iframe` elements. | 🔒 | | |
60+
| no-namespace | Enforces the absence of a `namespace` in React elements. | ✔️ | | |
61+
| no-render-return-value | Prevents usage of the return value of `ReactDOM.render`. || | |
62+
| no-script-url | Prevents usage of `javascript:` URLs as the value of certain attributes. | 🔒 | | |
63+
| no-unsafe-iframe-sandbox | Enforces `sandbox` attribute for `iframe` elements is not set to unsafe combinations. | 🔒 | | |
64+
| no-unsafe-target-blank | Prevents the use of `target="_blank"` without `rel="noreferrer noopener"`. | 🔒 | | |

packages/plugins/eslint-plugin-react-dom/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
"@eslint-react/tools": "workspace:*",
4949
"@eslint-react/types": "workspace:*",
5050
"@eslint-react/var": "workspace:*",
51-
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
52-
"@typescript-eslint/types": "8.0.0-alpha.40",
53-
"@typescript-eslint/utils": "8.0.0-alpha.40"
51+
"@typescript-eslint/scope-manager": "7.15.0",
52+
"@typescript-eslint/types": "7.15.0",
53+
"@typescript-eslint/utils": "7.15.0"
5454
},
5555
"devDependencies": {
5656
"dedent": "1.5.3",

packages/plugins/eslint-plugin-react-hooks-extra/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export default [
4040

4141
## Rules
4242

43-
| Rule | Description | 💼 | 💭 ||
44-
| :--------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- | :-: | :-: | :-: |
45-
| [`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. | ✔️ | | |
46-
| [`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. | 🧐 | | |
47-
| [`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. | 🧐 | | |
48-
| [`hooks-extra/prefer-use-state-lazy-initialization`](hooks-extra-prefer-use-state-lazy-initialization) | Warns function calls made inside `useState` calls. | 🚀 | | |
43+
| Rule | Description | 💼 | 💭 ||
44+
| :------------------------------------- | :---------------------------------------------------------------- | :-: | :-: | :-: |
45+
| ensure-custom-hooks-using-other-hooks | Warns when custom Hooks that don't use other Hooks. | ✔️ | | |
46+
| ensure-use-callback-has-non-empty-deps | Warns when `useCallback` is called with empty dependencies array. | 🧐 | | |
47+
| ensure-use-memo-has-non-empty-deps | Warns when `useMemo` is called with empty dependencies array. | 🧐 | | |
48+
| prefer-use-state-lazy-initialization | Warns function calls made inside `useState` calls. | 🚀 | | |

packages/plugins/eslint-plugin-react-hooks-extra/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"@eslint-react/tools": "workspace:*",
4949
"@eslint-react/types": "workspace:*",
5050
"@eslint-react/var": "workspace:*",
51-
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
52-
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
53-
"@typescript-eslint/types": "8.0.0-alpha.40",
54-
"@typescript-eslint/utils": "8.0.0-alpha.40"
51+
"@typescript-eslint/scope-manager": "7.15.0",
52+
"@typescript-eslint/type-utils": "7.15.0",
53+
"@typescript-eslint/types": "7.15.0",
54+
"@typescript-eslint/utils": "7.15.0"
5555
},
5656
"devDependencies": {
5757
"dedent": "1.5.3",

packages/plugins/eslint-plugin-react-naming-convention/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export default [
4040

4141
## Rules
4242

43-
| Rule | Description | 💼 | 💭 ||
44-
| :----------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :-: | :-: | :-: |
45-
| [`naming-convention/component-name`](naming-convention-component-name) | Enforces naming conventions for components. | 📖 | | |
46-
| [`naming-convention/filename`](naming-convention-filename) | Enforces naming convention for JSX files. | 📖 | | |
47-
| [`naming-convention/filename-extension`](naming-convention-filename-extension) | Enforces consistent use of the JSX file extension. | 📖 | | |
48-
| [`naming-convention/use-state`](naming-convention-use-state) | Enforces destructuring and symmetric naming of `useState` hook value and setter variables. | 📖 | | |
43+
| Rule | Description | 💼 | 💭 ||
44+
| :----------------- | :----------------------------------------------------------------------------------------- | :-: | :-: | :-: |
45+
| component-name | Enforces naming conventions for components. | 📖 | | |
46+
| filename | Enforces naming convention for JSX files. | 📖 | | |
47+
| filename-extension | Enforces consistent use of the JSX file extension. | 📖 | | |
48+
| use-state | Enforces destructuring and symmetric naming of `useState` hook value and setter variables. | 📖 | | |

packages/plugins/eslint-plugin-react-naming-convention/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
"@eslint-react/shared": "workspace:*",
4848
"@eslint-react/tools": "workspace:*",
4949
"@eslint-react/types": "workspace:*",
50-
"@typescript-eslint/scope-manager": "8.0.0-alpha.40",
51-
"@typescript-eslint/type-utils": "8.0.0-alpha.40",
52-
"@typescript-eslint/types": "8.0.0-alpha.40",
53-
"@typescript-eslint/utils": "8.0.0-alpha.40"
50+
"@typescript-eslint/scope-manager": "7.15.0",
51+
"@typescript-eslint/type-utils": "7.15.0",
52+
"@typescript-eslint/types": "7.15.0",
53+
"@typescript-eslint/utils": "7.15.0"
5454
},
5555
"devDependencies": {
5656
"dedent": "1.5.3",

0 commit comments

Comments
 (0)