Skip to content

Commit

Permalink
fix for early node version
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwullems committed Oct 12, 2019
1 parent 7ed942b commit 50ed041
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/rules/function-component-definition.js
Expand Up @@ -118,16 +118,16 @@ module.exports = {
const namedConfig = configuration.namedComponents || 'function-declaration';
const unnamedConfig = configuration.unnamedComponents || 'function-expression';

function getFixer(node, {type, template, range}) {
function getFixer(node, options) {
const sourceCode = context.getSourceCode();
const source = sourceCode.getText();

const typeAnnotation = getTypeAnnotation(node, source);

if (type === 'function-declaration' && typeAnnotation) return;
if (type === 'arrow-function' && hasOneUnconstrainedTypeParam(node)) return;
if (options.type === 'function-declaration' && typeAnnotation) return;
if (options.type === 'arrow-function' && hasOneUnconstrainedTypeParam(node)) return;

return fixer => fixer.replaceTextRange(range, buildFunction(template, {
return fixer => fixer.replaceTextRange(options.range, buildFunction(options.template, {
typeAnnotation,
typeParams: getNodeText(node.typeParameters, source),
params: getParams(node, source),
Expand All @@ -137,11 +137,11 @@ module.exports = {
}));
}

function report(node, {message, fixerOptions}) {
function report(node, options) {
context.report({
node,
message,
fix: getFixer(node, fixerOptions)
message: options.message,
fix: getFixer(node, options.fixerOptions)
});
}

Expand Down

0 comments on commit 50ed041

Please sign in to comment.