From 9a1ef2ba402cdac9ac904ebba286b452ca492e05 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 3 Dec 2019 16:23:42 +0100 Subject: [PATCH] Add rule fixer --- lint/rules/named-styles.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lint/rules/named-styles.js b/lint/rules/named-styles.js index eeed03bd0..8da64cfff 100644 --- a/lint/rules/named-styles.js +++ b/lint/rules/named-styles.js @@ -6,6 +6,15 @@ module.exports = { codePath.arguments.length < 2 ) { context.report({ + fix: fixer => + fixer.insertTextAfter( + codePath.arguments[0], + `,{ name: "${context + .getFilename() + .split("/") + .slice(-1)[0] + .replace(/\..+/, "")}" }` + ), loc: codePath.callee.loc, messageId: codePath.callee.name === "makeStyles" @@ -17,6 +26,7 @@ module.exports = { } }), meta: { + fixable: "code", messages: { expectedNameHoc: 'withStyles hook should have "name" property.', expectedNameHook: 'makeStyles hook should have "name" property.'