Skip to content

Commit

Permalink
feat: converted to TypeScript (#59)
Browse files Browse the repository at this point in the history
Work in progress:

- [x] `npm run tsc` passes
- [x] `npm run test` passes (except for #60)
- [x] Filed docs issue on `jsonc-eslint-parser` to document how to work
effectively with ESTree:
ota-meshi/jsonc-eslint-parser#184

Fixes #35.

Converts source files to TypeScript. In doing so, switches the test
library from Mocha to Vitest so that no transpiling is needed for tests.

~Will wait for feedback on
ota-meshi/eslint-plugin-jsonc#269 before taking
that PR's strategy in here.~ ✅ Brings in
ota-meshi/eslint-plugin-jsonc#271
`RuleListener` type as well.

~Marking as blocked on #60. I'd like that to be resolved before making
any changes that happen to also change tests around.~ ✅
  • Loading branch information
JoshuaKGoldberg authored Nov 8, 2023
1 parent 8b2f1e4 commit c328633
Show file tree
Hide file tree
Showing 32 changed files with 1,843 additions and 3,773 deletions.
12 changes: 12 additions & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description: Prepares the repo for a typical CI job

name: Prepare

runs:
steps:
- uses: actions/setup-node@v4
with:
node-version: '18'
- run: npm ci
shell: bash
using: composite
15 changes: 15 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: npm run format -- --check

name: Format

on:
pull_request: ~
push:
branches:
- main
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: npm run lint

name: Lint

on:
pull_request: ~
push:
branches:
- main
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- uses: ./.github/actions/prepare
- run: npm run test

name: Test
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/tsc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
jobs:
tsc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: npm run tsc

name: Type Check

on:
pull_request: ~
push:
branches:
- main
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
npm-debug.log
node_modules
.nyc_output
coverage
lib
node_modules
npm-debug.log
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint"]
}
29 changes: 14 additions & 15 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"skipFiles": [
"node-internals:*"
],
"port": 9229
}
]
"configurations": [
{
"args": ["run", "${relativeFile}"],
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"name": "Debug Current Test File",
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"request": "launch",
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"type": "node"
}
],
"version": "0.2.0"
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"typescript.tsdk": "node_modules/typescript/lib"
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Rules for valid, consistent, and readable package.json files
You'll first need to install [ESLint](http://eslint.org) >=8 and `eslint-plugin-package-json`:

```shell
$ npm install eslint eslint-plugin-package-json --save-dev
$ npm install eslint eslint-plugin-package-json jsonc-eslint-parser --save-dev
```

**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-package-json` globally.
Expand Down Expand Up @@ -40,7 +40,7 @@ module.exports = {
overrides: [
{
files: ['package.json'],
parser: 'jsonc-eslint-parser'
parser: 'jsonc-eslint-parser',
plugins: ['package-json'],
rules: {
'package-json/valid-package-def': 'error'
Expand Down
17 changes: 0 additions & 17 deletions lib/createRule.js

This file was deleted.

Loading

0 comments on commit c328633

Please sign in to comment.