diff --git a/lua/rule-breaker/ignoreRuleData.lua b/lua/rule-breaker/ignoreRuleData.lua new file mode 100644 index 0000000..91af462 --- /dev/null +++ b/lua/rule-breaker/ignoreRuleData.lua @@ -0,0 +1,29 @@ +---@class ruleIgnoreConfig +---@field comment string|string[] with %s for the rule id +---@field type "sameLine"|"nextLine"|"enclose" + +---@type table +local data = { + shellcheck = { + comment = "# shellcheck disable=%s", + type = "nextLine", + }, + selene = { + comment = "-- selene: allow(%s)", + type = "nextLine", + }, + vale = { + comment = { "", "" }, + type = "enclose", + }, + yamllint = { + comment = "# yamllint disable-line rule:%s", + type = "nextLine", + }, + stylelint = { + comment = "/* stylelint-disable-next-line %s */", + type = "nextLine", + }, +} + +return data diff --git a/lua/rule-breaker.lua b/lua/rule-breaker/init.lua similarity index 84% rename from lua/rule-breaker.lua rename to lua/rule-breaker/init.lua index afb50d2..c69528b 100644 --- a/lua/rule-breaker.lua +++ b/lua/rule-breaker/init.lua @@ -1,34 +1,7 @@ local M = {} local fn = vim.fn --------------------------------------------------------------------------------- ----@class ruleIgnoreConfig ----@field comment string|string[] with %s for the rule id ----@field type "sameLine"|"nextLine"|"enclose" - ----@type table -local ignoreRuleData = { - shellcheck = { - comment = "# shellcheck disable=%s", - type = "nextLine", - }, - selene = { - comment = "-- selene: allow(%s)", - type = "nextLine", - }, - vale = { - comment = { "", "" }, - type = "enclose", - }, - yamllint = { - comment = "# yamllint disable-line rule:%s", - type = "nextLine", - }, - stylelint = { - comment = "/* stylelint-disable-next-line %s */", - type = "nextLine", - }, -} +local ignoreRuleData = require("rule-breaker.ignoreRuleData") -------------------------------------------------------------------------------- @@ -117,7 +90,7 @@ local function addIgnoreComment(diag) return end - -- insert rule id and indentation into comment + -- add rule id and indentation into comment local currentIndent = vim.api.nvim_get_current_line():match("^%s*") local ignoreComment = ignoreRuleData[diag.source].comment if type(ignoreComment) == "string" then ignoreComment = { ignoreComment } end