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