1 | yaspeller
|
2 | =========
|
3 | <img align="right" width="200" src="https://raw.githubusercontent.com/hcodes/yaspeller/master/images/logo.png" />
|
4 |
|
5 | [![NPM version](https://img.shields.io/npm/v/yaspeller.svg)](https://www.npmjs.com/package/yaspeller)
|
6 | [![NPM Downloads](https://img.shields.io/npm/dm/yaspeller.svg?style=flat)](https://www.npmjs.org/package/yaspeller)
|
7 | [![Build Status](https://img.shields.io/travis/hcodes/yaspeller.svg)](https://travis-ci.org/hcodes/yaspeller)
|
8 | [![Coverage Status](https://img.shields.io/coveralls/hcodes/yaspeller.svg)](https://coveralls.io/r/hcodes/yaspeller)
|
9 | [![Dependency Status](https://img.shields.io/david/hcodes/yaspeller.svg)](https://david-dm.org/hcodes/yaspeller)
|
10 |
|
11 | This README is also available [in Russian](./README.ru.md).
|
12 |
|
13 | Search tool typos in the text, files and websites.
|
14 |
|
15 | Used API [Yandex.Speller](https://tech.yandex.ru/speller/doc/dg/concepts/About-docpage/).
|
16 |
|
17 | ![yaspeller](https://raw.githubusercontent.com/hcodes/yaspeller/master/images/cli.en.png)
|
18 |
|
19 | ## Installation
|
20 | `npm install yaspeller -g`
|
21 |
|
22 | ## Using CLI
|
23 | `yaspeller [options] <file-or-directory-or-link...>`
|
24 |
|
25 | ### Examples
|
26 | + `yaspeller README.md` — search typos in the file.
|
27 | + `yaspeller "*.md"` — node glob syntax for Windows.
|
28 | + `yaspeller -e ".md,.html,.js" ./texts/` — finding typos in files in the folder.
|
29 | + `yaspeller https://ru.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%87%D0%B0%D1%82%D0%BA%D0%B0` — search typos in the page.
|
30 | + `yaspeller http://bem.info/sitemap.xml` — search typos at the addresses specified in the sitemap.xml.
|
31 | + `echo "Hello, world!" | yaspeller --stdin`
|
32 | + `echo "Hello, world!" | yaspeller --stdin --stdin-filename hello.txt`
|
33 |
|
34 | ### Options
|
35 |
|
36 | #### `-f, --format <value>`
|
37 | Formats: `plain`, `html`, `markdown` or `auto`.<br/>
|
38 | Default: `auto`.
|
39 |
|
40 | #### `-l, --lang <value>`
|
41 | Languages: `en`, `ru` or `uk`.<br/>
|
42 | Default: `en,ru`.
|
43 |
|
44 | #### `-c, --config <path>`
|
45 | Configuration file path.
|
46 |
|
47 | #### `-e, --file-extensions <value>`
|
48 | Set file extensions to search for files in a folder.<br/>
|
49 | Example: `.md,.htm,.txt`.
|
50 |
|
51 | #### `--dictionary <file>`
|
52 | JSON file for own dictionary.
|
53 | ```js
|
54 | [
|
55 | "someword1", // someword1 = someword1 and Someword1
|
56 | "Someword2", // Someword2 = Someword2
|
57 | "someword3"
|
58 | ]
|
59 | ```
|
60 |
|
61 | Regular expressions are supported:
|
62 | ```js
|
63 | [
|
64 | "unknownword",
|
65 | "unknown(W|w)ord[12]?", // unknown(W|w)ord[12]? = unknown(W|w)ord[12]? and Unknown(W|w)ord[12]?
|
66 | "Unknown(W|w)ord[34]?" // Unknown(W|w)ord[34]? = Unknown(W|w)ord[34]?
|
67 | ]
|
68 | ```
|
69 |
|
70 | Examples:<br/>
|
71 | `yaspeller --dictionary my_dict.json .`<br/>
|
72 | `yaspeller --dictionary my_dict.json:my_dict2.json .`
|
73 |
|
74 |
|
75 | #### `--report <type>`
|
76 | Set type of report: `console`, `html`, `markdown` or `json`.<br/>
|
77 | Default: `console`<br/>
|
78 | Example: `console,html,custom_report.js`
|
79 |
|
80 | #### `--check-yo`
|
81 | Check the correctness of using the letter “Ё” (Yo) in Russian texts.
|
82 |
|
83 | #### `--by-words`
|
84 | Do not use a dictionary environment (context) during the scan.<br/>
|
85 | This is useful in cases where the service is transmitted to the input of a list of individual words.
|
86 |
|
87 | #### `--find-repeat-words`
|
88 | Highlight repetitions of words, consecutive. For example, `I flew to to to Cyprus`.
|
89 |
|
90 | #### `--flag-latin`
|
91 | Celebrate words, written in Latin, as erroneous.
|
92 |
|
93 | #### `--ignore-tags <tags>`
|
94 | Ignore HTML tags.<br/>
|
95 | Default: `code,kbd,object,samp,script,style,var`<br/>
|
96 | Option to formats `html` and` markdown`.
|
97 |
|
98 | #### `--ignore-text <regexp>`
|
99 | Remove the text from the scan using regular expressions.
|
100 |
|
101 | #### `--ignore-capitalization`
|
102 | Ignore the incorrect use of UPPERCASE / lowercase letters, for example, in the word `moscow`.
|
103 |
|
104 | #### `--ignore-digits`
|
105 | Ignore words with numbers, such as `avp17h4534`.
|
106 |
|
107 | #### `--ignore-latin`
|
108 | Ignore words, written in Latin, for example, `madrid`.
|
109 |
|
110 | #### `--ignore-roman-numerals`
|
111 | Ignore Roman numerals `I, II, III, ...`.
|
112 |
|
113 | #### `--ignore-uppercase`
|
114 | Ignore words written in capital letters.
|
115 |
|
116 | #### `--ignore-urls`
|
117 | Ignore Internet addresses, email addresses and filenames.
|
118 |
|
119 | #### `--max-requests <value>`
|
120 | Max count of requests in parallel.<br/>
|
121 | Default: `2`.
|
122 |
|
123 | #### `--no-colors`
|
124 | Clean output without colors.
|
125 |
|
126 | #### `--only-errors`
|
127 | Output only errors.
|
128 |
|
129 | #### `--stdin`
|
130 | Process files on <STDIN>. Default: false
|
131 |
|
132 | #### `--stdin-filename <file>`
|
133 | Specify filename to process STDIN as. Used in reports.
|
134 |
|
135 | #### `--debug`
|
136 | Debug mode.
|
137 |
|
138 | ## Configuration
|
139 | `npm install yaspeller --save-dev`
|
140 |
|
141 | Add the text in `package.json` / `scripts`:<br/>
|
142 | ` "yaspeller": "yaspeller .",`
|
143 |
|
144 | To run the linter:<br/>
|
145 | `npm run yaspeller`
|
146 |
|
147 | Yaspeller is configured using `.yaspellerrc` JSON file at the root of the project.
|
148 | ```JSON
|
149 | {
|
150 | "excludeFiles": [
|
151 | ".git",
|
152 | "libs",
|
153 | "node_modules",
|
154 | "yaspeller"
|
155 | ],
|
156 | "lang": "ru",
|
157 | "fileExtensions": [
|
158 | ".md",
|
159 | ".js",
|
160 | ".css"
|
161 | ],
|
162 | "dictionary": [
|
163 | "someword1"
|
164 | ]
|
165 | }
|
166 | ```
|
167 |
|
168 | **Advanced example:**
|
169 | ```js
|
170 | {
|
171 | "excludeFiles": [
|
172 | ".git",
|
173 | "yaspeller",
|
174 | "node_modules",
|
175 | "libs"
|
176 | ],
|
177 | "format": "html",
|
178 | "lang": "en",
|
179 | "fileExtensions": [
|
180 | ".md",
|
181 | ".js",
|
182 | ".css"
|
183 | ],
|
184 | "report": ["console", "html"],
|
185 | "dictionary": [
|
186 | // JSON comments
|
187 | "someword1", // someword1 = someword1 and Someword1
|
188 | "Someword2", // Someword2 = Someword2
|
189 | "some(w|W)ord[23]", // some(w|W)ord[23] = some(w|W)ord[23] and Some(w|W)ord[23]
|
190 | "Some(w|W)ord" // Some(w|W)ord = Some(w|W)ord
|
191 | ],
|
192 | "ignoreText": [
|
193 | "<php\?[^]*?\?>", // Shortly
|
194 | ["<php\?[^]*?\?>", "g"] // Longly
|
195 | ],
|
196 | "ignoreTags": ["code", "script"],
|
197 | "ignoreUrls": true,
|
198 | "findRepeatWords": true,
|
199 | "maxRequests": 5
|
200 | }
|
201 | ```
|
202 |
|
203 | | Property | Type | Details |
|
204 | |----------|------|---------|
|
205 | | `format` | `String` | [`--format`](#-f---format-value) |
|
206 | | `lang` | `String` | [`--lang`](#-l---lang-value) |
|
207 | | `excludeFiles` | `Array` | |
|
208 | | `fileExtensions` | `Array` | [`--file-extension`](#--file-extensions-value) |
|
209 | | `dictionary` | `Array` | [`--dictionary`](#--dictionary-file) |
|
210 | | `report` | `Array` | [`--report`](#--report-type) |
|
211 | | `checkYo` | `Boolean` | [`--check-yo`](#--check-yo) |
|
212 | | `byWords` | `Boolean` | [`--by-words`](#--by-words) |
|
213 | | `findRepeatWords` | `Boolean` | [`--find-repeat-words`](#--find-repeat-words) |
|
214 | | `flagLatin` | `Boolean` | [`--flag-latin`](#--flag-latin) |
|
215 | | `ignoreTags` | `Array` | [`--ignore-tags`](#--ignore-tags-tags) |
|
216 | | `ignoreText` | `Array` | [`--ignore-text`](#--ignore-text-regexp) |
|
217 | | `ignoreCapitalization` | `Boolean` | [`--ignore-capitalization`](#--ignore-capitalization) |
|
218 | | `ignoreDigits` | `Boolean` | [`--ignore-digits`](#--ignore-digits) |
|
219 | | `ignoreLatin` | `Boolean` | [`--ignore-latin`](#--ignore-latin) |
|
220 | | `ignoreRomanNumerals` | `Boolean` | [`--ignore-roman-numerals`](#--ignore-roman-numerals) |
|
221 | | `ignoreUppercase` | `Boolean` | [`--ignore-uppercase`](#--ignore-uppercase) |
|
222 | | `ignoreUrls` | `Boolean` | [`--ignore-urls`](#--ignore-urls) |
|
223 | | `maxRequests` | `Number` | [`--max-requests`](#--max-requests-value) |
|
224 |
|
225 | ## Ignore text from checking
|
226 | ### Ignore a line
|
227 | ```js
|
228 | var re = /a-z/; // yaspeller ignore
|
229 | ```
|
230 | ```js
|
231 | var re = /a-z/; /* yaspeller ignore */
|
232 | ```
|
233 | ```html
|
234 | <span>a-z</span> <!-- yaspeller ignore -->
|
235 | ```
|
236 |
|
237 | ### Ignore a block
|
238 | ```js
|
239 | /* yaspeller ignore:start */
|
240 | var reUpper = /A-Z/,
|
241 | reLower = /a-z/;
|
242 | /* yaspeller ignore:end */
|
243 | ```
|
244 |
|
245 | ```html
|
246 | <!-- yaspeller ignore:start -->
|
247 | <span>A-Z</span>
|
248 | <div>a-z</div>
|
249 | <!-- yaspeller ignore:end -->
|
250 | ```
|
251 |
|
252 | ## [Gulp](http://gulpjs.com) plugin
|
253 | ```js
|
254 | var gulp = require('gulp'),
|
255 | run = require('gulp-run'); // npm install gulp-run --save-dev
|
256 |
|
257 | gulp.task('yaspeller', function (cb) {
|
258 | run('./node_modules/.bin/yaspeller .').exec()
|
259 | .on('error', function (err) {
|
260 | console.error(err.message);
|
261 | cb();
|
262 | })
|
263 | .on('finish', cb);
|
264 | });
|
265 | ```
|
266 |
|
267 | ## [Grunt](http://gruntjs.com) plugin
|
268 | ```js
|
269 | module.exports = function(grunt) {
|
270 | grunt.loadNpmTasks('grunt-shell'); // npm install grunt-shell --save-dev
|
271 | grunt.initConfig({
|
272 | shell: {
|
273 | yaspeller: {
|
274 | options: {stderr: false},
|
275 | command: './node_modules/.bin/yaspeller .'
|
276 | }
|
277 | }
|
278 | });
|
279 | grunt.registerTask('lint', ['shell:yaspeller']);
|
280 | };
|
281 | ```
|
282 |
|
283 | ## [Restrictions API Yandex.Speller](http://legal.yandex.ru/speller_api/)
|
284 |
|
285 | ## Links
|
286 | - [Yaspeller for CI](https://github.com/ai/yaspeller-ci)
|
287 |
|
288 | ## [License](./LICENSE.md)
|
289 | MIT License
|