Skip to content

Commit

Permalink
refactor!: move to esm (#2)
Browse files Browse the repository at this point in the history
* refactor: move to esm

* CI: add .github/release.yml

* CI: add setup-pnpm
  • Loading branch information
azu authored Jan 11, 2025
1 parent d20db61 commit fe44b62
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 2,360 deletions.
12 changes: 0 additions & 12 deletions .babelrc

This file was deleted.

30 changes: 30 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
changelog:
exclude:
labels:
- 'Type: Meta'
- 'Type: Question'
- 'Type: Release'

categories:
- title: Security Fixes
labels: ['Type: Security']
- title: Breaking Changes
labels: ['Type: Breaking Change']
- title: Features
labels: ['Type: Feature']
- title: Bug Fixes
labels: ['Type: Bug']
- title: Documentation
labels: ['Type: Documentation']
- title: Refactoring
labels: ['Type: Refactoring']
- title: Testing
labels: ['Type: Testing']
- title: Maintenance
labels: ['Type: Maintenance']
- title: CI
labels: ['Type: CI']
- title: Dependency Updates
labels: ['Type: Dependencies', "dependencies"]
- title: Other Changes
labels: ['*']
17 changes: 12 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
name: test
on: [push, pull_request]
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
test:
timeout-minutes: 10
name: "Test on Node.js ${{ matrix.node-version }}"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12, 14, 16]
node-version: [ 20, 22 ]
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup pnpm
uses: pnpm/action-setup@v4
- name: setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install
run: yarn install
run: pnpm install
- name: Test
run: yarn test
run: pnpm test
5 changes: 0 additions & 5 deletions .mocharc.json

This file was deleted.

8 changes: 4 additions & 4 deletions bin/cmd.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
const { listPackageNames } = require('../lib/textlintrc-to-pacakge-list.js');
const concat = require('concat-stream');
const stripJsonComments = require("strip-json-comments");
import { listPackageNames } from "../lib/textlintrc-to-pacakge-list.js";
import concat from "concat-stream";
import stripJsonComments from "strip-json-comments";
import fs from "node:fs";

const fs = require('fs');
const file = process.argv[2];
const input = file && file !== '-'
? fs.createReadStream(process.argv[2])
Expand Down
16 changes: 4 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"bugs": {
"url": "https://github.com/textlint/textlintrc-to-package-list/issues"
},
"type": "module",
"version": "2.0.0",
"description": "listing package name from .textlintrc",
"main": "lib/textlintrc-to-package-list.js",
Expand All @@ -26,27 +27,18 @@
"test": "test"
},
"scripts": {
"build": "NODE_ENV=production babel src --out-dir lib --source-maps",
"watch": "babel src --out-dir lib --watch --source-maps",
"prepublish": "npm run --if-present build",
"test": "mocha",
"test": "node --test",
"updateSnapshot": "UPDATE_SNAPSHOT=1 npm test"
},
"keywords": [
"textlint",
"textlint-config"
],
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-preset-power-assert": "^3.0.0",
"mocha": "^9.1.3"
},
"dependencies": {
"concat-stream": "^2.0.0",
"strip-json-comments": "^3.1.1"
}
},
"packageManager": "pnpm@10.0.0+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b"
}
79 changes: 79 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/textlintrc-to-pacakge-list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// LICENSE : MIT
"use strict";

function validRulePackageKey(key) {
// valid: @scope/name
if (key.charAt(0) === "@") {
Expand Down
12 changes: 6 additions & 6 deletions test/textlintrc-to-package-list.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// LICENSE : MIT
"use strict";
import fs from "fs";
import path from "path";
import assert from "assert"
import { listPackageNames } from "../src/textlintrc-to-pacakge-list.js";
import fs from "node:fs";
import path from "node:path";
import assert from "node:assert"
import { describe, it } from "node:test";
import stripJsonComments from "strip-json-comments";
import { listPackageNames } from "../src/textlintrc-to-pacakge-list.js";

const fixturesDir = path.join(__dirname, 'fixtures');
const fixturesDir = path.join(import.meta.dirname, 'fixtures');
describe("textlintrc-to-package-list", () => {
fs.readdirSync(fixturesDir)
.forEach(caseName => {
Expand All @@ -15,7 +16,6 @@ describe("textlintrc-to-package-list", () => {
const fixtureDir = path.join(fixturesDir, caseName);
const actualFilePath = path.join(fixtureDir, ".textlintrc.json");
const actualContent = JSON.parse(stripJsonComments(fs.readFileSync(actualFilePath, "utf-8")));
console.log()
const actualResults = listPackageNames(actualContent);
const expectedFilePath = path.join(fixtureDir, "output.json");
// Usage: update snapshots
Expand Down
Loading

0 comments on commit fe44b62

Please sign in to comment.