diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 88b72f3..cc5931e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: ^20.8 + node-version: '22' - run: | npm install npm run lint @@ -27,7 +27,7 @@ jobs: strategy: matrix: - node-version: ['12.22.0', '12', '14.17.0', '14', '16.0.0', '16', '18', '20', '21'] + node-version: ['12.22.0', '12', '14.17.0', '14', '16.0.0', '16', '18', '20', '22'] steps: - uses: actions/checkout@v4 @@ -35,12 +35,12 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: | - npm install + npm install --force eslint@8.4 npm test - test-eslint-8_4: + test-eslint-9: - name: Test (ESLint 8.4) + name: Test (ESLint 9) runs-on: ubuntu-latest @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '22' - run: | - npm install --force eslint@8.4 + npm install --force eslint@9 npm test diff --git a/lib/format-code-path.js b/lib/format-code-path.js index a899d49..53608d2 100644 --- a/lib/format-code-path.js +++ b/lib/format-code-path.js @@ -43,10 +43,10 @@ function formatCodePath(codePath, { segmentNames } = { }) { const { id } = segment; const lines = segment.internal.nodes || []; + if (!segment.reachable) + lines.unshift('❮❮unreachable❯❯'); if (segmentNames) lines.unshift(`【${id}】`); - else if (!lines.length) - lines.push(id); const label = lines.join('\n'); text += `state ${JSON.stringify(label)} as ${id}\n`; } diff --git a/package.json b/package.json index 5444f1f..166803f 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,11 @@ "test": "mocha --check-leaks" }, "dependencies": { - "eslint": "^8.4", + "eslint": ">=8.4", "postrequire": "2" }, "devDependencies": { - "@origin-1/eslint-config": "latest", + "@origin-1/eslint-config": "eslint-8", "c8js": "latest", "eslint-formatter-compact": "latest", "globals": "latest", diff --git a/test/expected/graph-2.mermaid b/test/expected/graph-2.mermaid index 5d5c006..d2f71ee 100644 --- a/test/expected/graph-2.mermaid +++ b/test/expected/graph-2.mermaid @@ -5,7 +5,7 @@ classDef unreachable fill: #FF9800, stroke-dasharray: 5 5 class s1_2 unreachable classDef thrown fill: none, stroke: none state "Program:enter\nThrowStatement:enter\nIdentifier (foo)\nThrowStatement:exit" as s1_1 -state "Program:exit" as s1_2 +state "❮❮unreachable❯❯\nProgram:exit" as s1_2 thrown:::thrown: ✘ [*] --> s1_1 s1_1 --> s1_2 diff --git a/test/expected/graph-3.mermaid b/test/expected/graph-3.mermaid index 11e2480..3f78d34 100644 --- a/test/expected/graph-3.mermaid +++ b/test/expected/graph-3.mermaid @@ -7,7 +7,7 @@ classDef thrown fill: none, stroke: none state "【s1_1】" as s1_1 state "【s1_2】" as s1_2 state "【s1_4】" as s1_4 -state "【s1_3】" as s1_3 +state "【s1_3】\n❮❮unreachable❯❯" as s1_3 thrown:::thrown: ✘ [*] --> s1_1 s1_1 --> s1_2 diff --git a/test/expected/graph-4.mermaid b/test/expected/graph-4.mermaid index 3d86945..83bd844 100644 --- a/test/expected/graph-4.mermaid +++ b/test/expected/graph-4.mermaid @@ -7,7 +7,7 @@ classDef thrown fill: none, stroke: none state "【s1_1】\nProgram:enter\nIfStatement:enter\nIdentifier (foo)" as s1_1 state "【s1_2】\nThrowStatement:enter\nIdentifier (bar)\nThrowStatement:exit" as s1_2 state "【s1_4】\nIfStatement:exit\nProgram:exit" as s1_4 -state "【s1_3】" as s1_3 +state "【s1_3】\n❮❮unreachable❯❯" as s1_3 thrown:::thrown: ✘ [*] --> s1_1 s1_1 --> s1_2 diff --git a/test/expected/graph-7.mermaid b/test/expected/graph-7.mermaid index 59a18d2..085c38b 100644 --- a/test/expected/graph-7.mermaid +++ b/test/expected/graph-7.mermaid @@ -4,7 +4,7 @@ class s1_1, s1_2 common classDef unreachable fill: #FF9800, stroke-dasharray: 5 5 class s1_2 unreachable state "Program:enter\nReturnStatement:enter\nIdentifier (foo)\nReturnStatement:exit" as s1_1 -state "Program:exit" as s1_2 +state "❮❮unreachable❯❯\nProgram:exit" as s1_2 [*] --> s1_1 s1_1 --> s1_2 s1_1 --> [*] diff --git a/test/expected/graph-8.mermaid b/test/expected/graph-8.mermaid index e44900e..debc8c2 100644 --- a/test/expected/graph-8.mermaid +++ b/test/expected/graph-8.mermaid @@ -6,7 +6,7 @@ class s1_3 unreachable state "Program:enter\nIfStatement:enter\nIdentifier (foo)" as s1_1 state "ReturnStatement" as s1_2 state "IfStatement:exit\nProgram:exit" as s1_4 -state "s1_3" as s1_3 +state "❮❮unreachable❯❯" as s1_3 [*] --> s1_1 s1_1 --> s1_2 s1_1 --> s1_4