Skip to content

Commit 0fd4a6c

Browse files
committed
refactor: disable autofix implementation
1 parent 53a950c commit 0fd4a6c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

lib/rules/prefer-expect-query-by.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,19 @@ module.exports = {
8282
create: context => ({
8383
CallExpression(node) {
8484
if (hasExpectWithWrongGetByQuery(node)) {
85-
const nodesGetBy = mapNodesForWrongGetByQuery(node);
85+
// const nodesGetBy = mapNodesForWrongGetByQuery(node);
8686
context.report({
8787
node: node.callee,
8888
messageId: 'expectQueryBy',
89-
fix(fixer) {
90-
return fixer.replaceText(
91-
nodesGetBy[0],
92-
nodesGetBy[0].name.replace(/^(get(All)?(.*))$/, 'query$2$3')
93-
);
94-
},
89+
// TODO: we keep the autofixing disabled for now, until we figure out
90+
// a better way to amend for the edge cases.
91+
// See also the related discussion: https://github.com/Belco90/eslint-plugin-testing-library/pull/22#discussion_r335394402
92+
// fix(fixer) {
93+
// return fixer.replaceText(
94+
// nodesGetBy[0],
95+
// nodesGetBy[0].name.replace(/^(get(All)?(.*))$/, 'query$2$3')
96+
// );
97+
// },
9598
});
9699
}
97100
},

tests/lib/rules/prefer-expect-query-by.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,26 @@ ruleTester.run('prefer-expect-query-by', rule, {
3333
],
3434
[]
3535
),
36-
invalid: getByVariants.reduce((invalidRules, queryName) => {
37-
const fixedQueryName = queryName.replace('get', 'query');
38-
return [
36+
invalid: getByVariants.reduce(
37+
(invalidRules, queryName) => [
3938
...invalidRules,
4039
{
4140
code: `expect(${queryName}('Hello')).toBeInTheDocument()`,
4241
errors: [{ messageId: 'expectQueryBy' }],
43-
output: `expect(${fixedQueryName}('Hello')).toBeInTheDocument()`,
4442
},
4543
{
4644
code: `expect(rendered.${queryName}('Hello')).toBeInTheDocument()`,
4745
errors: [{ messageId: 'expectQueryBy' }],
48-
output: `expect(rendered.${fixedQueryName}('Hello')).toBeInTheDocument()`,
4946
},
5047
{
5148
code: `expect(${queryName}('Hello')).not.toBeInTheDocument()`,
5249
errors: [{ messageId: 'expectQueryBy' }],
53-
output: `expect(${fixedQueryName}('Hello')).not.toBeInTheDocument()`,
5450
},
5551
{
5652
code: `expect(rendered.${queryName}('Hello')).not.toBeInTheDocument()`,
5753
errors: [{ messageId: 'expectQueryBy' }],
58-
output: `expect(rendered.${fixedQueryName}('Hello')).not.toBeInTheDocument()`,
5954
},
60-
];
61-
}, []),
55+
],
56+
[]
57+
),
6258
});

0 commit comments

Comments
 (0)