Skip to content

Commit 18edb24

Browse files
committed
feat: react/no-unstable-default-props support checking for ObjectPatterns within VariableDeclarators that occur on props
1 parent 6951ed3 commit 18edb24

File tree

17 files changed

+96
-24
lines changed

17 files changed

+96
-24
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v0.10.4-beta.0 (Sat Jan 6 2024)
2+
3+
### 🪄 Improvements
4+
5+
- Improve rule `react/no-unstable-default-props` to support checking for ObjectPatterns within VariableDeclarators that occur on props.
6+
17
## v0.10.3 (Fri Jan 5 2024)
28

39
### 🪄 Improvements

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.3
1+
0.10.4-beta.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/monorepo",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's monorepo. A full TypeScript rewrite of eslint-plugin-react, with well-designed rule behaviors and sensible defaults for modern React apps.",
55
"keywords": [
66
"eslint",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/core",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's ESLint utility module for static analysis of React core API and Patterns.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/eslint-plugin-debug",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's ESLint plugin for debugging related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-jsx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/eslint-plugin-jsx",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's ESLint plugin for JSX related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/eslint-plugin-naming-convention",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's ESLint plugin for naming convention related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/eslint-plugin-react-hooks",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/eslint-plugin-react",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.0",
44
"description": "ESLint React's ESLint plugin for React related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react/src/rules/no-unstable-default-props.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,49 @@ ruleTester.run(RULE_NAME, rule, {
131131
dedent`export default function NonComponent({ foo = {} }) {}`,
132132
],
133133
invalid: [
134+
{
135+
code: dedent`
136+
function App({ foo = [], ...rest }) {
137+
return null
138+
}
139+
`,
140+
errors: [{
141+
messageId: MESSAGE_ID,
142+
data: {
143+
propName: "foo",
144+
forbiddenType: "array expression",
145+
},
146+
}],
147+
},
148+
{
149+
code: dedent`
150+
function App({ foo = {}, ...rest }) {
151+
return null
152+
}
153+
`,
154+
errors: [{
155+
messageId: MESSAGE_ID,
156+
data: {
157+
propName: "foo",
158+
forbiddenType: "object expression",
159+
},
160+
}],
161+
},
162+
{
163+
code: dedent`
164+
function App(props) {
165+
const { foo = [] } = props
166+
return null
167+
}
168+
`,
169+
errors: [{
170+
messageId: MESSAGE_ID,
171+
data: {
172+
propName: "foo",
173+
forbiddenType: "array expression",
174+
},
175+
}],
176+
},
134177
{
135178
code: dedent`
136179
function App({

0 commit comments

Comments
 (0)