Skip to content

Commit 97e0fa1

Browse files
authored
fix: Node.js 10のサポート[リグレッション修正] (#91)
* fix: Node.js 10のサポート * refactor: remove unneeded spread
1 parent 75418c8 commit 97e0fa1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
node-version: [12, 14]
9+
node-version: [10, 12, 14]
1010
steps:
1111
- name: checkout
1212
uses: actions/checkout@v2

src/util/pair-checker.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*/
1010
import assert from "assert";
1111
import { RuleHelper } from "textlint-rule-helper";
12+
const flat = (array) => {
13+
return [].concat.apply([], array);
14+
};
1215
export function checkPair(context, { left, right }) {
1316
assert(left);
1417
assert(right);
@@ -36,17 +39,17 @@ export function checkPair(context, { left, right }) {
3639
return symbolLocations;
3740
};
3841
const foundMissingPairNodes = (currentStrInParagraph) => {
39-
let matchParentheses = currentStrInParagraph
40-
.map((node) => {
42+
const matchParentheses = flat(
43+
currentStrInParagraph.map((node) => {
4144
let text = getSource(node);
4245
const leftSymbolLocations = findAllSymbolLocations(left, text);
4346
const rightSymbolLocations = left !== right ? findAllSymbolLocations(right, text) : [];
4447
const allSymbolLocations = [...leftSymbolLocations, ...rightSymbolLocations].sort(
4548
(a, b) => a.index - b.index
4649
);
47-
return allSymbolLocations.map((loc) => ({ ...loc, ...{ node } }));
50+
return allSymbolLocations.map((loc) => ({ ...loc, node }));
4851
})
49-
.flat();
52+
);
5053
if (left === right) {
5154
const isCompletedParentheses = matchParentheses.length % 2 == 0;
5255
if (isCompletedParentheses) {

0 commit comments

Comments
 (0)