@blacklizard/eslint-blacklizard 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/LICENSE +21 -0
- package/README.md +136 -0
- package/eslint.config.mjs +382 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 blacklizard
|
|
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,136 @@
|
|
|
1
|
+
# @blacklizard/eslint-blacklizard
|
|
2
|
+
|
|
3
|
+
Reusable, opinionated ESLint config — Blacklizard code standards. Built on
|
|
4
|
+
[`eslint-config-airbnb-extended`](https://www.npmjs.com/package/eslint-config-airbnb-extended),
|
|
5
|
+
flat config, ESLint 9+.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add -D eslint @blacklizard/eslint-blacklizard
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`eslint` is a peer dependency (`>=9`). Requires Node `>=24`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
The default export auto-configures itself — every rule set is scoped by file
|
|
18
|
+
extension, so `.js`/`.ts`, `.vue`, `.html`, `.css` and `.eta` files each get
|
|
19
|
+
the right rules with no manual selection:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// eslint.config.mjs — lints everything
|
|
23
|
+
export { default } from '@blacklizard/eslint-blacklizard';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
That is all most projects need. The individual configs are also exported if
|
|
27
|
+
you want to lint only one file type:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
export { typescriptConfig as default } from '@blacklizard/eslint-blacklizard';
|
|
31
|
+
export { vueConfig as default } from '@blacklizard/eslint-blacklizard';
|
|
32
|
+
export { htmlConfig as default } from '@blacklizard/eslint-blacklizard';
|
|
33
|
+
export { cssConfig as default } from '@blacklizard/eslint-blacklizard';
|
|
34
|
+
export { etaConfig as default } from '@blacklizard/eslint-blacklizard';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To extend a config with project-specific rules:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import config from '@blacklizard/eslint-blacklizard';
|
|
41
|
+
|
|
42
|
+
export default [
|
|
43
|
+
...config,
|
|
44
|
+
{
|
|
45
|
+
rules: {
|
|
46
|
+
// project overrides
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Exports
|
|
53
|
+
|
|
54
|
+
| Export | Files | Covers |
|
|
55
|
+
| ------------------ | ---------------- | ------------------------------------------------------------ |
|
|
56
|
+
| `autoConfig` | all of the below | every config combined, scoped by file extension |
|
|
57
|
+
| `typescriptConfig` | `.js`, `.ts` | airbnb base + node + typescript; Tailwind classes in JSX/TSX |
|
|
58
|
+
| `vueConfig` | + `.vue` | above, widened to SFCs + `eslint-plugin-vue` + Tailwind |
|
|
59
|
+
| `htmlConfig` | `.html` | `@html-eslint` recommended markup rules |
|
|
60
|
+
| `etaConfig` | `.eta` | JS inside `<% %>` exec tags of Eta templates |
|
|
61
|
+
| `cssConfig` | `.css` | `@eslint/css` recommended rules |
|
|
62
|
+
|
|
63
|
+
`default` is `autoConfig`.
|
|
64
|
+
|
|
65
|
+
## Notable rule choices
|
|
66
|
+
|
|
67
|
+
- `@stylistic/max-len`: 120 (comments + URLs exempt)
|
|
68
|
+
- `@stylistic/semi`: always
|
|
69
|
+
- `max-depth`: 2
|
|
70
|
+
- `@stylistic/padding-line-between-statements`: blank lines after imports,
|
|
71
|
+
before `return`, around blocks and functions
|
|
72
|
+
- `no-console`: error (allows `console.warn` / `console.error`)
|
|
73
|
+
- Relaxed rules for `*.{test,spec}.*` and `__tests__/`
|
|
74
|
+
|
|
75
|
+
## Tailwind CSS
|
|
76
|
+
|
|
77
|
+
`typescriptConfig` and `vueConfig` lint Tailwind class attributes via
|
|
78
|
+
[`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss)
|
|
79
|
+
(`recommended` rules — class order, duplicates, conflicts, unknown classes).
|
|
80
|
+
|
|
81
|
+
Class-resolution rules need to know your Tailwind setup, so consumers **must**
|
|
82
|
+
add a `settings` block pointing at it:
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import { vueConfig } from '@blacklizard/eslint-blacklizard';
|
|
86
|
+
|
|
87
|
+
export default [
|
|
88
|
+
...vueConfig,
|
|
89
|
+
{
|
|
90
|
+
settings: {
|
|
91
|
+
'better-tailwindcss': {
|
|
92
|
+
entryPoint: 'src/styles/app.css', // Tailwind v4: your CSS entry
|
|
93
|
+
// tailwindConfig: 'tailwind.config.js', // Tailwind v3 instead
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`tailwindcss` (`^3.3.0 || ^4.1.17`) must be installed in the project.
|
|
101
|
+
|
|
102
|
+
## Requirements & caveats
|
|
103
|
+
|
|
104
|
+
- **Typed linting** (`typescriptConfig`, `vueConfig`) needs a `tsconfig.json`
|
|
105
|
+
covering the linted files — including `.vue` for Vue projects. Without it,
|
|
106
|
+
ESLint reports `"not found by the project service"`.
|
|
107
|
+
- **Tailwind**: without the `settings['better-tailwindcss']` block above,
|
|
108
|
+
class-resolution rules cannot work and will flag every class as unknown.
|
|
109
|
+
- **HTML**: inline `<script>` JS is not linted — keep scripts in external
|
|
110
|
+
`.js` files.
|
|
111
|
+
- **Eta**: only JS in `<% %>` exec tags is linted. Interpolation tags
|
|
112
|
+
(`<%= %>`, `<%~ %>`) and HTML markup are not checked.
|
|
113
|
+
- **CSS**: `css/no-invalid-at-rules` is disabled — Tailwind at-rules
|
|
114
|
+
(`@apply`, `@theme`, `@utility`, `@variant`) are not standard CSS and would
|
|
115
|
+
otherwise false-flag every Tailwind file. All other `@eslint/css` rules
|
|
116
|
+
(empty blocks, duplicate imports/keyframes, `!important`, baseline, etc.)
|
|
117
|
+
stay on.
|
|
118
|
+
|
|
119
|
+
## Releasing
|
|
120
|
+
|
|
121
|
+
Versioning is managed with [changesets](https://github.com/changesets/changesets):
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
pnpm changeset # 1. record a change + pick bump type (patch/minor/major)
|
|
125
|
+
pnpm version # 2. apply bumps, write CHANGELOG.md (changeset version)
|
|
126
|
+
git commit -am "version packages" # 3. commit the bump
|
|
127
|
+
pnpm release # 4. lint + test, then tag + push
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Pushing the `v*` tag triggers the GitHub Actions workflow, which publishes to
|
|
131
|
+
npm with provenance.
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT
|
|
136
|
+
# eslint
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { includeIgnoreFile } from '@eslint/compat';
|
|
5
|
+
import cssPlugin from '@eslint/css';
|
|
6
|
+
import js from '@eslint/js';
|
|
7
|
+
import htmlPlugin from '@html-eslint/eslint-plugin';
|
|
8
|
+
import tsParser from '@typescript-eslint/parser';
|
|
9
|
+
import { defineConfig } from 'eslint/config';
|
|
10
|
+
import { configs, plugins, rules } from 'eslint-config-airbnb-extended';
|
|
11
|
+
import betterTailwind from 'eslint-plugin-better-tailwindcss';
|
|
12
|
+
import pluginVue from 'eslint-plugin-vue';
|
|
13
|
+
|
|
14
|
+
const gitignorePath = path.resolve('.', '.gitignore');
|
|
15
|
+
// eslint-disable-next-line n/no-sync -- config loads synchronously at startup
|
|
16
|
+
const gitignoreConfig = existsSync(gitignorePath)
|
|
17
|
+
? [includeIgnoreFile(gitignorePath)]
|
|
18
|
+
: [];
|
|
19
|
+
|
|
20
|
+
const VUE_GLOB = '**/*.vue';
|
|
21
|
+
const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
|
|
22
|
+
const TS_VUE_FILES = [...TS_FILES, VUE_GLOB];
|
|
23
|
+
// Every file type that carries JS/TS rules — used to scope shared overrides
|
|
24
|
+
// so their @stylistic rules never reach .css/.html/.eta files.
|
|
25
|
+
const SCRIPT_FILES = [
|
|
26
|
+
'**/*.js', '**/*.cjs', '**/*.mjs', '**/*.jsx',
|
|
27
|
+
'**/*.ts', '**/*.cts', '**/*.mts', '**/*.tsx',
|
|
28
|
+
VUE_GLOB,
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const isJsOnly = (entry) => Array.isArray(entry.files)
|
|
32
|
+
&& entry.files.every((glob) => /\.(?:c|m)?jsx?$/.test(glob));
|
|
33
|
+
|
|
34
|
+
// Widen an airbnb flat-config entry so its rules also cover .vue SFCs.
|
|
35
|
+
// Entries that intentionally target plain JS are left untouched.
|
|
36
|
+
const includeVue = (entry) => {
|
|
37
|
+
if (!Array.isArray(entry.files) || isJsOnly(entry) || entry.files.includes(VUE_GLOB)) {
|
|
38
|
+
return entry;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { ...entry, files: [...entry.files, VUE_GLOB] };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Restrict TypeScript parsing + typed rules to the given globs, so the
|
|
45
|
+
// typescript-eslint parser never leaks onto plain .js/.mjs/.cjs files.
|
|
46
|
+
const scopeTs = (files) => (entry) => (isJsOnly(entry) ? entry : { ...entry, files });
|
|
47
|
+
|
|
48
|
+
// Give an unscoped entry a script-file scope, so its JS rules never reach
|
|
49
|
+
// .css/.html/.eta files when configs are combined in autoConfig.
|
|
50
|
+
const ensureScriptScope = (entry) => (Array.isArray(entry.files) ? entry : { ...entry, files: SCRIPT_FILES });
|
|
51
|
+
|
|
52
|
+
// Give an unscoped entry a .vue scope, so vue rules never reach other files.
|
|
53
|
+
const ensureVueScope = (entry) => (Array.isArray(entry.files) ? entry : { ...entry, files: [VUE_GLOB] });
|
|
54
|
+
|
|
55
|
+
// Extract the JavaScript from Eta exec tags (<% ... %>) while masking every
|
|
56
|
+
// other character with whitespace, so reported line/column numbers still
|
|
57
|
+
// point at the original .eta file. Interpolation (<%=), raw (<%~) and comment
|
|
58
|
+
// (<%#) tags are skipped — they hold expressions, not statements.
|
|
59
|
+
const ETA_TAG = /<%([\s\S]*?)%>/g;
|
|
60
|
+
|
|
61
|
+
// Code offset of an exec tag's inner JS, skipping a leading slurp char (_ or -).
|
|
62
|
+
const etaCodeStart = (match, inner) => match.index + 2 + (/^[_-]/.test(inner) ? 1 : 0);
|
|
63
|
+
|
|
64
|
+
// End offset of an exec tag's inner JS, skipping a trailing slurp char.
|
|
65
|
+
const etaCodeEnd = (match, inner) => match.index + 2 + inner.length - (/[_-]$/.test(inner) ? 1 : 0);
|
|
66
|
+
|
|
67
|
+
// Blank out a chunk, keeping newlines so line numbers are preserved.
|
|
68
|
+
const maskChunk = (chunk) => chunk.replace(/[^\n]/g, ' ');
|
|
69
|
+
|
|
70
|
+
const extractEtaScript = (text) => {
|
|
71
|
+
let out = '';
|
|
72
|
+
let cursor = 0;
|
|
73
|
+
let match = ETA_TAG.exec(text);
|
|
74
|
+
|
|
75
|
+
while (match !== null) {
|
|
76
|
+
const inner = match[1];
|
|
77
|
+
const isExecTag = !/^[=~#]/.test(inner);
|
|
78
|
+
const tagEnd = match.index + match[0].length;
|
|
79
|
+
const codeStart = isExecTag ? etaCodeStart(match, inner) : tagEnd;
|
|
80
|
+
const codeEnd = isExecTag ? etaCodeEnd(match, inner) : tagEnd;
|
|
81
|
+
|
|
82
|
+
out += maskChunk(text.slice(cursor, codeStart))
|
|
83
|
+
+ text.slice(codeStart, codeEnd)
|
|
84
|
+
+ maskChunk(text.slice(codeEnd, tagEnd));
|
|
85
|
+
cursor = tagEnd;
|
|
86
|
+
match = ETA_TAG.exec(text);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return out + maskChunk(text.slice(cursor));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Processor that lets ESLint lint the JS inside .eta templates.
|
|
93
|
+
const etaProcessor = {
|
|
94
|
+
meta: { name: 'blacklizard/eta', version: '1.0.0' },
|
|
95
|
+
preprocess: (text) => [{ text: extractEtaScript(text), filename: 'script.js' }],
|
|
96
|
+
postprocess: (messageLists) => messageLists.flat(),
|
|
97
|
+
supportsAutofix: false,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const baseEntries = [
|
|
101
|
+
// ESLint recommended config
|
|
102
|
+
{
|
|
103
|
+
name: 'js/config',
|
|
104
|
+
...js.configs.recommended,
|
|
105
|
+
},
|
|
106
|
+
// Stylistic plugin
|
|
107
|
+
plugins.stylistic,
|
|
108
|
+
// Import X plugin
|
|
109
|
+
plugins.importX,
|
|
110
|
+
// Airbnb base recommended config
|
|
111
|
+
...configs.base.recommended,
|
|
112
|
+
// Strict import rules
|
|
113
|
+
rules.base.importsStrict,
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const nodeEntries = [
|
|
117
|
+
// Node plugin
|
|
118
|
+
plugins.node,
|
|
119
|
+
// Airbnb Node recommended config
|
|
120
|
+
...configs.node.recommended,
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const typescriptEntries = [
|
|
124
|
+
// TypeScript ESLint plugin
|
|
125
|
+
plugins.typescriptEslint,
|
|
126
|
+
// Airbnb base TypeScript config
|
|
127
|
+
...configs.base.typescript,
|
|
128
|
+
// Strict TypeScript rules
|
|
129
|
+
rules.typescript.typescriptEslintStrict,
|
|
130
|
+
// Enable typed linting
|
|
131
|
+
{
|
|
132
|
+
name: 'blacklizard/typescript-project-service',
|
|
133
|
+
languageOptions: {
|
|
134
|
+
parserOptions: { projectService: true },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
const vueEntries = [
|
|
140
|
+
// eslint-plugin-vue flat recommended config
|
|
141
|
+
...pluginVue.configs['flat/recommended'],
|
|
142
|
+
// TypeScript support inside <script lang="ts"> blocks
|
|
143
|
+
{
|
|
144
|
+
name: 'blacklizard/vue-typescript',
|
|
145
|
+
files: [VUE_GLOB],
|
|
146
|
+
languageOptions: {
|
|
147
|
+
parserOptions: {
|
|
148
|
+
parser: tsParser,
|
|
149
|
+
projectService: true,
|
|
150
|
+
extraFileExtensions: ['.vue'],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
// Tailwind class-attribute linting (eslint-plugin-better-tailwindcss).
|
|
157
|
+
// Consumers must set settings['better-tailwindcss'].entryPoint (Tailwind v4)
|
|
158
|
+
// or .tailwindConfig (v3) so class-resolution rules work.
|
|
159
|
+
const tailwindEntry = (files) => ({
|
|
160
|
+
...betterTailwind.configs.recommended,
|
|
161
|
+
name: 'blacklizard/tailwind',
|
|
162
|
+
files,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const stylisticOverrides = {
|
|
166
|
+
name: 'blacklizard/stylistic-overrides',
|
|
167
|
+
files: SCRIPT_FILES,
|
|
168
|
+
rules: {
|
|
169
|
+
'@stylistic/lines-between-class-members': [
|
|
170
|
+
'error',
|
|
171
|
+
'always',
|
|
172
|
+
{ exceptAfterSingleLine: true },
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const blacklizardOverrides = {
|
|
178
|
+
name: 'blacklizard/overrides',
|
|
179
|
+
files: SCRIPT_FILES,
|
|
180
|
+
rules: {
|
|
181
|
+
curly: ['error', 'all'],
|
|
182
|
+
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
183
|
+
'max-depth': ['error', 2],
|
|
184
|
+
'@stylistic/semi': ['error', 'always'],
|
|
185
|
+
'@stylistic/padding-line-between-statements': [
|
|
186
|
+
'error',
|
|
187
|
+
// Blank line after the import block
|
|
188
|
+
{ blankLine: 'always', prev: 'import', next: '*' },
|
|
189
|
+
{ blankLine: 'any', prev: 'import', next: 'import' },
|
|
190
|
+
// Blank line before return
|
|
191
|
+
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
192
|
+
// Blank line around block-like statements (if/for/while/switch/try)
|
|
193
|
+
{ blankLine: 'always', prev: 'block-like', next: '*' },
|
|
194
|
+
{ blankLine: 'always', prev: '*', next: 'block-like' },
|
|
195
|
+
// Blank line around function declarations
|
|
196
|
+
{ blankLine: 'always', prev: 'function', next: '*' },
|
|
197
|
+
{ blankLine: 'always', prev: '*', next: 'function' },
|
|
198
|
+
],
|
|
199
|
+
'@stylistic/max-len': [
|
|
200
|
+
'error',
|
|
201
|
+
{
|
|
202
|
+
code: 120,
|
|
203
|
+
tabWidth: 2,
|
|
204
|
+
ignoreComments: true,
|
|
205
|
+
ignoreUrls: true,
|
|
206
|
+
ignoreStrings: true,
|
|
207
|
+
ignoreTemplateLiterals: true,
|
|
208
|
+
ignoreRegExpLiterals: true,
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// Global ignores — applied regardless of .gitignore presence.
|
|
215
|
+
const ignores = {
|
|
216
|
+
name: 'blacklizard/ignores',
|
|
217
|
+
ignores: ['**/dist/**', '**/build/**', '**/coverage/**'],
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// CSS linting via @eslint/css.
|
|
221
|
+
const cssEntry = {
|
|
222
|
+
...cssPlugin.configs.recommended,
|
|
223
|
+
name: 'blacklizard/css',
|
|
224
|
+
files: ['**/*.css'],
|
|
225
|
+
language: 'css/css',
|
|
226
|
+
languageOptions: { tolerant: true },
|
|
227
|
+
rules: {
|
|
228
|
+
...cssPlugin.configs.recommended.rules,
|
|
229
|
+
// Tailwind at-rules (@apply, @theme, @utility, @variant, @tailwind) are
|
|
230
|
+
// not standard CSS — disable so they don't false-flag every Tailwind file.
|
|
231
|
+
'css/no-invalid-at-rules': 'off',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// HTML markup linting via @html-eslint.
|
|
236
|
+
const htmlEntry = {
|
|
237
|
+
...htmlPlugin.configs['flat/recommended'],
|
|
238
|
+
name: 'blacklizard/html',
|
|
239
|
+
files: ['**/*.html'],
|
|
240
|
+
language: '@html-eslint/html',
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// Relaxed rules for test files.
|
|
244
|
+
const testOverrides = {
|
|
245
|
+
name: 'blacklizard/test-overrides',
|
|
246
|
+
files: [
|
|
247
|
+
'**/*.{test,spec}.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}',
|
|
248
|
+
'**/__tests__/**',
|
|
249
|
+
],
|
|
250
|
+
rules: {
|
|
251
|
+
'no-unused-expressions': 'off',
|
|
252
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
253
|
+
'@stylistic/max-len': 'off',
|
|
254
|
+
// Test files import relative ESM modules — Node requires the extension.
|
|
255
|
+
'import-x/extensions': 'off',
|
|
256
|
+
'import-x/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// TypeScript config: base + node + typescript rules for .js/.ts files.
|
|
261
|
+
export const typescriptConfig = defineConfig([
|
|
262
|
+
ignores,
|
|
263
|
+
// Ignore files and folders listed in .gitignore when present
|
|
264
|
+
...gitignoreConfig,
|
|
265
|
+
...baseEntries,
|
|
266
|
+
...nodeEntries,
|
|
267
|
+
...typescriptEntries.map(scopeTs(TS_FILES)),
|
|
268
|
+
// Tailwind class linting for JSX/TSX
|
|
269
|
+
tailwindEntry(['**/*.jsx', '**/*.tsx']),
|
|
270
|
+
stylisticOverrides,
|
|
271
|
+
blacklizardOverrides,
|
|
272
|
+
testOverrides,
|
|
273
|
+
]);
|
|
274
|
+
|
|
275
|
+
// Vue config: everything in the TypeScript config, widened to .vue SFCs,
|
|
276
|
+
// plus eslint-plugin-vue recommended rules.
|
|
277
|
+
export const vueConfig = defineConfig([
|
|
278
|
+
ignores,
|
|
279
|
+
// Ignore files and folders listed in .gitignore when present
|
|
280
|
+
...gitignoreConfig,
|
|
281
|
+
...baseEntries.map(includeVue),
|
|
282
|
+
...nodeEntries.map(includeVue),
|
|
283
|
+
...typescriptEntries.map(scopeTs(TS_VUE_FILES)),
|
|
284
|
+
...vueEntries,
|
|
285
|
+
// Tailwind class linting for .vue SFCs and JSX/TSX
|
|
286
|
+
tailwindEntry([VUE_GLOB, '**/*.jsx', '**/*.tsx']),
|
|
287
|
+
stylisticOverrides,
|
|
288
|
+
blacklizardOverrides,
|
|
289
|
+
testOverrides,
|
|
290
|
+
]);
|
|
291
|
+
|
|
292
|
+
// HTML config: @html-eslint recommended markup rules for .html files.
|
|
293
|
+
export const htmlConfig = defineConfig([
|
|
294
|
+
ignores,
|
|
295
|
+
// Ignore files and folders listed in .gitignore when present
|
|
296
|
+
...gitignoreConfig,
|
|
297
|
+
htmlEntry,
|
|
298
|
+
]);
|
|
299
|
+
|
|
300
|
+
// CSS config: @eslint/css recommended rules for .css files.
|
|
301
|
+
export const cssConfig = defineConfig([
|
|
302
|
+
ignores,
|
|
303
|
+
// Ignore files and folders listed in .gitignore when present
|
|
304
|
+
...gitignoreConfig,
|
|
305
|
+
cssEntry,
|
|
306
|
+
]);
|
|
307
|
+
|
|
308
|
+
// Attach the Eta processor to .eta files — extracts the JS from exec tags.
|
|
309
|
+
const etaProcessorEntry = {
|
|
310
|
+
name: 'blacklizard/eta-processor',
|
|
311
|
+
files: ['**/*.eta'],
|
|
312
|
+
processor: etaProcessor,
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// Lint the extracted JS blocks (virtual path: <file>.eta/<n>_script.js).
|
|
316
|
+
const etaRulesEntry = {
|
|
317
|
+
name: 'blacklizard/eta',
|
|
318
|
+
files: ['**/*.eta/*.js'],
|
|
319
|
+
plugins: { '@stylistic': plugins.stylistic.plugins['@stylistic'] },
|
|
320
|
+
languageOptions: {
|
|
321
|
+
ecmaVersion: 'latest',
|
|
322
|
+
sourceType: 'script',
|
|
323
|
+
},
|
|
324
|
+
rules: {
|
|
325
|
+
// Off — template variables (it, layout data) are injected at render time.
|
|
326
|
+
'no-undef': 'off',
|
|
327
|
+
'no-unused-vars': 'off',
|
|
328
|
+
'no-unused-expressions': 'off',
|
|
329
|
+
strict: 'off',
|
|
330
|
+
// Off — the extractor masks non-JS regions with whitespace to preserve
|
|
331
|
+
// line numbers, which would otherwise trip every layout rule.
|
|
332
|
+
'@stylistic/indent': 'off',
|
|
333
|
+
'@stylistic/no-trailing-spaces': 'off',
|
|
334
|
+
'@stylistic/no-multiple-empty-lines': 'off',
|
|
335
|
+
'@stylistic/eol-last': 'off',
|
|
336
|
+
'@stylistic/max-len': 'off',
|
|
337
|
+
'@stylistic/padding-line-between-statements': 'off',
|
|
338
|
+
'@stylistic/lines-around-comment': 'off',
|
|
339
|
+
// Style — kept in sync with the rest of the config.
|
|
340
|
+
eqeqeq: ['error', 'always'],
|
|
341
|
+
'no-var': 'error',
|
|
342
|
+
'prefer-const': 'error',
|
|
343
|
+
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
344
|
+
'@stylistic/semi': ['error', 'always'],
|
|
345
|
+
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
|
|
346
|
+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// Eta config: lints the JS inside <% %> exec tags of .eta templates.
|
|
351
|
+
// Scope-dependent rules are off — template data is injected at render time.
|
|
352
|
+
export const etaConfig = defineConfig([
|
|
353
|
+
ignores,
|
|
354
|
+
// Ignore files and folders listed in .gitignore when present
|
|
355
|
+
...gitignoreConfig,
|
|
356
|
+
etaProcessorEntry,
|
|
357
|
+
etaRulesEntry,
|
|
358
|
+
]);
|
|
359
|
+
|
|
360
|
+
// Auto config: all of the above in one. Every entry is scoped by file
|
|
361
|
+
// extension, so ESLint applies the right rules per file with no manual
|
|
362
|
+
// selection — .ts/.js, .vue, .html, .css and .eta all just work.
|
|
363
|
+
export const autoConfig = defineConfig([
|
|
364
|
+
ignores,
|
|
365
|
+
// Ignore files and folders listed in .gitignore when present
|
|
366
|
+
...gitignoreConfig,
|
|
367
|
+
...baseEntries.map(includeVue).map(ensureScriptScope),
|
|
368
|
+
...nodeEntries.map(includeVue).map(ensureScriptScope),
|
|
369
|
+
...typescriptEntries.map(scopeTs(TS_VUE_FILES)),
|
|
370
|
+
...vueEntries.map(ensureVueScope),
|
|
371
|
+
// Tailwind class linting for .vue SFCs and JSX/TSX
|
|
372
|
+
tailwindEntry([VUE_GLOB, '**/*.jsx', '**/*.tsx']),
|
|
373
|
+
htmlEntry,
|
|
374
|
+
cssEntry,
|
|
375
|
+
etaProcessorEntry,
|
|
376
|
+
etaRulesEntry,
|
|
377
|
+
stylisticOverrides,
|
|
378
|
+
blacklizardOverrides,
|
|
379
|
+
testOverrides,
|
|
380
|
+
]);
|
|
381
|
+
|
|
382
|
+
export default autoConfig;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blacklizard/eslint-blacklizard",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reusable, opinionated ESLint config — blacklizard code standards.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "eslint.config.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./eslint.config.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"eslint.config.mjs",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"test": "node --test",
|
|
17
|
+
"changeset": "changeset",
|
|
18
|
+
"version": "changeset version",
|
|
19
|
+
"release": "pnpm lint && pnpm test && git tag \"v$npm_package_version\" && git push --follow-tags"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"eslint",
|
|
23
|
+
"eslintconfig",
|
|
24
|
+
"eslint-config",
|
|
25
|
+
"shareable-config",
|
|
26
|
+
"airbnb",
|
|
27
|
+
"lint",
|
|
28
|
+
"code-style"
|
|
29
|
+
],
|
|
30
|
+
"author": "blacklizard",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"eslint": ">=9"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=24",
|
|
40
|
+
"pnpm": ">=10"
|
|
41
|
+
},
|
|
42
|
+
"packageManager": "pnpm@10.33.0",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@eslint/compat": "^2.1.0",
|
|
45
|
+
"@eslint/css": "^1.2.0",
|
|
46
|
+
"@eslint/js": "^9.39.4",
|
|
47
|
+
"@html-eslint/eslint-plugin": "^0.60.0",
|
|
48
|
+
"@html-eslint/parser": "^0.60.0",
|
|
49
|
+
"@typescript-eslint/parser": "^8.59.3",
|
|
50
|
+
"eslint-config-airbnb-extended": "^3.1.0",
|
|
51
|
+
"eslint-plugin-better-tailwindcss": "^4.5.0",
|
|
52
|
+
"eslint-plugin-vue": "^10.9.1",
|
|
53
|
+
"vue-eslint-parser": "^10.4.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@changesets/cli": "^2.31.0",
|
|
57
|
+
"eslint": "^9.39.4",
|
|
58
|
+
"tailwindcss": "^4.3.0"
|
|
59
|
+
}
|
|
60
|
+
}
|