Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,85 @@
# eslint-merge-processors
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]
Merge multiple ESLint processors to behave like one
## Install
```bash
npm i eslint-merge-processors
```
```js
import { mergeProcessors } from 'eslint-merge-processors'
const processor = mergeProcessors([
processorA,
processorB,
// ...
])
```
## Examples
### Markdown
Lint `.md` files with `eslint-plugin-markdown`.
By default, `eslint-plugin-markdown`'s processor will create a virtual file for each code snippet in the markdown file, **but not the original `.md` file itself**. This means the original `.md` file will not be linted.
With this package, along with the `processorPassThrough` processor, you can now fix that:
```ts
import {
mergeProcessors,
processorPassThrough
} from 'eslint-merge-processors'
import markdown from 'eslint-plugin-markdown'
// ESlint Flat config
export default [
{
files: ['**/*.md'],
plugins: {
markdown
},
processor: mergeProcessors([
// This allow the original `.md` file to be linted
processorPassThrough,
// The markdown processor
markdown.processors.markdown,
// other processors if needed
])
}
]
```
## Sponsors
<p align="center">
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
</a>
</p>
## License
[MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu)
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/eslint-merge-processors?style=flat&colorA=080f12&colorB=1fa669
[npm-version-href]: https://npmjs.com/package/eslint-merge-processors
[npm-downloads-src]: https://img.shields.io/npm/dm/eslint-merge-processors?style=flat&colorA=080f12&colorB=1fa669
[npm-downloads-href]: https://npmjs.com/package/eslint-merge-processors
[bundle-src]: https://img.shields.io/bundlephobia/minzip/eslint-merge-processors?style=flat&colorA=080f12&colorB=1fa669&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=eslint-merge-processors
[license-src]: https://img.shields.io/github/license/antfu/eslint-merge-processors.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]: https://github.com/antfu/eslint-merge-processors/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/eslint-merge-processors

View file

@ -0,0 +1,14 @@
import { Linter } from 'eslint';
/**
* Merge multiple processors into one
*
* @param processors
*/
declare function mergeProcessors(processors: Linter.Processor[]): Linter.Processor;
/**
* Pass-through the file itself
*/
declare const processorPassThrough: Linter.Processor;
export { mergeProcessors, processorPassThrough };

View file

@ -0,0 +1,14 @@
import { Linter } from 'eslint';
/**
* Merge multiple processors into one
*
* @param processors
*/
declare function mergeProcessors(processors: Linter.Processor[]): Linter.Processor;
/**
* Pass-through the file itself
*/
declare const processorPassThrough: Linter.Processor;
export { mergeProcessors, processorPassThrough };

View file

@ -0,0 +1,41 @@
function mergeProcessors(processors) {
const cache = /* @__PURE__ */ new Map();
return {
meta: {
name: `merged-processor:${processors.map((processor) => processor.meta?.name || "unknown").join("+")}`
},
supportsAutofix: true,
preprocess(text, filename) {
const counts = [];
cache.set(filename, counts);
return processors.flatMap((processor) => {
const result = processor.preprocess?.(text, filename) || [];
counts.push(result.length);
return result;
});
},
postprocess(messages, filename) {
const counts = cache.get(filename);
cache.delete(filename);
let index = 0;
return processors.flatMap((processor, idx) => {
const msgs = messages.slice(index, index + counts[idx]);
index += counts[idx];
return processor.postprocess?.(msgs, filename) || [];
});
}
};
}
const processorPassThrough = {
meta: {
name: "pass-through"
},
preprocess(text) {
return [text];
},
postprocess(messages) {
return messages[0];
}
};
export { mergeProcessors, processorPassThrough };

View file

@ -0,0 +1,76 @@
{
"name": "eslint-merge-processors",
"type": "module",
"version": "2.0.0",
"packageManager": "pnpm@10.2.1",
"description": "Merge multiple ESLint processors to behave like one",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"homepage": "https://github.com/antfu/eslint-merge-processors#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/antfu/eslint-merge-processors.git"
},
"bugs": "https://github.com/antfu/eslint-merge-processors/issues",
"keywords": [
"eslint",
"eslint-processor"
],
"sideEffects": false,
"exports": {
".": "./dist/index.mjs"
},
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./dist/index.d.mts"
]
}
},
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "unbuild --stub",
"lint": "eslint .",
"prepublishOnly": "nr build",
"release": "bumpp && npm publish",
"start": "esno src/index.ts",
"test": "vitest",
"typecheck": "tsc --noEmit",
"prepare": "simple-git-hooks"
},
"peerDependencies": {
"eslint": "*"
},
"devDependencies": {
"@antfu/eslint-config": "^4.1.1",
"@antfu/ni": "^23.3.1",
"@antfu/utils": "^8.1.0",
"@types/eslint": "^9.6.1",
"@types/node": "^22.13.1",
"bumpp": "^10.0.2",
"eslint": "^9.20.0",
"esno": "^4.8.0",
"lint-staged": "^15.4.3",
"pnpm": "^10.2.1",
"rimraf": "^6.0.1",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.7.3",
"unbuild": "^3.3.1",
"vite": "^6.1.0",
"vitest": "^3.0.5"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
}
}