Skip to content

Commit

Permalink
feat: update toolchain (#19)
Browse files Browse the repository at this point in the history
Modernize dev tools and refactor code to conform to new linting standards.

* `ava` → `node:test`
* `ts-node` → `tsx`
* `ts-standardx` (standard) → `eslint`/`prettier` (`@haltcase/style`)
* add CI for code quality checks

BREAKING CHANGE: Node.js 18+ is now required.
  • Loading branch information
haltcase authored Apr 2, 2024
1 parent fab51d6 commit 3ca7cba
Show file tree
Hide file tree
Showing 20 changed files with 824 additions and 736 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yaml,yml}]
indent_size = 2
indent_style = space
62 changes: 27 additions & 35 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
"use strict"
"use strict";

const [, , error] = ["off", "warn", "error"]
const { resolve } = require("node:path");

module.exports = {
extends: ["./node_modules/ts-standardx/.eslintrc.js"],
ignorePatterns: ["dist"],
rules: {
"no-unused-vars": [
error,
{
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
varsIgnorePattern: "^_"
}
],
quotes: [error, "double"],
const project = [
resolve(__dirname, "tsconfig.json"),
resolve(__dirname, "./tests/tsconfig.json")
];

"prettier/prettier": [
error,
{
semi: false,
singleQuote: false,
trailingComma: "none",
bracketSameLine: true,
arrowParens: "avoid"
}
]
},
overrides: [
{
files: ["**/*.{ts,tsx}"],
rules: {
"@typescript-eslint/quotes": [error, "double"]
}
}
]
}
module.exports = {
env: {
node: true,
es2023: true
},
extends: [
require.resolve("@haltcase/style/eslint/node"),
require.resolve("@haltcase/style/eslint/typescript")
],
parserOptions: {
ecmaVersion: 2023,
project: true
},
settings: {
"import/resolver": {
typescript: {
project
}
}
}
};
34 changes: 34 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Quality

on:
pull_request:
push:
branches:
- "canary"
- "main"

jobs:
code-quality:
name: Code quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3

- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: package.json
check-latest: true

- run: pnpm install
- run: pnpm test

- name: Check linting (ESLint)
run: pnpm eslint:check

- name: Check formatting (Prettier)
run: pnpm prettier:check

- name: Check linting (ESLint)
run: pnpm typescript:check
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 14]
node: [18, 20]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Install Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: yarn && yarn test
- run: pnpm install
- run: pnpm test
23 changes: 18 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# ide configurations
.c9
.idea
.vscode
# https://help.github.com/articles/ignoring-files/

# dependencies
/node_modules
/.pnp
/.pnpm-store
.pnp.js

# lock files
npm-shrinkwrap.json
package-lock.json
pnpm-lock.yaml
yarn.lock

node_modules
# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

tsconfig.tsbuildinfo

/dist
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"search.exclude": {
"package-lock.json": true,
"pnpm-lock.yaml": true
},
"prettier.arrowParens": "always",
"prettier.bracketSpacing": true,
"prettier.bracketSameLine": true,
"prettier.printWidth": 80,
"prettier.semi": true,
"prettier.singleQuote": false,
"prettier.trailingComma": "none",
"prettier.useTabs": true,
"typescript.tsdk": "node_modules\\typescript\\lib"
}
10 changes: 0 additions & 10 deletions ava.config.js

This file was deleted.

112 changes: 63 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,65 @@
{
"name": "tablemark",
"version": "3.1.0",
"description": "Generate markdown tables from a list of objects or JSON data.",
"author": "Bo Lingen <bo@haltcase.dev> (https://github.com/haltcase)",
"license": "MIT",
"repository": "https://github.com/haltcase/tablemark",
"homepage": "https://github.com/haltcase/tablemark",
"bugs": "https://github.com/haltcase/tablemark/issues",
"engines": {
"node": ">=14.16"
},
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"keywords": [
"markdown",
"table",
"tables",
"json",
"convert",
"generate",
"ghfm",
"tableify",
"typescript"
],
"files": [
"dist"
],
"scripts": {
"lint": "ts-standardx src && cd tests && ts-standardx .",
"build": "tsc",
"pretest": "npm run build",
"test": "ava",
"changelog": "changelog",
"prepublishOnly": "npm run lint && npm test"
},
"devDependencies": {
"@citycide/changelog": "^2.0.0",
"@types/node": "^14.17.27",
"ava": "^3.15.0",
"ts-node": "^10.3.0",
"ts-standardx": "^0.8.4",
"typescript": "^4.4.4"
},
"dependencies": {
"sentence-case": "^3.0.4",
"split-text-to-chunks": "^1.0.0"
}
"name": "tablemark",
"version": "3.1.0",
"description": "Generate markdown tables from a list of objects or JSON data.",
"keywords": [
"markdown",
"table",
"tables",
"json",
"convert",
"generate",
"ghfm",
"tableify",
"typescript"
],
"homepage": "https://github.com/haltcase/tablemark",
"bugs": "https://github.com/haltcase/tablemark/issues",
"repository": "https://github.com/haltcase/tablemark",
"license": "MIT",
"author": "Bo Lingen <bo@haltcase.dev> (https://github.com/haltcase)",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"changelog": "changelog",
"eslint:check": "eslint src tests",
"format": "eslint --fix src tests && prettier --write src tests",
"prepublishOnly": "pnpm format && pnpm test",
"prettier:check": "prettier --check src tests",
"test": "glob \"**/*.test.ts\" --cmd \"node --import tsx --test\"",
"typescript:check": "tsc --noEmit && echo \"No errors reported by tsc.\""
},
"prettier": "@haltcase/style/prettier",
"dependencies": {
"sentence-case": "^3.0.4",
"split-text-to-chunks": "^1.0.0"
},
"devDependencies": {
"@citycide/changelog": "^2.0.0",
"@haltcase/style": "^6.1.0",
"@types/node": "^20.12.2",
"eslint": "^8.57.0",
"glob": "^10.3.12",
"prettier": "^3.2.5",
"tsx": "^4.7.1",
"typescript": "^5.3.3"
},
"packageManager": "pnpm@8.11.0",
"engines": {
"node": ">=18"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit 3ca7cba

Please sign in to comment.