Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zhlint

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zhlint - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

README.zh-CN.md

31

bin/index.js

@@ -17,6 +17,23 @@ #!/usr/bin/env node

Usage:
zhlint <file-pattern>
zhlint <file-pattern> --fix
zhlint <input-file-path> --output=<output-file-path>
zhlint --help
zhlint <file-pattern>[, ...]
zhlint <file-pattern>[, ...] --fix
zhlint --fix <file-pattern>
zhlint --fix=<file-pattern>
zhlint <input-file-path> --output <output-file-path>
zhlint <input-file-path> --output=<output-file-path>
zhlint --help
Examples:
zhlint foo.md
zhlint foo.md --fix
zhlint *.md
zhlint *.md --fix
zhlint foo.md bar.md
zhlint foo.md bar.md --fix
zhlint --fix foo.md
zhlint --fix=foo.md
zhlint --fix *.md
zhlint --fix=*.md
zhlint foo.md --output dest.md
zhlint foo.md --output=dest.md
`.trim())

@@ -29,2 +46,8 @@

// To support other CLI conventions like `lint-staged`.
if (typeof argv.fix === 'string') {
argv._.push(argv.fix)
argv.fix = true
}
if (argv._ && argv._.length) {

@@ -31,0 +54,0 @@ const [filePattern] = [...argv._]

2

package.json
{
"name": "zhlint",
"version": "0.2.2",
"version": "0.3.0",
"description": "A linting tool for Chinese language.",

@@ -5,0 +5,0 @@ "bin": {

@@ -104,3 +104,3 @@ # <img src="./logo.svg" style="vertical-align: middle;"> zhlint

- `message`: The description of this validation in natural language.
- `Options`: `{ rules?: string[], hyperParse?: string[], ignoredCases?: IgnoredCase[], logger?: Console }`: Customize your own rules and
- `Options`: `{ rules?: string[], hyperParse?: string[], ignoredCases?: IgnoredCase[], logger?: Console }`: Customize your own rules and other advanced options.
- `rules`: customize the linting rules by their names, could be `undefined` which means just use the default [rules](https://github.com/Jinjiang/zhlint/tree/master/src/rules).

@@ -107,0 +107,0 @@ - `hyperParse`: customize the hyper parser by their names, could be `undefined` which means just use default [ignored cases parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/ignore.js), [Markdown parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/md.js) and the [Hexo tags parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/hexo.js).

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ const { defaultLogger } = require('./logger')

@@ -5,4 +5,4 @@ const run = require('./run')

// API
// - run(file, str, options): { result, validations, ignoredTokens }
// - report(result[{ file, str, validations, ignoredTokens }], logger?)
// - run(str, options): { origin, result, validations, disabled }
// - report(result[{ file, origin, validations, disabled }], logger?)

@@ -9,0 +9,0 @@ module.exports = {

@@ -0,0 +0,0 @@ const isInRange = (start, end, mark) => {

@@ -58,7 +58,14 @@ const chalk = require('chalk')

let errorCount = 0
const invalidFiles = resultList.map(({ file, origin, validations }) => {
reportSingleResult(file, origin, validations, logger)
errorCount += validations.length
return validations.length ? file : ''
}).filter(Boolean)
resultList
.filter(({ file, disabled }) => {
if (disabled) {
logger.log(`${chalk.blue.bgWhite(file || '')}${file ? ':' : ''} disabled`)
return false
}
return true
}).map(({ file, origin, validations }) => {
reportSingleResult(file, origin, validations, logger)
errorCount += validations.length
return validations.length ? file : ''
}).filter(Boolean)
if (errorCount) {

@@ -80,2 +87,2 @@ logger.error('Invalid files:')

report
}
}

@@ -0,0 +0,0 @@ const checkCharType = require('./check-char-type')

// {% x y %}z{% endx %}
// \{\% ([^ ]+?) [^\%]+?\%\} ([^ ]+?) [^\%]*?
// \{\% ([^ ]+?) [^\%]*?\%\} ([^ ]+?) [^\%]*?
// (?:\n|\{(?!\%)|[^\{])*? \n \{(?!\%) [^\{]

@@ -9,13 +9,13 @@ // \{\% end(?:\1) \%\}

data.content = data.content.replace(matcher, (raw, name, index ) => {
const { length } = raw
data.ignoredByParsers.push({
name,
index,
length,
raw,
meta: `hexo-${name}`
})
return '@'.repeat(length)
const { length } = raw
data.ignoredByParsers.push({
name,
index,
length,
raw,
meta: `hexo-${name}`
})
return '@'.repeat(length)
})
return data
}

@@ -23,3 +23,3 @@ const ignoredCaseMatcher = /^(?:(?<prefix>.+?)\-,)?(?<textStart>.+?)(?:,(?<textEnd>.+?))?(?:,\-(?<suffix>.+?))?$/

const { ignoredByRules, raw } = data
const matcher = /<\!\-\-\szhlint\signore\:\s*(.+?)\s*\-\-\>/g
const matcher = /<\!\-\-\s*zhlint\s*ignore\:\s*(.+?)\s*\-\-\>/g
let result

@@ -26,0 +26,0 @@ while ((result = matcher.exec(raw)) !== null) {

@@ -0,0 +0,0 @@ const unified = require('unified')

@@ -0,0 +0,0 @@ const travel = require('./travel')

@@ -0,0 +0,0 @@ const replaceBlocks = (str, blocks) => {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const { removeValidation } = require('./util')

@@ -41,7 +41,9 @@ const {

) {
const nonMarkTokenBefore = findNonMarkTokenBefore(group, contentTokenBefore)
const nonMarkTokenAfter = findNonMarkTokenAfter(group, contentTokenAfter)
if (
token.content === '/' &&
(
findNonMarkTokenBefore(group, contentTokenBefore).content === '/' ||
findNonMarkTokenAfter(group, contentTokenAfter).content === '/'
nonMarkTokenBefore && nonMarkTokenBefore.content === '/' ||
nonMarkTokenAfter && nonMarkTokenAfter.content === '/'
)

@@ -54,4 +56,4 @@ ) {

(
findNonMarkTokenBefore(group, contentTokenBefore).content === '-' ||
findNonMarkTokenAfter(group, contentTokenAfter).content === '-'
nonMarkTokenBefore && nonMarkTokenBefore.content === '-' ||
nonMarkTokenAfter && nonMarkTokenAfter.content === '-'
)

@@ -58,0 +60,0 @@ ) {

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const { addValidation } = require("./util")

@@ -0,0 +0,0 @@ // space besides hyper mark:

@@ -0,0 +0,0 @@ // space besides raw mark: one space outside

@@ -0,0 +0,0 @@ // deps:

@@ -0,0 +0,0 @@ // examples:

@@ -0,0 +0,0 @@ const {

@@ -0,0 +0,0 @@ const {

@@ -23,4 +23,4 @@ const {

const messages = {
full: ({ origin, result }) => `The puncatuation \`${origin}\` should be full-width as \`${result}\`.`,
half: ({ origin, result }) => `The puncatuation \`${origin}\` should be half-width as \`${result}\`.`,
full: ({ origin, result }) => `The punctuation \`${origin}\` should be full-width as \`${result}\`.`,
half: ({ origin, result }) => `The punctuation \`${origin}\` should be half-width as \`${result}\`.`,
bracketStart: ({ origin, result }) => `The left bracket \`${origin}\` should be full-width as \`${result}\`.`,

