@crackdown/core
v0.1.1
Published
The lint pipeline that powers the [marky](https://github.com/deftco/marky) CLI. You can also use it directly as a Node.js library inside build tools, editors, or other automation.
Readme
@crackdown/core
The lint pipeline that powers the marky CLI. You can also use it directly as a Node.js library inside build tools, editors, or other automation.
Install
pnpm add @crackdown/coreProgrammatic API
@crackdown/core exposes two main entry points: lint for files on disk and
lintString for in-memory content. Both accept an optional MarkyConfig.
import { lint, lintString, type MarkyConfig } from '@crackdown/core'
const config: MarkyConfig = {
rules: {
'remark-lint:no-heading-punctuation': 'error',
},
plugins: [],
}
// Lint files on disk.
const results = await lint(['README.md', 'docs/intro.md'], config)
for (const result of results) {
console.log(result.file, result.violations.length)
}
// Lint a string in memory.
const single = await lintString('# Hello!\n', config, 'README.md')
console.log(single.violations)Loading configuration from crackdown.config.ts
loadConfig(cwd) walks up the directory tree from cwd looking for a
crackdown.config.ts file and returns an empty config if none is found.
import { loadConfig, lint } from '@crackdown/core'
const config = await loadConfig(process.cwd())
const results = await lint(['README.md'], config)Exports
lint(files, config?)— lint a list of fileslintString(content, config?, filename?)— lint a Markdown stringlintFile(file, config?)— lint a single fileloadConfig(cwd)— locate and loadcrackdown.config.tsloadConfigFromFile(path)— load a specific config file- Types:
MarkyConfig,LintResult,LintViolation,Plugin,Severity,RuleSeverity
