@acfatah/eslint-preset 1.0.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/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # Eslint Preset
2
+
3
+ <p>
4
+ <a href="https://github.com/antfu/eslint-config">
5
+ <img
6
+ alt="Code Style"
7
+ src="https://antfu.me/badge-code-style.svg"></a>
8
+ <a href="https://github.com/antfu/eslint-config">
9
+ <img
10
+ alt="GitHub last commit (by committer)"
11
+ src="https://img.shields.io/github/last-commit/acfatah/eslint-preset?display_timestamp=committer&style=flat-square"></a>
12
+ </p>
13
+
14
+ An opinionated ESLint configuration preset for TypeScript projects, based on [`antfu/eslint-config`][1].
15
+
16
+ ## Installation
17
+
18
+ To install the config, run:
19
+
20
+ ```bash
21
+ bun add --dev @acfatah/eslint-preset
22
+ ```
23
+
24
+ Add `eslint.config.ts` file with the following content,
25
+
26
+ ```typescript
27
+ import { markdown, preset, vue } from '@acfatah/eslint-preset/rules'
28
+ import antfu from '@antfu/eslint-config'
29
+
30
+ export default antfu(
31
+ {
32
+ formatters: true,
33
+ vue: true,
34
+ },
35
+
36
+ {
37
+ rules: {
38
+ ...preset,
39
+ ...markdown,
40
+ ...vue,
41
+ },
42
+ },
43
+
44
+ {
45
+ name: 'app/files-to-ignore',
46
+ ignores: [
47
+ '**/coverage/**',
48
+ '**/dist/**',
49
+ '**/logs/**',
50
+ 'bun.lock',
51
+ 'tsconfig.*',
52
+ ],
53
+ },
54
+ )
55
+ ```
56
+
57
+ ## VS Code Support
58
+
59
+ Install the [VS Code ESLint extension][2].
60
+
61
+ Add the following vscode configuration to `.vscode/settings.json`,
62
+
63
+ ```jsonc
64
+ {
65
+ // Disable the default formatter, use eslint instead
66
+ "prettier.enable": false,
67
+ "editor.formatOnSave": false,
68
+
69
+ // Auto fix
70
+ "editor.codeActionsOnSave": {
71
+ "source.fixAll.eslint": "explicit",
72
+ "source.organizeImports": "never"
73
+ },
74
+
75
+ // Silent the stylistic rules in you IDE, but still auto fix them
76
+ "eslint.rules.customizations": [
77
+ { "rule": "style/*", "severity": "off", "fixable": true },
78
+ { "rule": "format/*", "severity": "off", "fixable": true },
79
+ { "rule": "*-indent", "severity": "off", "fixable": true },
80
+ { "rule": "*-spacing", "severity": "off", "fixable": true },
81
+ { "rule": "*-spaces", "severity": "off", "fixable": true },
82
+ { "rule": "*-order", "severity": "off", "fixable": true },
83
+ { "rule": "*-dangle", "severity": "off", "fixable": true },
84
+ { "rule": "*-newline", "severity": "off", "fixable": true },
85
+ { "rule": "*quotes", "severity": "off", "fixable": true },
86
+ { "rule": "*semi", "severity": "off", "fixable": true }
87
+ ],
88
+
89
+ // Enable eslint for all supported languages
90
+ "eslint.validate": [
91
+ "javascript",
92
+ "javascriptreact",
93
+ "typescript",
94
+ "typescriptreact",
95
+ "vue",
96
+ "html",
97
+ "markdown",
98
+ "json",
99
+ "jsonc",
100
+ "yaml",
101
+ "toml",
102
+ "xml",
103
+ "gql",
104
+ "graphql",
105
+ "astro",
106
+ "svelte",
107
+ "css",
108
+ "less",
109
+ "scss",
110
+ "pcss",
111
+ "postcss"
112
+ ],
113
+
114
+ // https://github.com/tailwindlabs/tailwindcss-intellisense?tab=readme-ov-file#recommended-vs-code-settings
115
+ "files.associations": {
116
+ "*.css": "tailwindcss"
117
+ },
118
+
119
+ // https://github.com/tailwindlabs/tailwindcss-intellisense?tab=readme-ov-file#recommended-vs-code-settings
120
+ "editor.quickSuggestions": {
121
+ "strings": "on"
122
+ }
123
+ }
124
+ ```
125
+
126
+ ## Tailwind CSS Configuration
127
+
128
+ Install the [Tailwind CSS IntelliSense extension][3].
129
+
130
+ Add the following custom Tailwind CSS v4 functions and directives lines to the `.vscode/settings.json` file:
131
+
132
+ ```jsonc
133
+ {
134
+ // other settings...
135
+
136
+ // Custom Tailwind CSS v4 functions and directives
137
+ // See:
138
+ // - https://tailwindcss.com/docs/functions-and-directives
139
+ // - https://grok.com/share/bGVnYWN5_1cf7d218-282e-46e5-acc6-efb07d12d35e
140
+ "css.customData": [
141
+ ".vscode/tailwind.json"
142
+ ]
143
+
144
+ // other settings...
145
+ }
146
+ ```
147
+
148
+ Then, add the following configurations to `.vscode/tailwindcss.json`.
149
+
150
+ ```jsonc
151
+ {
152
+ "version": 1.1,
153
+ "atDirectives": [
154
+ {
155
+ "name": "@apply",
156
+ "description": "Inline any existing utility classes into custom CSS.",
157
+ "references": [
158
+ {
159
+ "name": "Tailwind Documentation",
160
+ "url": "https://tailwindcss.com/docs/functions-and-directives#apply-directive"
161
+ }
162
+ ]
163
+ },
164
+ {
165
+ "name": "@config",
166
+ "description": "Load legacy JavaScript-based configuration file (compatibility with v3.x).",
167
+ "references": [
168
+ {
169
+ "name": "Tailwind Documentation",
170
+ "url": "https://tailwindcss.com/docs/functions-and-directives#config-directive"
171
+ }
172
+ ]
173
+ },
174
+ {
175
+ "name": "@custom-variant",
176
+ "description": "Add a custom variant in the project.",
177
+ "references": [
178
+ {
179
+ "name": "Tailwind Documentation",
180
+ "url": "https://tailwindcss.com/docs/functions-and-directives#custom-variant-directive"
181
+ }
182
+ ]
183
+ },
184
+ {
185
+ "name": "@import",
186
+ "description": "Use the @import directive to inline import CSS files, including Tailwind itself.",
187
+ "references": [
188
+ {
189
+ "name": "Tailwind Documentation",
190
+ "url": "https://tailwindcss.com/docs/functions-and-directives#import-directive"
191
+ }
192
+ ]
193
+ },
194
+ {
195
+ "name": "@plugin",
196
+ "description": "Load legacy JavaScript-based plugin (compatibility with v3.x).",
197
+ "references": [
198
+ {
199
+ "name": "Tailwind Documentation",
200
+ "url": "https://tailwindcss.com/docs/upgrading-to-v4#plugins"
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ "name": "@reference",
206
+ "description": "Import main stylesheet for reference without including styles, for use with frameworks like React, Svelte, etc.",
207
+ "references": [
208
+ {
209
+ "name": "Tailwind Documentation",
210
+ "url": "https://tailwindcss.com/docs/functions-and-directives#reference-directive"
211
+ }
212
+ ]
213
+ },
214
+ {
215
+ "name": "@source",
216
+ "description": "Specify source files not picked up by automatic content detection.",
217
+ "references": [
218
+ {
219
+ "name": "Tailwind Documentation",
220
+ "url": "https://tailwindcss.com/docs/functions-and-directives#source-directive"
221
+ }
222
+ ]
223
+ },
224
+ {
225
+ "name": "@theme",
226
+ "description": "Define custom design tokens like fonts, colors, breakpoints.",
227
+ "references": [
228
+ {
229
+ "name": "Tailwind Documentation",
230
+ "url": "https://tailwindcss.com/docs/functions-and-directives#theme-directive"
231
+ }
232
+ ]
233
+ },
234
+ {
235
+ "name": "@utility",
236
+ "description": "Add custom utilities that work with variants like hover, focus, lg.",
237
+ "references": [
238
+ {
239
+ "name": "Tailwind Documentation",
240
+ "url": "https://tailwindcss.com/docs/functions-and-directives#utility-directive"
241
+ }
242
+ ]
243
+ },
244
+ {
245
+ "name": "@variant",
246
+ "description": "Apply a Tailwind variant to styles in CSS.",
247
+ "references": [
248
+ {
249
+ "name": "Tailwind Documentation",
250
+ "url": "https://tailwindcss.com/docs/functions-and-directives#variant-directive"
251
+ }
252
+ ]
253
+ }
254
+ ]
255
+ }
256
+ ```
257
+
258
+ ## Acknowledgments
259
+
260
+ - [antfu/eslint-config][1]
261
+
262
+ [1]: https://github.com/antfu/eslint-config
263
+ [2]: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
264
+ [3]: https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
@@ -0,0 +1,76 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ * Eslint preset for Markdown files.
5
+ *
6
+ * This preset integrates the `@eslint/markdown` plugin.
7
+ * See: https://github.com/eslint/markdown
8
+ */
9
+ export declare const markdown: {
10
+ name: string;
11
+ files: string[];
12
+ language: string;
13
+ plugins: {};
14
+ rules: {
15
+ readonly "markdown/fenced-code-language": "error";
16
+ readonly "markdown/heading-increment": "error";
17
+ readonly "markdown/no-duplicate-definitions": "error";
18
+ readonly "markdown/no-empty-definitions": "error";
19
+ readonly "markdown/no-empty-images": "error";
20
+ readonly "markdown/no-empty-links": "error";
21
+ readonly "markdown/no-invalid-label-refs": "error";
22
+ readonly "markdown/no-missing-atx-heading-space": "error";
23
+ readonly "markdown/no-missing-label-refs": "error";
24
+ readonly "markdown/no-missing-link-fragments": "error";
25
+ readonly "markdown/no-multiple-h1": "error";
26
+ readonly "markdown/no-reference-like-urls": "error";
27
+ readonly "markdown/no-reversed-media-syntax": "error";
28
+ readonly "markdown/no-space-in-emphasis": "error";
29
+ readonly "markdown/no-unused-definitions": "error";
30
+ readonly "markdown/require-alt-text": "error";
31
+ readonly "markdown/table-column-count": "error";
32
+ };
33
+ }[];
34
+ export declare const preset: {
35
+ "sort-imports": string;
36
+ "perfectionist/sort-imports": (string | {
37
+ partitionByNewLine: boolean;
38
+ newlinesBetween: string;
39
+ })[];
40
+ "space-before-function-paren": (string | {
41
+ anonymous: string;
42
+ named: string;
43
+ asyncArrow: string;
44
+ })[];
45
+ "style/padding-line-between-statements": (string | {
46
+ blankLine: string;
47
+ prev: string;
48
+ next: string;
49
+ })[];
50
+ };
51
+ /**
52
+ * Eslint preset for Tailwind CSS.
53
+ *
54
+ * This preset integrates the `eslint-plugin-better-tailwindcss` plugin.
55
+ * See: https://github.com/schoero/eslint-plugin-better-tailwindcss
56
+ */
57
+ export declare const tailwind: {
58
+ "better-tailwindcss/enforce-consistent-line-wrapping": (string | {
59
+ printWidth: number;
60
+ })[];
61
+ "better-tailwindcss/no-restricted-classes": string;
62
+ "better-tailwindcss/no-unregistered-classes": string;
63
+ };
64
+ /**
65
+ * Eslint preset for Vue.js files.
66
+ *
67
+ * This preset integrates the `eslint-plugin-vue` plugin.
68
+ * See: https://eslint.vuejs.org/
69
+ */
70
+ export declare const vue: {
71
+ "vue/object-property-newline": (string | {
72
+ allowAllPropertiesOnSameLine: boolean;
73
+ })[];
74
+ };
75
+
76
+ export {};
package/dist/index.mjs ADDED
@@ -0,0 +1,43 @@
1
+ // src/rules/markdown.ts
2
+ import eslintMarkdown from "@eslint/markdown";
3
+ var markdown = eslintMarkdown.configs.recommended;
4
+ // src/rules/preset.ts
5
+ var preset = {
6
+ "sort-imports": "off",
7
+ "perfectionist/sort-imports": ["error", {
8
+ partitionByNewLine: true,
9
+ newlinesBetween: "ignore"
10
+ }],
11
+ "space-before-function-paren": ["error", {
12
+ anonymous: "never",
13
+ named: "never",
14
+ asyncArrow: "always"
15
+ }],
16
+ "style/padding-line-between-statements": [
17
+ "error",
18
+ { blankLine: "always", prev: "*", next: "return" }
19
+ ]
20
+ };
21
+ // src/rules/tailwind.ts
22
+ import eslintPluginBetterTailwindcss from "eslint-plugin-better-tailwindcss";
23
+ var tailwind = {
24
+ ...eslintPluginBetterTailwindcss.configs["recommended-warn"]?.rules,
25
+ ...eslintPluginBetterTailwindcss.configs["recommended-error"]?.rules,
26
+ "better-tailwindcss/enforce-consistent-line-wrapping": ["warn", {
27
+ printWidth: 100
28
+ }],
29
+ "better-tailwindcss/no-restricted-classes": "off",
30
+ "better-tailwindcss/no-unregistered-classes": "off"
31
+ };
32
+ // src/rules/vue.ts
33
+ var vue = {
34
+ "vue/object-property-newline": ["error", {
35
+ allowAllPropertiesOnSameLine: true
36
+ }]
37
+ };
38
+ export {
39
+ vue,
40
+ tailwind,
41
+ preset,
42
+ markdown
43
+ };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@acfatah/eslint-preset",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "Eslint config preset.",
6
+ "author": "Achmad F. Ibrahim <acfatah@gmail.com>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/acfatah/eslint-preset#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/acfatah/eslint-preset.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/acfatah/eslint-preset/issues"
15
+ },
16
+ "exports": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.mjs"
19
+ },
20
+ "main": "./dist/index.mjs",
21
+ "module": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "engines": {
30
+ "node": "^20.19.0 || >=22.12.0"
31
+ },
32
+ "scripts": {
33
+ "build": "bun run scripts/build.ts",
34
+ "lint": "bunx --bun eslint",
35
+ "lint:staged": "bunx --bun eslint --pass-on-no-patterns --no-warn-ignored $(git diff --relative --cached --name-only --diff-filter=d)",
36
+ "lint:commit-message": "bunx --bun commitlint --edit",
37
+ "format": "bunx --bun eslint --fix",
38
+ "typecheck": "tsc --noEmit",
39
+ "release": "bunx --bun bumpp --execute=\"bun install\"",
40
+ "publish": "npm publish --access public"
41
+ },
42
+ "dependencies": {
43
+ "@antfu/eslint-config": "^6.2.0",
44
+ "@eslint/markdown": "^7.5.1",
45
+ "eslint-plugin-better-tailwindcss": "^3.7.11",
46
+ "eslint-plugin-vue": "^10.6.2"
47
+ },
48
+ "devDependencies": {
49
+ "@commitlint/cli": "^20.1.0",
50
+ "@commitlint/config-conventional": "^20.0.0",
51
+ "@types/bun": "^1.3.3",
52
+ "bumpp": "^10.3.1",
53
+ "bun-plugin-dts": "^0.3.0",
54
+ "eslint": "^9.39.1",
55
+ "eslint-plugin-format": "^1.0.2",
56
+ "simple-git-hooks": "^2.13.1"
57
+ },
58
+ "simple-git-hooks": {
59
+ "commit-msg": "bun lint:commit-message",
60
+ "pre-commit": "bun lint:staged"
61
+ }
62
+ }