UNPKG

8.22 kBMarkdownView Raw
1yaspeller
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
11This README is also available [in Russian](./README.ru.md).
12
13Search tool typos in the text, files and websites.
14
15Used 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>`
37Formats: `plain`, `html`, `markdown` or `auto`.<br/>
38Default: `auto`.
39
40#### `-l, --lang <value>`
41Languages: `en`, `ru` or `uk`.<br/>
42Default: `en,ru`.
43
44#### `-c, --config <path>`
45Configuration file path.
46
47#### `-e, --file-extensions <value>`
48Set file extensions to search for files in a folder.<br/>
49Example: `.md,.htm,.txt`.
50
51#### `--dictionary <file>`
52JSON file for own dictionary.
53```js
54[
55 "someword1", // someword1 = someword1 and Someword1
56 "Someword2", // Someword2 = Someword2
57 "someword3"
58]
59```
60
61Regular 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
70Examples:<br/>
71`yaspeller --dictionary my_dict.json .`<br/>
72`yaspeller --dictionary my_dict.json:my_dict2.json .`
73
74
75#### `--report <type>`
76Set type of report: `console`, `html`, `markdown` or `json`.<br/>
77Default: `console`<br/>
78Example: `console,html,custom_report.js`
79
80#### `--check-yo`
81Check the correctness of using the letter “Ё” (Yo) in Russian texts.
82
83#### `--by-words`
84Do not use a dictionary environment (context) during the scan.<br/>
85This is useful in cases where the service is transmitted to the input of a list of individual words.
86
87#### `--find-repeat-words`
88Highlight repetitions of words, consecutive. For example, `I flew to to to Cyprus`.
89
90#### `--flag-latin`
91Celebrate words, written in Latin, as erroneous.
92
93#### `--ignore-tags <tags>`
94Ignore HTML tags.<br/>
95Default: `code,kbd,object,samp,script,style,var`<br/>
96Option to formats `html` and` markdown`.
97
98#### `--ignore-text <regexp>`
99Remove the text from the scan using regular expressions.
100
101#### `--ignore-capitalization`
102Ignore the incorrect use of UPPERCASE / lowercase letters, for example, in the word `moscow`.
103
104#### `--ignore-digits`
105Ignore words with numbers, such as `avp17h4534`.
106
107#### `--ignore-latin`
108Ignore words, written in Latin, for example, `madrid`.
109
110#### `--ignore-roman-numerals`
111Ignore Roman numerals `I, II, III, ...`.
112
113#### `--ignore-uppercase`
114Ignore words written in capital letters.
115
116#### `--ignore-urls`
117Ignore Internet addresses, email addresses and filenames.
118
119#### `--max-requests <value>`
120Max count of requests in parallel.<br/>
121Default: `2`.
122
123#### `--no-colors`
124Clean output without colors.
125
126#### `--only-errors`
127Output only errors.
128
129#### `--stdin`
130Process files on <STDIN>. Default: false
131
132#### `--stdin-filename <file>`
133Specify filename to process STDIN as. Used in reports.
134
135#### `--debug`
136Debug mode.
137
138## Configuration
139`npm install yaspeller --save-dev`
140
141Add the text in `package.json` / `scripts`:<br/>
142` "yaspeller": "yaspeller .",`
143
144To run the linter:<br/>
145`npm run yaspeller`
146
147Yaspeller 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
228var re = /a-z/; // yaspeller ignore
229```
230```js
231var 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 */
240var 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
254var gulp = require('gulp'),
255 run = require('gulp-run'); // npm install gulp-run --save-dev
256
257gulp.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
269module.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)
289MIT License