Skip to content

Commit cb7ee0c

Browse files
committed
feature: @putout/plugin-putout: replace-test-message: no-report-after-transform: add
1 parent ae9b186 commit cb7ee0c

File tree

13 files changed

+57
-12
lines changed

13 files changed

+57
-12
lines changed

packages/plugin-conditions/lib/apply-consistent-blocks/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test('putout: apply-consistent-blocks: no report: else-statement', (t) => {
6464
t.end();
6565
});
6666

67-
test('putout: apply-consistent-blocks: no report after transform', (t) => {
67+
test('putout: apply-consistent-blocks: no report after transform: nested', (t) => {
6868
t.noReportAfterTransform('nested');
6969
t.end();
7070
});

packages/plugin-putout/lib/apply-fixture-name-to-message/fixture/no-report-after-transform-fix.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ test('compiler: convert-dec-to-hex: transform: hello', (t) => {
22
t.noReportAfterTransform('hello');
33
t.end();
44
});
5+
6+
test('compiler: convert-dec-to-hex: no report after transform: hello', (t) => {
7+
t.noReportAfterTransform('hello');
8+
t.end();
9+
});

packages/plugin-putout/lib/apply-fixture-name-to-message/fixture/no-report-after-transform.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ test('compiler: convert-dec-to-hex: transform', (t) => {
22
t.noReportAfterTransform('hello');
33
t.end();
44
});
5+
6+
test('compiler: convert-dec-to-hex: no report after transform', (t) => {
7+
t.noReportAfterTransform('hello');
8+
t.end();
9+
});

packages/plugin-putout/lib/apply-fixture-name-to-message/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const NAMES = [
1414
...FIXTURE,
1515
'no report',
1616
'no transform',
17+
'no report after transform',
1718
];
1819

1920
export const report = () => `Apply 'fixture' name to 'message'`;

packages/plugin-putout/lib/check-replace-code/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test('plugin-putout: check-replace-code: report: __json: json-left', (t) => {
147147
t.end();
148148
});
149149

150-
test('plugin-putout: check-replace-code: no report: after-transform: once', (t) => {
150+
test('plugin-putout: check-replace-code: no report after transform: after-transform: once', (t) => {
151151
t.noReportAfterTransform('after-transform');
152152
t.end();
153153
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
test('compiler: convert-dec-to-hex: no report after transform', (t) => {
2+
t.noReportAfterTransform('convert-dec-to-hex');
3+
t.end();
4+
});
5+
6+
test('compiler: convert-dec-to-hex: transform', (t) => {
7+
t.transform('convert-dec-to-hex');
8+
t.end();
9+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
test('compiler: convert-dec-to-hex: transform', (t) => {
2+
t.noReportAfterTransform('convert-dec-to-hex');
3+
t.end();
4+
});
5+
6+
test('compiler: convert-dec-to-hex: no report after transform', (t) => {
7+
t.transform('convert-dec-to-hex');
8+
t.end();
9+
});

packages/plugin-putout/lib/replace-test-message/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ export const fix = ({path, incorrect, correct}) => {
1313
};
1414

1515
const INCORRECT = {
16-
TRANSFORM: /: (no transform|report|no report)/,
17-
NO_TRANSFORM: /: (transform|report|no report)/,
18-
REPORT: /: (no report|transform|no transform)/,
19-
NO_REPORT: /: (report|transform|no transform)/,
16+
TRANSFORM: /: (no report after transform|no transform|report|no report)/,
17+
NO_TRANSFORM: /: (no report after transform|transform|report|no report)/,
18+
REPORT: /: (no report after transform|no report|transform|no transform)/,
19+
NO_REPORT: /: (no report after transform|report|transform|no transform)/,
20+
NO_REPORT_AFTER_TRANSFORM: /: (report|transform|no transform|no report)/,
2021
};
2122

2223
export const traverse = ({push}) => ({
@@ -45,12 +46,18 @@ export const traverse = ({push}) => ({
4546
incorrect: INCORRECT.NO_REPORT,
4647
correct: ': no report',
4748
}),
49+
't.noReportAfterTransform(__a)': convert({
50+
push,
51+
incorrect: INCORRECT.NO_REPORT_AFTER_TRANSFORM,
52+
correct: ': no report after transform',
53+
}),
4854
});
4955

5056
const convert = ({push, correct, incorrect}) => (path) => {
5157
const [is, messagePath] = isCorrect({
5258
incorrect,
5359
path,
60+
correct,
5461
});
5562

5663
if (is)
@@ -66,7 +73,7 @@ const convert = ({push, correct, incorrect}) => (path) => {
6673

6774
const CORRECT = true;
6875

69-
function isCorrect({path, incorrect}) {
76+
function isCorrect({path, correct, incorrect}) {
7077
const calleePath = path.findParent(isCallExpression);
7178

7279
if (!calleePath)
@@ -78,6 +85,10 @@ function isCorrect({path, incorrect}) {
7885
return [CORRECT];
7986

8087
const {value} = messagePath.node;
88+
89+
if (value.includes(correct))
90+
return [CORRECT];
91+
8192
const is = !incorrect.test(value);
8293

8394
return [is, messagePath];

packages/plugin-putout/lib/replace-test-message/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ test('plugin-putout: replace-test-message: transform: transform-with-plugins', (
5151
t.transform('transform-with-plugins');
5252
t.end();
5353
});
54+
55+
test('plugin-putout: replace-test-message: transform: no-report-after-transform', (t) => {
56+
t.transform('no-report-after-transform');
57+
t.end();
58+
});

packages/plugin-regexp/lib/optimize/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ test('plugin-regexp/optimize: transform: replace-all', (t) => {
4040
t.end();
4141
});
4242

43-
test('plugin-regexp/optimize: escape', (t) => {
43+
test('plugin-regexp/optimize: no transform: escape', (t) => {
4444
t.noTransform('escape');
4545
t.end();
4646
});
4747

48-
test('plugin-regexp/optimize: false positive after fix', (t) => {
48+
test('plugin-regexp/optimize: no-report-after-transform: after-fix', (t) => {
4949
t.noReportAfterTransform('after-fix');
5050
t.end();
5151
});

0 commit comments

Comments
 (0)