Skip to content

Commit 7554757

Browse files
committed
fix: node.lang is not defined, skip it
1 parent 3a7d5ae commit 7554757

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"devDependencies": {
3535
"@types/eslint": "^8.4.10",
3636
"@types/node": "^18.11.18",
37-
"@types/structured-source": "^3.0.0",
3837
"eslint": "8.31.0",
3938
"textlint-plugin-asciidoctor": "^1.1.0",
4039
"textlint-scripts": "^13.0.1",
@@ -46,7 +45,7 @@
4645
"eslint": "^8.0.0"
4746
},
4847
"dependencies": {
49-
"@textlint/types": "^12.6.0",
48+
"@textlint/types": "^13.0.5",
5049
"structured-source": "^4.0.0"
5150
}
5251
}

src/textlint-rule-eslint.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type Options = {
2727
langs: string[]
2828
}
2929
const reporter: TextlintRuleModule<Options> = (context, options) => {
30-
const { Syntax, RuleError, report, fixer, getSource, getFilePath} = context;
30+
const { Syntax, RuleError, report, fixer, getSource, getFilePath } = context;
3131
if (!options) {
3232
throw new Error(`Require options: { "configFile": "path/to/.eslintrc" }`);
3333
}
@@ -43,6 +43,9 @@ const reporter: TextlintRuleModule<Options> = (context, options) => {
4343
});
4444
return {
4545
async [Syntax.CodeBlock](node) {
46+
if (!node.lang) {
47+
return;
48+
}
4649
if (availableLang.indexOf(node.lang) === -1) {
4750
return;
4851
}

test/textlint-rule-eslint-test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ tester.run("textlint-rule-eslint", rule, {
2424
configFile: configFilePath
2525
}
2626
},
27+
{
28+
text: "```\n\n" +
29+
"++++++" +
30+
"```",
31+
options: {
32+
configFile: configFilePath
33+
}
34+
},
2735
{
2836
text: "```js\n\n" +
2937
"var a = 1;\n\n" +

yarn.lock

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,16 +1459,16 @@
14591459
"@nodelib/fs.scandir" "2.1.5"
14601460
fastq "^1.6.0"
14611461

1462-
"@textlint/ast-node-types@^12.6.1":
1463-
version "12.6.1"
1464-
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-12.6.1.tgz#35ecefe74e701d7f632c083d4fda89cab1b89012"
1465-
integrity sha512-uzlJ+ZsCAyJm+lBi7j0UeBbj+Oy6w/VWoGJ3iHRHE5eZ8Z4iK66mq+PG/spupmbllLtz77OJbY89BYqgFyjXmA==
1466-
14671462
"@textlint/ast-node-types@^13.0.1":
14681463
version "13.0.1"
14691464
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-13.0.1.tgz#9f82450bb80499140b7cf1a2cfbaeab8ad1c1755"
14701465
integrity sha512-XK0dWw98gLlUDjciuqebpBez6tAAxlzwqlrcj30PMJ7LYlXee2PyFBVIW3q3R4M6JY0OpqI7DC+YZ0KD3Gaxew==
14711466

1467+
"@textlint/ast-node-types@^13.0.5":
1468+
version "13.0.5"
1469+
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-13.0.5.tgz#fcea5a5ad29478e84b3de6286fea0b32278b685b"
1470+
integrity sha512-BiH5QOKDs52WR2Q26POwm5RaNs7hnU6TCrkoo4uECZQjjDQoaQWsp242KDQnvbiGnkj/a2xl+XPMuFCyn0XqjA==
1471+
14721472
"@textlint/ast-tester@^13.0.1":
14731473
version "13.0.1"
14741474
resolved "https://registry.yarnpkg.com/@textlint/ast-tester/-/ast-tester-13.0.1.tgz#310e18cfc13bc84108b13ad810572e231087fde7"
@@ -1549,20 +1549,20 @@
15491549
dependencies:
15501550
"@textlint/text-to-ast" "^13.0.1"
15511551

1552-
"@textlint/types@^12.6.0":
1553-
version "12.6.1"
1554-
resolved "https://registry.yarnpkg.com/@textlint/types/-/types-12.6.1.tgz#d00c5d625287a113c2807587c2c0cdc1c7f182d8"
1555-
integrity sha512-t1SZYahu2olnF8MUhlP6qDIEDyl7WmyIaBYxQdE2qU6xUkZWXS2zIxoAT/pVgvFCzDw3KO5HhIYGVeWRp90dTg==
1556-
dependencies:
1557-
"@textlint/ast-node-types" "^12.6.1"
1558-
15591552
"@textlint/types@^13.0.1":
15601553
version "13.0.1"
15611554
resolved "https://registry.yarnpkg.com/@textlint/types/-/types-13.0.1.tgz#ae286b9a0b714f5944a4522c57ebf60bc88b97bb"
15621555
integrity sha512-sO2B4B8ZTyMuYeOk92zmq+rF5Sh1p1+wredQyvAnTHrM2Wa1Khfl1iP1yN1dVDTE/AMIOP4UuC/Bc1Kyb7l6/w==
15631556
dependencies:
15641557
"@textlint/ast-node-types" "^13.0.1"
15651558

1559+
"@textlint/types@^13.0.5":
1560+
version "13.0.5"
1561+
resolved "https://registry.yarnpkg.com/@textlint/types/-/types-13.0.5.tgz#c26037c7a38f600427d4f7f3e72f0b526e3c491c"
1562+
integrity sha512-H4BzC1wPiN2kJc6WUre6ggIeVKy6vKMAWQYkR0VmMtk1Lu5kysvwRifNuqecVIHpJIBwtVhkhrBlH1fz50SlXg==
1563+
dependencies:
1564+
"@textlint/ast-node-types" "^13.0.5"
1565+
15661566
"@textlint/utils@^13.0.1":
15671567
version "13.0.1"
15681568
resolved "https://registry.yarnpkg.com/@textlint/utils/-/utils-13.0.1.tgz#d0619f7fd95edd9f3d309f3a637a20e4e8093082"
@@ -1628,11 +1628,6 @@
16281628
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
16291629
integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==
16301630

1631-
"@types/structured-source@^3.0.0":
1632-
version "3.0.0"
1633-
resolved "https://registry.yarnpkg.com/@types/structured-source/-/structured-source-3.0.0.tgz#e95d76037d400c1957f3b709f023b308e92f3829"
1634-
integrity sha512-8u+Wo5+GEXe4jZyQ8TplLp+1A7g32ZcVoE7VZu8VcxnlaEm5I/+T579R7q3qKN76jmK0lRshpo4hl4bj/kEPKA==
1635-
16361631
"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2":
16371632
version "2.0.3"
16381633
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"

0 commit comments

Comments
 (0)