@@ -46,3 +46,3 @@ bracketEnd: ({ origin, result }) => `The right bracket \`${origin}\` should be full-width as \`${result}\`.`

// half-width: brackets
// no change for half-width puncatuation between half-width content without space
// no change for half-width punctuation between half-width content without space
if (token.type === 'punctuation-half') {

@@ -49,0 +49,0 @@ const contentTokenBefore = findContentTokenBefore(group, token)

@@ -0,0 +0,0 @@ // utils

@@ -11,2 +11,3 @@ const replaceBlocks = require('./replace-block')

{ name: 'hexo', value: require('./parsers/hexo') },
{ name: 'vuepress', value: require('./parsers/vuepress') },
{ name: 'markdown', value: require('./parsers/md') }

@@ -93,6 +94,12 @@ ]

const run = (str, options = {}) => {
const logger = options.logger || defaultLogger
const disabledMatcher = /<\!\-\-\s*zhlint\s*disabled\s*\-\-\>/g
if (str.match(disabledMatcher)) {
return { origin: str, result: str, validations: [], disabled: true }
}
const rules = options.rules || rulesInfo.map(item => item.name)
const hyperParse = options.hyperParse || hyperParseInfo.map(item => item.name)
const ignoredCases = options.ignoredCases || []
const logger = options.logger || defaultLogger

@@ -99,0 +106,0 @@ if (typeof hyperParse === 'function') {

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ type Options = {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc