mirror of
https://github.com/He4eT/oddsquat.git
synced 2026-05-04 20:37:22 +00:00
typograf: linter
This commit is contained in:
parent
92a9024d2f
commit
11211d436a
1 changed files with 43 additions and 0 deletions
43
typograf.js
Normal file
43
typograf.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
const Typograf = require('typograf');
|
||||
const fs = require('fs')
|
||||
|
||||
if (!process.argv[2]) {
|
||||
console.log('Usage:\n node typograf file [locale]')
|
||||
return
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
const filePath =
|
||||
`${process.cwd()}/${process.argv[2]}`
|
||||
|
||||
const fileContent =
|
||||
fs.readFileSync(filePath).toString()
|
||||
|
||||
const locale =
|
||||
process.argv[3] || 'en-US'
|
||||
|
||||
const tp = new Typograf({
|
||||
locale: [locale, 'en-US'],
|
||||
htmlEntity: {
|
||||
type: 'name',
|
||||
onlyInvisible: true
|
||||
}
|
||||
})
|
||||
|
||||
tp.disableRule('*')
|
||||
|
||||
;[
|
||||
'common/punctuation/quote',
|
||||
'common/nbsp/*',
|
||||
'ru/nbsp/*',
|
||||
'ru/dash/main'
|
||||
].forEach(rule =>
|
||||
tp.enableRule(rule))
|
||||
|
||||
void fs.writeFile(
|
||||
filePath,
|
||||
tp.execute(fileContent),
|
||||
err => err
|
||||
? console.error(err)
|
||||
: console.log(`Typografed: ${filePath}`))
|
||||
Loading…
Add table
Add a link
Reference in a new issue