i18n-lint-plugin
v0.2.3
Published
An i18n lint plugin of webpack
Downloads
2
Readme
i18n-lint-plugin
Install
$ yarn add i18n-lint-plugin -D
# or
$ npm install i18n-lint-plugin -D
Configuration
- vue.config.js
const I18nLintPlugin = require('i18n-lint-plugin')
module.exports = {
configureWebpack: {
plugins: [
new I18nLintPlugin()
]
}
}
- add
.i18nlintrc.js
to the root dir of your project
module.exports = {
// report level, exits on 'errors'
report: 'warnings',
rules: [{
// report: 'errors',
glob: 'src/**/*.{js,vue}',
test: /[\u4e00-\u9fa5]+/
// or check with function
// test: (line, filePath, lines, lineNo) => {
// return line.match(/[\u4e00-\u9fa5]+/)?.index
// }
}, {
glob: '**/*.json',
test: /[\u4e00-\u9fa5]+/
}],
// ignore path, use array depends
ignores: 'src/views/components/**/*',
// static path to lint
staticPath: 'dataview/*.json',
// file types to lint, defaults are js,jsx,json,vue,jade,ejs
lintSuffix: ['js', 'vue', 'coffee', 'ts'],
// remove comments before lint
ignoreComment: true,
// remove console before lint
ignoreConsole: true
}
Git Hooks
Execute i18n-lint before git commit.
- install
husky
$ yarn add [email protected] -D
- add husky config to
package.json
"husky": {
"hooks": {
"pre-commit": "i18n-lint"
}
}