Skip to content

Commit 0bc3d86

Browse files
authored
Merge pull request #3 from textlint-rule/update-2021-05-01
chore(deps): update dependencies
2 parents 645b16d + 0044ace commit 0bc3d86

File tree

9 files changed

+3140
-1961
lines changed

9 files changed

+3140
-1961
lines changed

.githooks/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
npx --no-install lint-staged

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
name: "Test on Node.js ${{ matrix.node-version }}"
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
node-version: [12, 14]
10+
steps:
11+
- name: checkout
12+
uses: actions/checkout@v2
13+
- name: setup Node.js ${{ matrix.node-version }}
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: ${{ matrix.node-version }}
17+
- name: Install
18+
run: yarn install
19+
- name: Test
20+
run: yarn test

.travis.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @textlint-rule/textlint-rule-no-invalid-control-character [![Build Status](https://travis-ci.org/textlint-rule/textlint-rule-no-invalid-control-character.svg?branch=master)](https://travis-ci.org/textlint-rule/textlint-rule-no-invalid-control-character)
1+
# @textlint-rule/textlint-rule-no-invalid-control-character [![Actions Status: test](https://github.com/textlint-rule/textlint-rule-no-invalid-control-character/workflows/test/badge.svg)](https://github.com/textlint-rule/textlint-rule-no-invalid-control-character/actions?query=workflow%3A"test")
22

33
textlint rule check invalid control character in the document.
44

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
"main": "lib/textlint-rule-no-invalid-control-character.js",
1717
"scripts": {
1818
"test": "textlint-scripts test",
19-
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
20-
"precommit": "lint-staged",
21-
"postcommit": "git reset",
2219
"prepublish": "npm run --if-present build",
2320
"build": "textlint-scripts build",
24-
"watch": "textlint-scripts build --watch"
21+
"watch": "textlint-scripts build --watch",
22+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
23+
"prepare": "git config --local core.hooksPath .githooks"
2524
},
2625
"keywords": [
2726
"textlintrule"
@@ -35,19 +34,19 @@
3534
},
3635
"homepage": "https://github.com/textlint-rule/textlint-rule-no-invalid-control-character",
3736
"devDependencies": {
38-
"husky": "^0.14.3",
39-
"lint-staged": "^6.0.0",
40-
"prettier": "^1.9.2",
41-
"textlint-scripts": "^1.4.1"
37+
"lint-staged": "^10.5.4",
38+
"prettier": "^2.2.1",
39+
"textlint-scripts": "^3.0.0"
4240
},
4341
"prettier": {
42+
"singleQuote": false,
4443
"printWidth": 120,
45-
"tabWidth": 4
44+
"tabWidth": 4,
45+
"trailingComma": "none"
4646
},
4747
"lint-staged": {
4848
"*.{js,jsx,ts,tsx,css}": [
49-
"prettier --write",
50-
"git add"
49+
"prettier --write"
5150
]
5251
},
5352
"dependencies": {

src/CONTROL_CHARACTERS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const CONTROL_CHARACTERS = [
108108
];
109109

110110
// except
111-
const INVALID_CONTROL_CHARACTERS = CONTROL_CHARACTERS.filter(CONTROL_CHARACTER => {
111+
const INVALID_CONTROL_CHARACTERS = CONTROL_CHARACTERS.filter((CONTROL_CHARACTER) => {
112112
const code = CONTROL_CHARACTER.code;
113113
return code !== "\r" && code !== "\n" && code !== "\t";
114114
});

src/textlint-rule-no-invalid-control-character.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import { CONTROL_CHARACTERS } from "./CONTROL_CHARACTERS";
99
* @param {string} str
1010
* @return {string}
1111
*/
12-
const unicodeEscape = str => {
13-
return str.replace(/./g, c => {
12+
const unicodeEscape = (str) => {
13+
return str.replace(/./g, (c) => {
1414
return `\\u${`000${c.charCodeAt(0).toString(16)}`.substr(-4)}`;
1515
});
1616
};
1717

18-
const getName = char => {
19-
const matchChar = CONTROL_CHARACTERS.find(CONTROL_CHARACTER => CONTROL_CHARACTER.code === char);
18+
const getName = (char) => {
19+
const matchChar = CONTROL_CHARACTERS.find((CONTROL_CHARACTER) => CONTROL_CHARACTER.code === char);
2020
if (!matchChar) {
2121
return "";
2222
}
@@ -37,19 +37,19 @@ const reporter = (context, options = {}) => {
3737
const allow = options.allow || DEFAULT_OPTION.allow;
3838
const checkCode = options.checkCode !== undefined ? options.checkCode : DEFAULT_OPTION.checkCode;
3939
const checkImage = options.checkImage !== undefined ? options.checkImage : DEFAULT_OPTION.checkImage;
40-
const checkNode = node => {
40+
const checkNode = (node) => {
4141
const text = getSource(node);
4242
// Ignore \r \n \t
4343
const controlCharacterPattern = /([\x00-\x08\x0B\x0C\x0E-\x1F\x7F])/g;
4444
/**
4545
* @type {Array<{match:string, sub:string[], index:number}>}
4646
*/
4747
const results = execall(controlCharacterPattern, text);
48-
results.forEach(result => {
48+
results.forEach((result) => {
4949
const index = result.index;
5050
const char = result.sub[0];
5151
// if allow the `char`, ignore it
52-
if (allow.some(allowChar => allowChar === char)) {
52+
if (allow.some((allowChar) => allowChar === char)) {
5353
return;
5454
}
5555
const name = getName(char);

test/textlint-rule-no-invalid-control-character-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const tester = new TextLintTester();
55
const rule = require("../src/textlint-rule-no-invalid-control-character");
66
import { INVALID_CONTROL_CHARACTERS } from "../src/CONTROL_CHARACTERS";
77

8-
const invalid = INVALID_CONTROL_CHARACTERS.map(character => {
8+
const invalid = INVALID_CONTROL_CHARACTERS.map((character) => {
99
return {
1010
text: `${character.code}:${character.name}`,
1111
output: `:${character.name}`,

0 commit comments

Comments
 (0)