Created
April 12, 2016 12:05
-
-
Save jrencz/becd1befac3f14b53039e0361087794c to your computer and use it in GitHub Desktop.
Useful set of words for eslint-plugin-spellcheck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"plugins": [ | |
"spellcheck" | |
], | |
"rules": | |
// Spellcheck | |
// | |
"spellcheck/spell-checker": ["warn", { | |
"skipWords": [ | |
// own names | |
// gulp plugin names, node package names etc. | |
// | |
"analytics", | |
"atlassian", | |
"autoprefixer", | |
"cordova", | |
"cssnano", | |
"del", // gulp plugin name | |
"eslint", | |
"github", | |
"gmap", | |
"gmapgoogle", // in uiGmapgoogle package name | |
"gulpfile", | |
"htmlmin", // gulp plugin name | |
"ionics", | |
"ios", | |
"iPad", | |
"iPads", | |
"iPod", | |
"iPods", | |
"istanbul", | |
"lazypipe", | |
"localforage", | |
"lodash", | |
"ng", | |
"segmentio", | |
"shelljs", | |
"splashscreen", // a name of cordova plugin | |
"streamqueue", // node package | |
"touchspin", | |
"uglify", | |
"webdriver", | |
//file extensions | |
"css", | |
"html", | |
"html", | |
"js", | |
"jsonp", | |
"md", | |
"png", | |
"scss", | |
"tpl", | |
// programming gibberish | |
"addon", | |
"addons", | |
"arg", | |
"args", | |
"asc", | |
"async", | |
"atan", | |
"attr", | |
"attrs", | |
"auth", | |
"autocomplete", | |
"autoincrement", | |
"basename", | |
"bcrypt", | |
"broadcasted", | |
"chainable", | |
"cli", | |
"clickability", | |
"concat", | |
"conf", | |
"config", | |
"configs", | |
"const", | |
"ctrl", | |
"customizer", | |
"deregister", | |
"deregistered", | |
"deregistering", | |
"deregistrator", | |
"deregistrators", | |
"desc", | |
"deserialization", | |
"deserialize", | |
"deserialized", | |
"deserializes", | |
"dest", | |
"destructuring", | |
"dev", | |
"dir", | |
"dirname", | |
"dragend", | |
"dragstart", | |
"el", | |
"elem", | |
"elems", | |
"env", | |
"envs", | |
"falsy", | |
"filename", | |
"fn", | |
"fns", | |
"formatters", | |
"fulfillable", | |
"fullscreen", | |
"getter", | |
"hostname", | |
"http", | |
"https", | |
"img", | |
"init", | |
"initializer", | |
"injectable", | |
"instantiation", | |
"iterable", | |
"iteree", | |
"laquo", | |
"lib", | |
"libs", | |
"lifecycle", | |
"linter", | |
"linters", | |
"metadata", | |
"minified", | |
"mixin", | |
"mixins", | |
"multiselect", | |
"nav", | |
"noop", | |
"param", | |
"params", | |
"parsers", | |
"polyfill", | |
"polyfilled", | |
"polyfills", | |
"popup", | |
"prefetch", | |
"preload", | |
"preloaded", | |
"preprocess", | |
"preprocessor", | |
"preprocessors", | |
"preselected", | |
"programmatically", | |
"proto", | |
"px", | |
"raquo", | |
"reconfiguring", | |
"refetch", | |
"refetching", | |
"ret", | |
"rethrows", | |
"rgba", | |
"runtime", | |
"sanitization", | |
"serialize", | |
"serializer", | |
"sha", | |
"shorthands", | |
"sourcemap", | |
"sourcemaps", | |
"sqrt", | |
"src", | |
"stacktrace", | |
"subdirectories", | |
"subdirectory", | |
"subunit", | |
"subunits", | |
"superset", | |
"thanables", | |
"thenable", | |
"timeline", | |
"timestamp", | |
"tmp", | |
"todo", | |
"truthy", | |
"typedef", | |
"ui", | |
"uncomment", | |
"unfulfillable", | |
"ungroup", | |
"ungrouped", | |
"unhandled", | |
"uniq", | |
"unwatch", | |
"util", | |
"utils", | |
"uuid", | |
"validator", | |
"viewport", | |
"webserver", | |
"whitelist", | |
"whitelisted", | |
"www", | |
"zindex", | |
"api", | |
"backend", | |
"iso", | |
"utc", | |
// names provided by external source code dependencies or standard | |
// library | |
// | |
"clusterer", // in Google Map options | |
"cwd", // in node api | |
"eq", // in jQuery#eq | |
"expr", // in uiRouter stateRef.paramExpr | |
"extname", // gulp-plugin-rename config option | |
"lcov", // name of line coverage format | |
"memoize", // in _.memoize | |
"nobrowser", // ionic cli flag | |
"prev", // in jQuery#prev | |
"roadmap", // https://developers.google.com/maps/documentation/javascript/maptypes | |
"scrollwheel", // in Google Map options | |
"sref", // in [ui-sref] | |
"starttag", // a config name in gulp-plugin-inject | |
"stringify", // in JSON.stringify | |
"stylers", // https://developers.google.com/maps/documentation/javascript/styling#overview | |
"substr", // in String#substr | |
"thru", // in _.thru | |
"transclude", // in angular directive | |
"transclusion", // in angular directive | |
"unshift", // in Array#unshift | |
// Moment.js date format strings | |
"YYYY", | |
"YY", | |
"Y", | |
"MM", | |
"MMM", | |
"MMMM", | |
"D", | |
"DD", | |
"Do", | |
"DDD", | |
"DDDD", | |
"HH", | |
"MM", | |
"gg", | |
"gggg", | |
"ww", | |
"ss", | |
"ss", | |
"zz", | |
// Lorem ipsum 1st sentence | |
"Lorem", | |
"ipsum", | |
"dolor", | |
"sit", | |
"amet", | |
"consectetur", | |
"adipiscing", | |
"elit", | |
// Related to Google Maps | |
// | |
"coords", // South-east etc. | |
"geocode", | |
"geocoder", | |
"geocoding", | |
"geolocate", | |
"geolocated", | |
"geolocation", | |
"geoposition", | |
"lat", | |
"lng", | |
"ne", | |
"nw", | |
"se", | |
"sublocality", | |
"sw", | |
// various | |
"ness", // -ness suffix | |
"pre", // pre- prefix | |
"Na", // in NaN - NaN is mishandled by the plugin | |
// tests | |
"foo", | |
"bar", | |
"baz", | |
"quux" | |
], | |
"skipIfMatch": [ | |
"http(s)?://[^s]*", | |
// Auxiliary werbs | |
// see: https://github.com/aotaduy/eslint-plugin-spellcheck/issues/7 | |
"(\\s|^)\\w+'t(\\s|$)", | |
// ordinals | |
// https://github.com/aotaduy/eslint-plugin-spellcheck/issues/8 | |
"(\\s|^|\\w+)\\d+(st|nd|rd|th)(\\s|[A-Z][a-zA-Z]+|$)", | |
// pre/post prefixes both in kebab case and camel case | |
"(\\s|^)(pre|post)([-\\w]|[A-Z])[a-zA-Z]+(\\s|$)", | |
// mimetypes | |
"^[-\\w]+\/[-\\w\\.]+$", | |
// xml tags | |
"<(?:\/)?[\\w-]+>", | |
// cryptographic octal hashes | |
"^[0-9a-f]{5,999}$", | |
// hex colors | |
"^#[0-9a-f]{3,6}$" | |
] | |
}] | |
} | |
} |
my result code is:
.eslintrc.js
const npmLS = require("npmls")();
const allESLintRules = require("all-eslint-rules")({
useEslintrc: false,
});
const { getDictionary } = require("./config/dictionary")
const dictionary = getDictionary({
nodeModulesList: npmLS,
allESLintRules: allESLintRules,
});
module.exports = {
...
plugins: [
...
"spellcheck"
],
rules: {
...
"spellcheck/spell-checker": ["warn", {
...
skipWords: dictionary,
}]
},
}
config/dictionary.js
/* eslint-disable import/no-extraneous-dependencies */
const fs = require("fs");
const path = require("path");
const builtinModules = require("builtin-modules");
// https://gist.github.com/jrencz/becd1befac3f14b53039e0361087794c#gistcomment-3430019
const nodeModules = list => Array.from(new Set(
list || []
// Handle NPM scoped packages
// See https://github.com/charlike/npmls/issues/3
.map(name => name.replace(/^@/, ""))
// Turns names delimited with various delimiters into words
.reduce(
(collector, name) => collector.concat(...name.split(/[_\-/.]/)),
[]
)
// Handle digit-ending words: foo3 -> foo
.map(name => name.replace(/(\w+)\d+$/, "$1"))
));
const whitelist = fs.readFileSync(path.join(__dirname, "./spell.dict"))
.toString()
.split("\n")
.map(word => word.replace(/\/\/.*$/, "")) // So you can add comments to the words
.map(word => word.trim()) // Remove any leading/trailing whitespace
.filter(word => word); // Remove any empty lines
const getDictionary = ({ nodeModulesList, allESLintRules }) => [
...nodeModules(nodeModulesList) || [],
...builtinModules || [],
...allESLintRules || [],
...whitelist || [],
];
// console.log(123123, { getDictionary });
module.exports = {
getDictionary,
};
`config/spell.dict`
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
accept
accept-charset
accesskey
action
align
allow
alt
async
autocapitalize
autocomplete
autofocus
autoplay
background
bgcolor
border
buffered
capture
challenge
charset
checked
cite
class
code
codebase
color
cols
colspan
content
contenteditable
contextmenu
controls
coords
crossorigin
csp
data
data-*
datetime
decoding
default
defer
dir
dirname
disabled
download
draggable
dropzone
enctype
enterkeyhint
for
form
formaction
formenctype
formmethod
formnovalidate
formtarget
headers
height
hidden
high
href
hreflang
http-equiv
icon
id
importance
integrity
intrinsicsize
inputmode
ismap
itemprop
keytype
kind
label
lang
language
loading
list
loop
low
manifest
max
maxlength
minlength
media
method
min
multiple
muted
name
novalidate
open
optimum
pattern
ping
placeholder
poster
preload
radiogroup
readonly
referrerpolicy
rel
required
reversed
rows
rowspan
sandbox
scope
scoped
selected
shape
size
sizes
slot
span
spellcheck
src
srcdoc
srclang
srcset
start
step
style
summary
tabindex
target
title
translate
type
usemap
value
width
wrap
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
base
head
link
meta
style
title
address
article
aside
footer
header
h1
hgroup
main
nav
section
blockquote
dd
dir
div
dl
dt
figcaption
figure
hr
li
main
ol
p
pre
ul
a
abbr
b
bdi
bdo
br
cite
code
data
dfn
em
i
kbd
mark
q
rb
rp
rt
rtc
ruby
s
samp
small
span
strong
sub
sup
time
tt
u
var
wbr
area
audio
img
map
track
video
applet
embed
iframe
noembed
object
param
picture
source
canvas
noscript
script
del
ins
caption
col
colgroup
table
tbody
td
tfoot
th
thead
tr
button
datalist
fieldset
form
input
label
legend
meter
optgroup
option
output
progress
select
textarea
details
dialog
menu
menuitem
summary
content
element
shadow
slot
template
acronym
applet
basefont
bgsound
big
blink
center
command
content
dir
element
font
frame
frameset
image
isindex
keygen
listing
marquee
menuitem
multicol
nextid
nobr
noembed
noframes
plaintext
shadow
spacer
strike
tt
xmp
getOpenedSuggest
jsonvisible
Next thing I want to add all Material UI components names because spellchecker dictionary does not have (seems like common) words like "snackbar", "tooltip" or "dropdown".
Okay is was easy as Object.keys(require("@material-ui/core"))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, very useful code! We need to add this to spellcheck eslint plugin somehow