|
15 | 15 | * along with this program; if not, see https://sonarsource.com/license/ssal/ |
16 | 16 | */ |
17 | 17 | import { test } from '../../../../tests/jsts/tools/testers/comment-based/checker.js'; |
| 18 | +import { DefaultParserRuleTester } from '../../../../tests/jsts/tools/testers/rule-tester.js'; |
18 | 19 | import { rule } from './index.js'; |
19 | | -import { describe } from 'node:test'; |
| 20 | +import { rules as tsEslintRules } from '../external/typescript-eslint/index.js'; |
| 21 | +import { describe, it } from 'node:test'; |
20 | 22 | import * as meta from './generated-meta.js'; |
21 | 23 |
|
| 24 | +const upstreamRule = tsEslintRules['default-param-last']; |
| 25 | + |
| 26 | +// Sentinel: verify that the upstream ESLint rule still raises on the patterns our decorator fixes. |
| 27 | +// If this test starts failing (i.e., the upstream rule no longer reports these patterns), |
| 28 | +// it signals that the decorator can be safely removed. |
| 29 | +describe('S1788 upstream sentinel', () => { |
| 30 | + it('upstream default-param-last raises on destructured action patterns that decorator suppresses', () => { |
| 31 | + const ruleTester = new DefaultParserRuleTester(); |
| 32 | + ruleTester.run('default-param-last', upstreamRule, { |
| 33 | + valid: [], |
| 34 | + invalid: [ |
| 35 | + // (state = x, { type }) — suppressed by decorator, raised by upstream |
| 36 | + { code: `function appReducer(state = initialState, { type }) {}`, errors: 1 }, |
| 37 | + // (state = x, { type, payload }) — suppressed by decorator, raised by upstream |
| 38 | + { code: `const dataReducer = (state = null, { type, payload }) => {};`, errors: 1 }, |
| 39 | + ], |
| 40 | + }); |
| 41 | + }); |
| 42 | +}); |
| 43 | + |
22 | 44 | describe('Rule S1788', () => { |
23 | 45 | test(meta, rule, import.meta.dirname); |
24 | 46 | }); |
0 commit comments