Skip to content

Commit

Permalink
style: apply prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed May 1, 2021
1 parent acd0daf commit 0044ace
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/CONTROL_CHARACTERS.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const CONTROL_CHARACTERS = [
];

// except
const INVALID_CONTROL_CHARACTERS = CONTROL_CHARACTERS.filter(CONTROL_CHARACTER => {
const INVALID_CONTROL_CHARACTERS = CONTROL_CHARACTERS.filter((CONTROL_CHARACTER) => {
const code = CONTROL_CHARACTER.code;
return code !== "\r" && code !== "\n" && code !== "\t";
});
Expand Down
14 changes: 7 additions & 7 deletions src/textlint-rule-no-invalid-control-character.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { CONTROL_CHARACTERS } from "./CONTROL_CHARACTERS";
* @param {string} str
* @return {string}
*/
const unicodeEscape = str => {
return str.replace(/./g, c => {
const unicodeEscape = (str) => {
return str.replace(/./g, (c) => {
return `\\u${`000${c.charCodeAt(0).toString(16)}`.substr(-4)}`;
});
};

const getName = char => {
const matchChar = CONTROL_CHARACTERS.find(CONTROL_CHARACTER => CONTROL_CHARACTER.code === char);
const getName = (char) => {
const matchChar = CONTROL_CHARACTERS.find((CONTROL_CHARACTER) => CONTROL_CHARACTER.code === char);
if (!matchChar) {
return "";
}
Expand All @@ -37,19 +37,19 @@ const reporter = (context, options = {}) => {
const allow = options.allow || DEFAULT_OPTION.allow;
const checkCode = options.checkCode !== undefined ? options.checkCode : DEFAULT_OPTION.checkCode;
const checkImage = options.checkImage !== undefined ? options.checkImage : DEFAULT_OPTION.checkImage;
const checkNode = node => {
const checkNode = (node) => {
const text = getSource(node);
// Ignore \r \n \t
const controlCharacterPattern = /([\x00-\x08\x0B\x0C\x0E-\x1F\x7F])/g;
/**
* @type {Array<{match:string, sub:string[], index:number}>}
*/
const results = execall(controlCharacterPattern, text);
results.forEach(result => {
results.forEach((result) => {
const index = result.index;
const char = result.sub[0];
// if allow the `char`, ignore it
if (allow.some(allowChar => allowChar === char)) {
if (allow.some((allowChar) => allowChar === char)) {
return;
}
const name = getName(char);
Expand Down
2 changes: 1 addition & 1 deletion test/textlint-rule-no-invalid-control-character-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const tester = new TextLintTester();
const rule = require("../src/textlint-rule-no-invalid-control-character");
import { INVALID_CONTROL_CHARACTERS } from "../src/CONTROL_CHARACTERS";

const invalid = INVALID_CONTROL_CHARACTERS.map(character => {
const invalid = INVALID_CONTROL_CHARACTERS.map((character) => {
return {
text: `${character.code}:${character.name}`,
output: `:${character.name}`,
Expand Down

0 comments on commit 0044ace

Please sign in to comment.