Skip to content

Commit 430eda6

Browse files
committed
initial commit
0 parents  commit 430eda6

9 files changed

+3805
-0
lines changed

.gitignore

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
2+
3+
# Logs
4+
logs
5+
*.log
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19+
.grunt
20+
21+
# node-waf configuration
22+
.lock-wscript
23+
24+
# Compiled binary addons (http://nodejs.org/api/addons.html)
25+
build/Release
26+
27+
# Dependency directory
28+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
29+
node_modules
30+
31+
# Debug log from npm
32+
npm-debug.log
33+
34+
35+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
36+
37+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
38+
39+
*.iml
40+
41+
## Directory-based project format:
42+
.idea/
43+
# if you remove the above rule, at least ignore the following:
44+
45+
# User-specific stuff:
46+
# .idea/workspace.xml
47+
# .idea/tasks.xml
48+
# .idea/dictionaries
49+
50+
# Sensitive or high-churn files:
51+
# .idea/dataSources.ids
52+
# .idea/dataSources.xml
53+
# .idea/sqlDataSources.xml
54+
# .idea/dynamic.xml
55+
# .idea/uiDesigner.xml
56+
57+
# Gradle:
58+
# .idea/gradle.xml
59+
# .idea/libraries
60+
61+
# Mongo Explorer plugin:
62+
# .idea/mongoSettings.xml
63+
64+
## File-based project format:
65+
*.ipr
66+
*.iws
67+
68+
## Plugin-specific files:
69+
70+
# IntelliJ
71+
out/
72+
73+
# mpeltonen/sbt-idea plugin
74+
.idea_modules/
75+
76+
# JIRA plugin
77+
atlassian-ide-plugin.xml
78+
79+
# Crashlytics plugin (for Android Studio and IntelliJ)
80+
com_crashlytics_export_strings.xml
81+
crashlytics.properties
82+
crashlytics-build.properties
83+
84+
85+
/lib

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sudo: false
2+
language: node_js
3+
node_js: "stable"

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 azu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# textlint-rule-no-invalid-control-character
2+
3+
textlint rule check invalid control character in the document.
4+
5+
## Allow
6+
7+
- `\r`
8+
- `\n`
9+
- `\t`
10+
11+
## Now Allow
12+
13+
Other [control character](https://en.wikipedia.org/wiki/Control_character "Control character").
14+
15+
For example, following control character is not allowed.
16+
17+
- `\t`
18+
- `\u0019`
19+
20+
## Install
21+
22+
Install with [npm](https://www.npmjs.com/):
23+
24+
npm install textlint-rule-no-invalid-control-character
25+
26+
## Usage
27+
28+
Via `.textlintrc`(Recommended)
29+
30+
```json
31+
{
32+
"rules": {
33+
"no-invalid-control-character": true
34+
}
35+
}
36+
```
37+
38+
Via CLI
39+
40+
```
41+
textlint --rule no-invalid-control-character README.md
42+
```
43+
44+
## Options
45+
46+
- `allow`: `string[]`
47+
- Define allow control characters
48+
49+
```json
50+
{
51+
"rules": {
52+
"no-invalid-control-character": {
53+
"allow": [
54+
"\v"
55+
]
56+
}
57+
}
58+
}
59+
```
60+
61+
## Reference
62+
63+
- [JavaScript character escape sequences · Mathias Bynens](https://mathiasbynens.be/notes/javascript-escapes "JavaScript character escape sequences · Mathias Bynens")
64+
65+
## Changelog
66+
67+
See [Releases page](https://github.com/textlint-rule/textlint-rule-no-invalid-control-character/releases).
68+
69+
## Running tests
70+
71+
Install devDependencies and Run `npm test`:
72+
73+
npm i -d && npm test
74+
75+
## Contributing
76+
77+
Pull requests and stars are always welcome.
78+
79+
For bugs and feature requests, [please create an issue](https://github.com/textlint-rule/textlint-rule-no-invalid-control-character/issues).
80+
81+
1. Fork it!
82+
2. Create your feature branch: `git checkout -b my-new-feature`
83+
3. Commit your changes: `git commit -am 'Add some feature'`
84+
4. Push to the branch: `git push origin my-new-feature`
85+
5. Submit a pull request :D
86+
87+
## Author
88+
89+
- [github/azu](https://github.com/azu)
90+
- [twitter/azu_re](https://twitter.com/azu_re)
91+
92+
## License
93+
94+
MIT © azu

package.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"directories": {
3+
"lib": "lib",
4+
"test": "test"
5+
},
6+
"author": "azu",
7+
"license": "MIT",
8+
"files": [
9+
"bin/",
10+
"lib/",
11+
"src/"
12+
],
13+
"name": "textlint-rule-no-invalid-control-character",
14+
"version": "1.0.0",
15+
"description": "textlint rule check unnessary control character in the document.",
16+
"main": "lib/textlint-rule-no-invalid-control-character.js",
17+
"scripts": {
18+
"test": "textlint-scripts test",
19+
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
20+
"precommit": "lint-staged",
21+
"postcommit": "git reset",
22+
"prepublish": "npm run --if-present build",
23+
"build": "textlint-scripts build",
24+
"watch": "textlint-scripts build --watch"
25+
},
26+
"keywords": [
27+
"textlintrule"
28+
],
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/textlint-rule/textlint-rule-no-invalid-control-character.git"
32+
},
33+
"bugs": {
34+
"url": "https://github.com/textlint-rule/textlint-rule-no-invalid-control-character/issues"
35+
},
36+
"homepage": "https://github.com/textlint-rule/textlint-rule-no-invalid-control-character",
37+
"devDependencies": {
38+
"husky": "^0.14.3",
39+
"lint-staged": "^6.0.0",
40+
"prettier": "^1.9.2",
41+
"textlint-scripts": "^1.4.1"
42+
},
43+
"prettier": {
44+
"printWidth": 120,
45+
"tabWidth": 4
46+
},
47+
"lint-staged": {
48+
"*.{js,jsx,ts,tsx,css}": [
49+
"prettier --write",
50+
"git add"
51+
]
52+
},
53+
"dependencies": {
54+
"execall": "^1.0.0"
55+
}
56+
}

src/CONTROL_CHARACTERS.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// MIT © 2017 azu
2+
"use strict";
3+
const CONTROL_CHARACTERS = [
4+
{
5+
code: "\u0001",
6+
name: "START OF HEADING"
7+
},
8+
{
9+
code: "\u0002",
10+
name: "START OF TEXT"
11+
},
12+
{
13+
code: "\u0003",
14+
name: "END OF TEXT"
15+
},
16+
{
17+
code: "\u0004",
18+
name: "END OF TRANSMISSION"
19+
},
20+
{
21+
code: "\u0005",
22+
name: "ENQUIRY"
23+
},
24+
{
25+
code: "\u0006",
26+
name: "ACKNOWLEDGE"
27+
},
28+
{
29+
code: "\u0007",
30+
name: "BELL"
31+
},
32+
{
33+
code: "\u0008",
34+
name: "BACKSPACE"
35+
},
36+
{
37+
code: "\u0009",
38+
name: "CHARACTER TABULATION"
39+
},
40+
{
41+
code: "\u000A",
42+
name: "LINE FEED (LF)"
43+
},
44+
{
45+
code: "\u000B",
46+
name: "LINE TABULATION"
47+
},
48+
{
49+
code: "\u000C",
50+
name: "FORM FEED (FF)"
51+
},
52+
{
53+
code: "\u000D",
54+
name: "CARRIAGE RETURN (CR)"
55+
},
56+
{
57+
code: "\u000E",
58+
name: "SHIFT OUT"
59+
},
60+
{
61+
code: "\u000F",
62+
name: "SHIFT IN"
63+
},
64+
{
65+
code: "\u0010",
66+
name: "DATA LINK ESCAPE"
67+
},
68+
{
69+
code: "\u0011",
70+
name: "DEVICE CONTROL ONE"
71+
},
72+
{
73+
code: "\u0012",
74+
name: "DEVICE CONTROL TWO"
75+
},
76+
{
77+
code: "\u0013",
78+
name: "DEVICE CONTROL THREE"
79+
},
80+
{
81+
code: "\u0014",
82+
name: "DEVICE CONTROL FOUR"
83+
},
84+
{
85+
code: "\u0015",
86+
name: "NEGATIVE ACKNOWLEDGE"
87+
},
88+
{
89+
code: "\u0016",
90+
name: "SYNCHRONOUS IDLE"
91+
},
92+
{
93+
code: "\u0017",
94+
name: "END OF TRANSMISSION BLOCK"
95+
},
96+
{
97+
code: "\u0018",
98+
name: "CANCEL"
99+
},
100+
{
101+
code: "\u0019",
102+
name: "END OF MEDIUM"
103+
},
104+
{
105+
code: "\u001A",
106+
name: "SUBSTITUTE"
107+
}
108+
];
109+
110+
// except
111+
const INVALID_CONTROL_CHARACTERS = CONTROL_CHARACTERS.filter(CONTROL_CHARACTER => {
112+
const code = CONTROL_CHARACTER.code;
113+
return code !== "\r" && code !== "\n" && code !== "\t";
114+
});
115+
export { INVALID_CONTROL_CHARACTERS, CONTROL_CHARACTERS };

0 commit comments

Comments
 (0)