Преглед на файлове

style: add taplo format (#318)

LongYinan преди 2 години
родител
ревизия
828fd3236d
променени са 8 файла, в които са добавени 54 реда и са изтрити 14 реда
  1. 20 0
      .github/renovate.json
  2. 3 0
      .github/workflows/CI.yml
  3. 5 10
      .github/workflows/lint.yml
  4. 7 0
      .taplo.toml
  5. 1 1
      .yarnrc.yml
  6. 2 2
      Cargo.toml
  7. 6 1
      package.json
  8. 10 0
      yarn.lock

+ 20 - 0
.github/renovate.json

@@ -0,0 +1,20 @@
+{
+  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
+  "extends": ["config:base", "group:allNonMajor", ":preserveSemverRanges", ":disablePeerDependencies"],
+  "labels": ["dependencies"],
+  "packageRules": [
+    {
+      "matchPackageNames": ["@napi/cli", "napi", "napi-build", "napi-derive"],
+      "addLabels": ["napi-rs"],
+      "groupName": "napi-rs"
+    },
+    {
+      "matchPackagePatterns": ["^eslint", "^@typescript-eslint"],
+      "groupName": "linter"
+    }
+  ],
+  "commitMessagePrefix": "chore: ",
+  "commitMessageAction": "bump up",
+  "commitMessageTopic": "{{depName}} version",
+  "ignoreDeps": []
+}

+ 3 - 0
.github/workflows/CI.yml

@@ -16,6 +16,9 @@ env:
       - .editorconfig
       - docs/**
   pull_request: null
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 jobs:
   build:
     strategy:

+ 5 - 10
.github/workflows/lint.yml

@@ -7,7 +7,9 @@ on:
     tags-ignore:
       - '**'
   pull_request:
-
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 jobs:
   lint:
     name: Lint
@@ -18,23 +20,16 @@ jobs:
       - name: Setup node
         uses: actions/setup-node@v3
         with:
-          node-version: 16
+          node-version: 18
           cache: 'yarn'
-          check-latest: true
 
       - name: Install
         uses: dtolnay/rust-toolchain@stable
         with:
           components: clippy, rustfmt
 
-      - name: Cache NPM dependencies
-        uses: actions/cache@v3
-        with:
-          path: node_modules
-          key: npm-cache-lint-node@16
-
       - name: Install dependencies
-        run: yarn install --immutable --network-timeout 300000
+        run: yarn install
 
       - name: ESLint
         run: yarn lint

+ 7 - 0
.taplo.toml

@@ -0,0 +1,7 @@
+exclude = ["node_modules/**/*.toml"]
+
+# https://taplo.tamasfe.dev/configuration/formatter-options.html
+[formatting]
+align_entries = true
+indent_tables = true
+reorder_keys  = true

+ 1 - 1
.yarnrc.yml

@@ -1,5 +1,5 @@
 nodeLinker: node-modules
 
-npmAuditRegistry: "https://registry.npmjs.org"
+npmAuditRegistry: 'https://registry.npmjs.org'
 
 yarnPath: .yarn/releases/yarn-3.4.1.cjs

+ 2 - 2
Cargo.toml

@@ -1,7 +1,7 @@
 [package]
 authors = ["LongYinan <lynweklm@gmail.com>"]
 edition = "2021"
-name = "napi-package-template"
+name    = "napi-package-template"
 version = "0.1.0"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -10,7 +10,7 @@ version = "0.1.0"
 crate-type = ["cdylib"]
 
 [dependencies]
-napi = "2"
+napi        = "2"
 napi-derive = "2"
 
 [build-dependencies]

+ 6 - 1
package.json

@@ -47,8 +47,9 @@
     "bench": "node -r @swc-node/register benchmark/bench.ts",
     "build": "napi build --platform --release --pipe \"prettier -w\"",
     "build:debug": "napi build --platform --pipe \"prettier -w\"",
-    "format": "run-p format:prettier format:rs",
+    "format": "run-p format:prettier format:rs format:toml",
     "format:prettier": "prettier . -w",
+    "format:toml": "taplo format",
     "format:rs": "cargo fmt",
     "lint": "eslint . -c ./.eslintrc.yml",
     "prepublishOnly": "napi prepublish -t npm",
@@ -59,6 +60,7 @@
     "@napi-rs/cli": "^2.14.6",
     "@swc-node/register": "^1.5.5",
     "@swc/core": "^1.3.32",
+    "@taplo/cli": "^0.5.2",
     "@typescript-eslint/eslint-plugin": "^5.50.0",
     "@typescript-eslint/parser": "^5.50.0",
     "ava": "^5.1.1",
@@ -80,6 +82,9 @@
     ],
     "*.@(js|ts|tsx|yml|yaml|md|json)": [
       "prettier --write"
+    ],
+    "*.toml": [
+      "taplo format"
     ]
   },
   "ava": {

+ 10 - 0
yarn.lock

@@ -114,6 +114,7 @@ __metadata:
     "@napi-rs/cli": ^2.14.6
     "@swc-node/register": ^1.5.5
     "@swc/core": ^1.3.32
+    "@taplo/cli": ^0.5.2
     "@typescript-eslint/eslint-plugin": ^5.50.0
     "@typescript-eslint/parser": ^5.50.0
     ava: ^5.1.1
@@ -323,6 +324,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@taplo/cli@npm:^0.5.2":
+  version: 0.5.2
+  resolution: "@taplo/cli@npm:0.5.2"
+  bin:
+    taplo: dist/cli.js
+  checksum: c2e0e584172bfee1cca6624bdb4470259179e232472fc7f4bbbd2e0127233039b9ace21a8d6b8d5081b157d9f046dc942ab27a634e23924b8c8a6096f1d04e27
+  languageName: node
+  linkType: hard
+
 "@tootallnate/once@npm:2":
   version: 2.0.0
   resolution: "@tootallnate/once@npm:2.0.0"