From 700ab8f9b603f949e344aa6aa8cbb73465e7d4bf Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Oct 2023 15:58:46 +0300 Subject: [PATCH] chore: lint --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++-------------- .gitignore | 4 ++++ .madrun.mjs | 1 - .npmignore | 2 ++ .putout.json | 4 +--- README.md | 1 - app/index.js | 22 ++++++++++---------- lib/validators.js | 15 ++++++++------ package.json | 6 +----- plugin/index.js | 4 ++-- 10 files changed, 58 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d80191..2733407 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,10 +12,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: + - 16.x + - 18.x + - 20.x - name: Install dependencies run: npm ci - name: Lint files @@ -24,20 +30,27 @@ jobs: name: Test strategy: matrix: - os: [ubuntu-latest] - node: [18.x, 16.x, 14.x] + os: + - ubuntu-latest + node: + - 18.x + - 16.x + - 14.x include: - - os: windows-latest - node: "18.x" + - os: windows-latest + node: 18.x runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - - name: Install latest NPM - run: npm install -g npm@latest - - name: Install dependencies - run: npm ci - - name: Run tests - run: npm test + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: + - 16.x + - 18.x + - 20.x + - name: Install latest NPM + run: bun i -g npm@latest --no-save + - name: Install dependencies + run: npm ci + - name: Run tests + run: npm test diff --git a/.gitignore b/.gitignore index 49cc8b3..6e38a04 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ node_modules/ temp/ npm-debug.log .eslint-release-info.json +.idea +*.swp +yarn-error.log +coverage diff --git a/.madrun.mjs b/.madrun.mjs index 9ef8416..2128d83 100644 --- a/.madrun.mjs +++ b/.madrun.mjs @@ -10,4 +10,3 @@ export default { 'coverage': async () => `c8 ${await run('test')}`, 'report': () => 'c8 report --reporter=lcov', }; - diff --git a/.npmignore b/.npmignore index 4cde8bd..7c831da 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,5 @@ test .* +yarn-error.log +coverage diff --git a/.putout.json b/.putout.json index 7b2fefc..9559429 100644 --- a/.putout.json +++ b/.putout.json @@ -1,5 +1,3 @@ { - "ignore": [ - "templates" - ] + "ignore": ["test", "templates"] } diff --git a/README.md b/README.md index 53743e3..00e2a7a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ ![image](https://user-images.githubusercontent.com/1573141/187409656-fdd6a1f6-3ae2-4752-a30e-a8420011fcdd.png) - The 🐊Putout generator for [Yeoman](https://yeoman.io/). This generator is intended to aid development within the 🐊[Putout](https://github.com/coderaiser/putout) project. It is designed to work within the top-level `putout` directory. ## Installation diff --git a/app/index.js b/app/index.js index 7960627..ef75feb 100644 --- a/app/index.js +++ b/app/index.js @@ -4,27 +4,27 @@ * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ - //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ +import Generator from 'yeoman-generator'; +import PluginGenerator from '../plugin/index.js'; +import {fileURLToPath} from 'node:url'; +import path from 'node:path'; -import Generator from "yeoman-generator"; -import PluginGenerator from "../plugin/index.js"; -import { fileURLToPath } from "node:url"; -import path from "node:path"; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle +const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const RULE_GENERATOR_PATH = path.join(__dirname, "..", "rule", "index.js"); -const PLUGIN_GENERATOR_PATH = path.join(__dirname, "..", "plugin", "index.js"); +// eslint-disable-line no-underscore-dangle +const PLUGIN_GENERATOR_PATH = path.join(__dirname, '..', 'plugin', 'index.js'); //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ - export default class extends Generator { initializing() { - this.composeWith({ Generator: PluginGenerator, path: PLUGIN_GENERATOR_PATH }); + this.composeWith({ + Generator: PluginGenerator, + path: PLUGIN_GENERATOR_PATH, + }); } } diff --git a/lib/validators.js b/lib/validators.js index 9b184b9..68705c3 100644 --- a/lib/validators.js +++ b/lib/validators.js @@ -2,12 +2,11 @@ * @fileoverview Validation helpers * @author Nicholas C. Zakas */ - /** * Regex for valid IDs * @type {RegExp} */ -const rValidId = /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)$/u; +const rValidId = /^[\da-z]+(?:-[\da-z]+)*$/u; /** * Determines if a given pluginId is valid. This is used by the prompt system. @@ -18,7 +17,8 @@ export function isPluginId(pluginId) { if (rValidId.test(pluginId)) { return true; } - return "Plugin ID must be all lowercase with dashes as separators."; + + return 'Plugin ID must be all lowercase with dashes as separators.'; } /** @@ -30,7 +30,8 @@ export function isRuleId(ruleId) { if (rValidId.test(ruleId)) { return true; } - return "Rule ID must be all lowercase with dashes as separators."; + + return 'Rule ID must be all lowercase with dashes as separators.'; } /** @@ -41,8 +42,10 @@ export function isRuleId(ruleId) { * if the value is not an empty string. */ export function isRequired(value) { - if (value === "") { - return "Please provide a value"; + if (value === '') { + return 'Please provide a value'; } + return true; } + diff --git a/package.json b/package.json index af46262..90f60d3 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,7 @@ "name": "generator-putout", "version": "1.1.0", "description": "A Yeoman generator for creating 🐊Putout plugins", - "commitType": "colon", - "keywords": [ - "putout", - "yeoman-generator" - ], + "keywords": ["putout", "yeoman-generator"], "homepage": "https://github.com/putoutjs/generator-putout", "funding": "https://opencollective.com/putout", "bugs": "https://github.com/putoutjs/generator-putout/issues", diff --git a/plugin/index.js b/plugin/index.js index 2ce010e..7cf0cd5 100644 --- a/plugin/index.js +++ b/plugin/index.js @@ -1,6 +1,6 @@ import Generator from 'yeoman-generator'; -import {basename} from 'path'; -import {cwd} from 'process'; +import {basename} from 'node:path'; +import {cwd} from 'node:process'; import {isRequired} from '../lib/validators.js'; export default class extends Generator {