Skip to content

Commit be67064

Browse files
committed
fix: @putout/plugin-madrun: add-function: report
1 parent 6b1b22a commit be67064

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

packages/engine-loader/test/load-plugins.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,27 @@ test('putout: loader: enable part of rule', (t) => {
299299
const {run} = require('madrun');
300300
301301
module.exports = {
302-
'lint': () => 'bin/putout.js .',
303-
'fix:lint': () => run('lint', '--fix'),
302+
'lint': 'putout .',
304303
};
305304
`;
306305

307306
const {places} = putout(code, {
308307
fix: false,
309308
rules: {
310309
'madrun': 'off',
311-
'madrun/add-madrun-to-lint': 'on',
310+
'madrun/add-function': 'on',
312311
},
313312
plugins: ['madrun'],
314313
});
315314

316-
const expected = [];
315+
const expected = [{
316+
message: `Use 'function' instead of 'string' in script: 'lint'`,
317+
position: {
318+
column: 12,
319+
line: 4,
320+
},
321+
rule: 'madrun/add-function',
322+
}];
317323

318324
t.deepEqual(places, expected, 'should disable all but couple of rules in plugin');
319325
t.end();

packages/plugin-madrun/lib/add-function/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
const {types, operator} = require('putout');
44

55
const {replaceWith, extract} = operator;
6-
76
const {
87
isLiteral,
98
isCallExpression,
109
arrowFunctionExpression,
1110
} = types;
1211

13-
module.exports.report = ({name}) => `function should be used instead of string in script "${name}`;
12+
module.exports.report = ({name}) => `Use 'function' instead of 'string' in script: '${name}'`;
1413

1514
module.exports.fix = ({path}) => {
1615
replaceWith(path, arrowFunctionExpression([], path.node));

packages/plugin-madrun/lib/add-function/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const test = createTest(__dirname, {
1010
});
1111

1212
test('madrun: add function: report: string', (t) => {
13-
t.report('string', 'function should be used instead of string in script "hello');
13+
t.report('string', `Use 'function' instead of 'string' in script: 'hello'`);
1414
t.end();
1515
});
1616

@@ -40,6 +40,6 @@ test('madrun: add function: transform: export-default', (t) => {
4040
});
4141

4242
test('madrun: add function: report: identifier', (t) => {
43-
t.report('identifier', 'function should be used instead of string in script "build');
43+
t.report('identifier', `Use 'function' instead of 'string' in script: 'build'`);
4444
t.end();
4545
});

0 commit comments

Comments
 (0)