Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Oct 4, 2023
1 parent 0d3b594 commit 700ab8f
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 44 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ node_modules/
temp/
npm-debug.log
.eslint-release-info.json
.idea
*.swp
yarn-error.log
coverage
1 change: 0 additions & 1 deletion .madrun.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export default {
'coverage': async () => `c8 ${await run('test')}`,
'report': () => 'c8 report --reporter=lcov',
};

2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
test
.*

yarn-error.log
coverage
4 changes: 1 addition & 3 deletions .putout.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"ignore": [
"templates"
]
"ignore": ["test", "templates"]
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
}
15 changes: 9 additions & 6 deletions lib/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.';
}

/**
Expand All @@ -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.';
}

/**
Expand All @@ -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;
}

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions plugin/index.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 700ab8f

Please sign in to comment.