eslint-plugin-smarthr 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.3.1](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v3.3.0...eslint-plugin-smarthr-v3.3.1) (2025-12-19)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * smarthr/best-practice-for-rest-parametersの誤検知を修正 ([#959](https://github.com/kufu/tamatebako/issues/959)) ([12d2018](https://github.com/kufu/tamatebako/commit/12d20189c5f697b74751169925a063b8c67b4edb))
11
+
5
12
  ## [3.3.0](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v3.2.0...eslint-plugin-smarthr-v3.3.0) (2025-12-18)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-smarthr",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "author": "SmartHR",
5
5
  "license": "MIT",
6
6
  "description": "A sharable ESLint plugin for SmartHR",
@@ -37,5 +37,5 @@
37
37
  "eslintplugin",
38
38
  "smarthr"
39
39
  ],
40
- "gitHead": "61261c2334b39d607b47e1f5be64fdb74f4ac83f"
40
+ "gitHead": "7390a378bca7e0f44fa90cb2a983cc807dc6c403"
41
41
  }
@@ -9,6 +9,15 @@ module.exports = {
9
9
  schema: SCHEMA,
10
10
  },
11
11
  create(context) {
12
+ const restAction = (node) => {
13
+ context.report({
14
+ node,
15
+ message: `残余引数以外に 'rest' という名称を利用しないでください
16
+ - 詳細: https://github.com/kufu/tamatebako/tree/master/packages/eslint-plugin-smarthr/rules/best-practice-for-rest-parameters
17
+ - 残余引数(rest parameters)と混同する可能性があるため別の名称に修正してください`,
18
+ });
19
+ }
20
+
12
21
  return {
13
22
  [`RestElement[argument.name='props']`]: (node) => {
14
23
  context.report({
@@ -18,14 +27,8 @@ module.exports = {
18
27
  - 'rest' という名称を推奨します`,
19
28
  });
20
29
  },
21
- [`:not(RestElement)>Identifier[name='rest']`]: (node) => {
22
- context.report({
23
- node,
24
- message: `残余引数以外に 'rest' という名称を利用しないでください
25
- - 詳細: https://github.com/kufu/tamatebako/tree/master/packages/eslint-plugin-smarthr/rules/best-practice-for-rest-parameters
26
- - 残余引数(rest parameters)と混同する可能性があるため別の名称に修正してください`,
27
- });
28
- },
30
+ [`:not(:matches(RestElement,JSXSpreadAttribute,ObjectPattern>Property,ObjectExpression>Property))>Identifier[name='rest']`]: restAction,
31
+ [`:matches(ObjectPattern>Property[value.name='rest'],ObjectExpression>Property[key.name='rest'])`]: restAction,
29
32
  }
30
33
  },
31
34
  }
@@ -27,13 +27,18 @@ ruleTester.run('best-practice-for-rest-parameters', rule, {
27
27
  { code: `const hoge = (props) => {}` },
28
28
  { code: `const props = {}` },
29
29
  { code: `const hogeRest = {}` },
30
+ { code: `const hoge = { fuga: rest }` },
31
+ { code: `<Any {...rest} />` },
30
32
  ],
31
33
  invalid: [
32
34
  { code: `const hoge = (a, b, ...props) => {}`, errors: [ { message: ERROR_PROPS } ] },
33
35
  { code: `const hoge = ({ a, b, ...props }) => {}`, errors: [ { message: ERROR_PROPS } ] },
34
36
  { code: `const hoge = (rest) => {}`, errors: [ { message: ERROR_REST } ] },
35
37
  { code: `const hoge = (a, b, rest) => {}`, errors: [ { message: ERROR_REST } ] },
38
+ { code: `const hoge = ({ a: rest, b }) => {}`, errors: [ { message: ERROR_REST } ] },
36
39
  { code: `const rest = {}`, errors: [ { message: ERROR_REST } ] },
40
+ { code: `const hoge = { rest }`, errors: [ { message: ERROR_REST } ] },
41
+ { code: `const hoge = { rest: fuga }`, errors: [ { message: ERROR_REST } ] },
37
42
  ]
38
43
  })
39
44