From 671329ef258bdd663a3138a578ee0d754da4b7d6 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Thu, 22 Jul 2021 17:40:21 -0700 Subject: [PATCH] Update: Fix linting inconsistencies in template (#106) --- plugin/templates/_.eslintrc.js | 12 ++++----- plugin/templates/_plugin.js | 3 +-- rule/templates/_rule.js | 49 ++++++++++++++++------------------ rule/templates/_test.js | 32 +++++++++------------- 4 files changed, 43 insertions(+), 53 deletions(-) diff --git a/plugin/templates/_.eslintrc.js b/plugin/templates/_.eslintrc.js index 4f88f53..2f33f7a 100644 --- a/plugin/templates/_.eslintrc.js +++ b/plugin/templates/_.eslintrc.js @@ -1,19 +1,19 @@ -'use strict'; +"use strict"; module.exports = { root: true, extends: [ - 'eslint:recommended', - 'plugin:eslint-plugin/recommended', - 'plugin:node/recommended', + "eslint:recommended", + "plugin:eslint-plugin/recommended", + "plugin:node/recommended", ], env: { node: true, }, overrides: [ { - files: ['tests/**/*.js'], + files: ["tests/**/*.js"], env: { mocha: true }, }, - ] + ], }; diff --git a/plugin/templates/_plugin.js b/plugin/templates/_plugin.js index bf04743..8f1fc91 100644 --- a/plugin/templates/_plugin.js +++ b/plugin/templates/_plugin.js @@ -22,7 +22,6 @@ module.exports.rules = requireIndex(__dirname + "/rules"); <% if (hasProcessors) { %> // import processors module.exports.processors = { - - // add your processors here + // add your processors here }; <% } %> diff --git a/rule/templates/_rule.js b/rule/templates/_rule.js index f343534..473604c 100644 --- a/rule/templates/_rule.js +++ b/rule/templates/_rule.js @@ -9,36 +9,33 @@ //------------------------------------------------------------------------------ module.exports = { - meta: { - type: null, // `problem`, `suggestion`, or `layout` - docs: { - description: "<%- desc.replace(/"/g, '\\"') %>", - category: "Fill me in", - recommended: false, - url: null, // URL to the documentation page for this rule - }, - fixable: null, // or "code" or "whitespace" - schema: [], // Add a schema if the rule has options + meta: { + type: null, // `problem`, `suggestion`, or `layout` + docs: { + description: "<%- desc.replace(/"/g, '\\"') %>", + category: "Fill me in", + recommended: false, + url: null, // URL to the documentation page for this rule }, + fixable: null, // Or `code` or `whitespace` + schema: [], // Add a schema if the rule has options + }, - create: function(context) { + create(context) { + // variables should be defined here - // variables should be defined here + //---------------------------------------------------------------------- + // Helpers + //---------------------------------------------------------------------- - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- + // any helper functions should go here or else delete this section - // any helper functions should go here or else delete this section + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - - // give me methods - - }; - } + return { + // visitor functions for different types of nodes + }; + }, }; diff --git a/rule/templates/_test.js b/rule/templates/_test.js index ac280a5..365ef65 100644 --- a/rule/templates/_test.js +++ b/rule/templates/_test.js @@ -8,32 +8,26 @@ // Requirements //------------------------------------------------------------------------------ -var rule = require("../../../lib/rules/<%= ruleId %>"), -<% if (target === "eslint") { %> - RuleTester = require("../../../lib/testers/rule-tester"); +const rule = require("../../../lib/rules/<%= ruleId %>"),<% if (target === "eslint") { %> + RuleTester = require("../../../lib/testers/rule-tester"); <% } else { %> - RuleTester = require("eslint").RuleTester; + RuleTester = require("eslint").RuleTester; <% } %> //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var ruleTester = new RuleTester(); +const ruleTester = new RuleTester(); ruleTester.run("<%= ruleId %>", rule, { + valid: [ + // give me some code that won't trigger a warning + ], - valid: [ - - // give me some code that won't trigger a warning - ], - - invalid: [ - { - code: "<%- invalidCode.replace(/"/g, '\\"') %>", - errors: [{ - message: "Fill me in.", - type: "Me too" - }] - } - ] + invalid: [ + { + code: "<%- invalidCode.replace(/"/g, '\\"') %>", + errors: [{ message: "Fill me in.", type: "Me too" }], + }, + ], });