@octohash/eslint-config 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jing Haihan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @octohash/eslint-config
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![JSDocs][jsdocs-src]][jsdocs-href]
5
+ [![License][license-src]][license-href]
6
+
7
+ <!-- Badges -->
8
+
9
+ [npm-version-src]: https://img.shields.io/npm/v/@octohash/eslint-config?style=flat&colorA=080f12&colorB=1fa669
10
+ [npm-version-href]: https://npmjs.com/package/@octohash/eslint-config
11
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@octohash/eslint-config?style=flat&colorA=080f12&colorB=1fa669
12
+ [npm-downloads-href]: https://npmjs.com/package/@octohash/eslint-config
13
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/@octohash/eslint-config?style=flat&colorA=080f12&colorB=1fa669&label=minzip
14
+ [bundle-href]: https://bundlephobia.com/result?p=@octohash/eslint-config
15
+ [license-src]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat&colorA=080f12&colorB=1fa669
16
+ [license-href]: https://github.com/jinghaihan/@octohash/eslint-config/LICENSE
17
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
18
+ [jsdocs-href]: https://www.jsdocs.io/package/@octohash/eslint-config
@@ -0,0 +1,15 @@
1
+ import * as _antfu_eslint_config0 from "@antfu/eslint-config";
2
+ import { Awaitable, OptionsConfig, TypedFlatConfigItem } from "@antfu/eslint-config";
3
+ import * as eslint_flat_config_utils2 from "eslint-flat-config-utils";
4
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
5
+ import { Linter } from "eslint";
6
+
7
+ //#region src/types.d.ts
8
+ type Options = AntfuOptions & {};
9
+ type AntfuOptions = OptionsConfig & Omit<TypedFlatConfigItem, 'files'>;
10
+ type UserConfig = Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[];
11
+ //#endregion
12
+ //#region src/index.d.ts
13
+ declare function defineConfig(options?: Options, ...userConfigs: UserConfig): eslint_flat_config_utils2.FlatConfigComposer<_antfu_eslint_config0.TypedFlatConfigItem, _antfu_eslint_config0.ConfigNames>;
14
+ //#endregion
15
+ export { defineConfig };
package/dist/index.js ADDED
@@ -0,0 +1,51 @@
1
+ import antfu from "@antfu/eslint-config";
2
+ import { readFileSync, readdirSync } from "node:fs";
3
+ import process from "node:process";
4
+ import tailwindPlugin from "eslint-plugin-tailwindcss";
5
+ import { isPackageExists } from "local-pkg";
6
+ import { join } from "pathe";
7
+
8
+ //#region src/tailwindcss.ts
9
+ function tailwindCSS(dir) {
10
+ const installed = isPackageExists("tailwindcss");
11
+ if (!installed) return;
12
+ dir = dir ?? process.cwd();
13
+ return {
14
+ ...tailwindPlugin.configs["flat/recommended"],
15
+ settings: { tailwindcss: { config: findTailwindImportCSS(dir) } }
16
+ };
17
+ }
18
+ function findTailwindImportCSS(dir) {
19
+ const entries = readdirSync(dir, { withFileTypes: true });
20
+ for (const entry of entries) {
21
+ const fullPath = join(dir, entry.name);
22
+ if (entry.isDirectory()) {
23
+ const found = findTailwindImportCSS(fullPath);
24
+ if (found) return found;
25
+ } else if (entry.isFile() && entry.name.endsWith(".css")) {
26
+ const lines = readFileSync(fullPath, "utf8").split(/\r?\n/);
27
+ for (const line of lines) if (line.trim().startsWith("@import \"tailwindcss")) return fullPath;
28
+ }
29
+ }
30
+ return null;
31
+ }
32
+
33
+ //#endregion
34
+ //#region src/index.ts
35
+ function defineConfig(options, ...userConfigs) {
36
+ return antfu(mergeOptions(options), tailwindCSS(), ...userConfigs);
37
+ }
38
+ function mergeOptions(options) {
39
+ return {
40
+ ...options,
41
+ stylistic: true,
42
+ formatters: {
43
+ css: true,
44
+ html: true,
45
+ ...typeof options?.formatters === "object" ? options.formatters : {}
46
+ }
47
+ };
48
+ }
49
+
50
+ //#endregion
51
+ export { defineConfig };
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@octohash/eslint-config",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "ESLint configuration based on @antfu/eslint-config, optimized for application development. Includes built-in support for Vue, TypeScript, and Tailwind CSS",
6
+ "author": "jinghaihan",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/jinghaihan/eslint-config#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/jinghaihan/eslint-config.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jinghaihan/eslint-config/issues"
15
+ },
16
+ "keywords": [
17
+ "eslint",
18
+ "eslint-config",
19
+ "linter"
20
+ ],
21
+ "exports": {
22
+ ".": "./dist/index.js",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "main": "./dist/index.js",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "dependencies": {
35
+ "@antfu/eslint-config": "^4.16.2",
36
+ "eslint-plugin-format": "^1.0.1",
37
+ "eslint-plugin-tailwindcss": "npm:@hyoban/eslint-plugin-tailwindcss@4.0.0-alpha.13",
38
+ "local-pkg": "^1.1.1",
39
+ "pathe": "^2.0.3"
40
+ },
41
+ "devDependencies": {
42
+ "@octohash/tsconfig": "^0.1.0",
43
+ "@types/node": "^24.0.12",
44
+ "bumpp": "^10.2.0",
45
+ "czg": "^1.11.2",
46
+ "eslint": "^9.30.1",
47
+ "eslint-flat-config-utils": "^2.1.0",
48
+ "lint-staged": "^16.1.2",
49
+ "pncat": "^0.2.6",
50
+ "simple-git-hooks": "^2.13.0",
51
+ "taze": "^19.1.0",
52
+ "tsdown": "^0.12.9",
53
+ "typescript": "^5.8.3",
54
+ "vitest": "^3.2.4",
55
+ "@octohash/eslint-config": "0.1.0"
56
+ },
57
+ "simple-git-hooks": {
58
+ "pre-commit": "pnpm lint-staged"
59
+ },
60
+ "lint-staged": {
61
+ "*": "eslint --fix"
62
+ },
63
+ "scripts": {
64
+ "build": "tsdown --clean --dts",
65
+ "typecheck": "tsc",
66
+ "test": "vitest",
67
+ "lint": "eslint",
68
+ "commit": "czg",
69
+ "deps": "taze major -I",
70
+ "release": "bumpp && pnpm publish --no-git-checks",
71
+ "catalog": "pncat",
72
+ "bootstrap": "pnpm install",
73
+ "preinstall": "npx only-allow pnpm"
74
+ }
75
+ }