@micelio/eslint-config 0.0.0-stage → 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 +16 -0
- package/README.md +23 -2
- package/dist/index.d.ts +32 -0
- package/dist/index.js +79 -0
- package/licenses.json +24 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT No Attribution
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alejandro Ramirez Garcia and the Micelio contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
6
|
+
software and associated documentation files (the "Software"), to deal in the Software
|
|
7
|
+
without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
8
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
9
|
+
to whom the Software is furnished to do so.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
12
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
13
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
|
14
|
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
15
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
16
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @micelio/eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The ESLint flat config of the Micelio repositories (sections 4 and 15 of the
|
|
4
|
+
engineering standard) and the licence allowlist that `npm run lint:licenses` reads.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
// eslint.config.js
|
|
8
|
+
import micelio from '@micelio/eslint-config'
|
|
9
|
+
|
|
10
|
+
export default [...micelio, { ignores: ['generated/**'] }]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
It extends `typescript-eslint`'s recommended rules and `eslint-config-prettier`, bans
|
|
14
|
+
promise chains and `console.log` (except in `scripts/`), and in `.ts` files requires
|
|
15
|
+
typed module boundaries (`explicit-module-boundary-types`), valid TSDoc (`tsdoc/syntax`) and a doc
|
|
16
|
+
comment on every public export (`jsdoc/require-jsdoc`). `eslint` and `typescript` are
|
|
17
|
+
peer dependencies. A flat-config override of `no-restricted-syntax` replaces the option
|
|
18
|
+
list, so a repository that adds selectors spreads `promiseChainRestriction` back in.
|
|
19
|
+
|
|
20
|
+
## Licence allowlist
|
|
21
|
+
|
|
22
|
+
`@micelio/eslint-config/licenses.json` holds `allowed`, `allowedPrefixes` and
|
|
23
|
+
`allowedGpl2`: the SPDX identifiers a production dependency may carry (ADR 0007). The
|
|
24
|
+
repository's `lint:licenses` script reads it and evaluates SPDX expressions against it.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* The `no-restricted-syntax` entry that bans `.then()`, `.catch()` and `.finally()` chains.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A flat-config override of `no-restricted-syntax` replaces the whole option list, so a
|
|
7
|
+
* repository that adds its own selectors spreads this one back in:
|
|
8
|
+
* `['error', promiseChainRestriction, { selector: '…', message: '…' }]`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const promiseChainRestriction: {
|
|
11
|
+
readonly selector: "CallExpression[callee.type='MemberExpression'][callee.property.name=/^(then|catch|finally)$/]";
|
|
12
|
+
readonly message: "No promise chains: use await with try/catch (AGENTS.md, Async code).";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The ESLint flat config shared by every Micelio repository (standard, sections 4 and 15).
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* It extends `typescript-eslint`'s recommended rules, turns off the rules Prettier owns,
|
|
19
|
+
* bans promise chains and `console.log` (outside `scripts/`) and, in `.ts` files, requires
|
|
20
|
+
* typed module boundaries, valid TSDoc (`tsdoc/syntax`) and a doc comment on every public export
|
|
21
|
+
* (`jsdoc/require-jsdoc`). Spread it in the repository's
|
|
22
|
+
* `eslint.config.js` and add the repository's own entries after it.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import micelio from '@micelio/eslint-config';
|
|
27
|
+
*
|
|
28
|
+
* export default [...micelio, { ignores: ['generated/**'] }];
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const config: Linter.Config[];
|
|
32
|
+
export default config;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
3
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
4
|
+
import tsdoc from 'eslint-plugin-tsdoc';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
/** Message shown when code chains a promise instead of awaiting it. */
|
|
7
|
+
const PROMISE_CHAIN_MESSAGE = 'No promise chains: use await with try/catch (AGENTS.md, Async code).';
|
|
8
|
+
/**
|
|
9
|
+
* The `no-restricted-syntax` entry that bans `.then()`, `.catch()` and `.finally()` chains.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* A flat-config override of `no-restricted-syntax` replaces the whole option list, so a
|
|
13
|
+
* repository that adds its own selectors spreads this one back in:
|
|
14
|
+
* `['error', promiseChainRestriction, { selector: '…', message: '…' }]`.
|
|
15
|
+
*/
|
|
16
|
+
export const promiseChainRestriction = {
|
|
17
|
+
selector: "CallExpression[callee.type='MemberExpression'][callee.property.name=/^(then|catch|finally)$/]",
|
|
18
|
+
message: PROMISE_CHAIN_MESSAGE,
|
|
19
|
+
};
|
|
20
|
+
/** Files that never need a doc comment: declarations, build output and tests. */
|
|
21
|
+
const UNDOCUMENTED_FILES = ['**/*.d.ts', 'dist/**', 'test/**', 'tests/**', 'e2e/**', '**/*.test.ts'];
|
|
22
|
+
/**
|
|
23
|
+
* The ESLint flat config shared by every Micelio repository (standard, sections 4 and 15).
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* It extends `typescript-eslint`'s recommended rules, turns off the rules Prettier owns,
|
|
27
|
+
* bans promise chains and `console.log` (outside `scripts/`) and, in `.ts` files, requires
|
|
28
|
+
* typed module boundaries, valid TSDoc (`tsdoc/syntax`) and a doc comment on every public export
|
|
29
|
+
* (`jsdoc/require-jsdoc`). Spread it in the repository's
|
|
30
|
+
* `eslint.config.js` and add the repository's own entries after it.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import micelio from '@micelio/eslint-config';
|
|
35
|
+
*
|
|
36
|
+
* export default [...micelio, { ignores: ['generated/**'] }];
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
const config = defineConfig({
|
|
40
|
+
ignores: ['dist/', 'build/', 'coverage/', 'node_modules/', '.tmp/', '.cache/'],
|
|
41
|
+
}, tseslint.configs.recommended, eslintConfigPrettier, {
|
|
42
|
+
files: ['**/*.ts', '**/*.js', '**/*.mjs'],
|
|
43
|
+
languageOptions: {
|
|
44
|
+
ecmaVersion: 2023,
|
|
45
|
+
sourceType: 'module',
|
|
46
|
+
},
|
|
47
|
+
rules: {
|
|
48
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
49
|
+
'no-restricted-syntax': ['error', promiseChainRestriction],
|
|
50
|
+
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
51
|
+
},
|
|
52
|
+
}, {
|
|
53
|
+
// Scripts talk to the terminal (standard, section 4, "Errors and logging")
|
|
54
|
+
files: ['scripts/**', '.claude/skills/**/scripts/**'],
|
|
55
|
+
rules: { 'no-console': 'off' },
|
|
56
|
+
}, {
|
|
57
|
+
files: ['**/*.ts'],
|
|
58
|
+
ignores: UNDOCUMENTED_FILES,
|
|
59
|
+
plugins: { tsdoc, jsdoc },
|
|
60
|
+
rules: {
|
|
61
|
+
// Exported functions declare their parameter and return types (standard, section 4)
|
|
62
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
63
|
+
'tsdoc/syntax': 'error',
|
|
64
|
+
'jsdoc/require-jsdoc': [
|
|
65
|
+
'error',
|
|
66
|
+
{
|
|
67
|
+
publicOnly: true,
|
|
68
|
+
require: { FunctionDeclaration: true, ClassDeclaration: true },
|
|
69
|
+
contexts: [
|
|
70
|
+
'ExportNamedDeclaration > TSInterfaceDeclaration',
|
|
71
|
+
'ExportNamedDeclaration > TSTypeAliasDeclaration',
|
|
72
|
+
'ExportNamedDeclaration > TSEnumDeclaration',
|
|
73
|
+
'ExportNamedDeclaration > VariableDeclaration',
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
export default config;
|
package/licenses.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Licences a production dependency may carry (ADR 0007, AGPL-3.0-only). SPDX expressions are judged by the repository's lint:licenses script: OR passes if one side is allowed, AND needs all, `X WITH exception` is judged by X. Dev-only dependencies are not distributed and only warn.",
|
|
3
|
+
"allowed": [
|
|
4
|
+
"MIT",
|
|
5
|
+
"ISC",
|
|
6
|
+
"BSD-2-Clause",
|
|
7
|
+
"BSD-3-Clause",
|
|
8
|
+
"0BSD",
|
|
9
|
+
"Apache-2.0",
|
|
10
|
+
"MPL-2.0",
|
|
11
|
+
"CC0-1.0",
|
|
12
|
+
"MIT-0",
|
|
13
|
+
"CC-BY-3.0",
|
|
14
|
+
"CC-BY-4.0",
|
|
15
|
+
"Unlicense",
|
|
16
|
+
"BlueOak-1.0.0",
|
|
17
|
+
"Python-2.0",
|
|
18
|
+
"Zlib",
|
|
19
|
+
"OFL-1.1",
|
|
20
|
+
"WTFPL"
|
|
21
|
+
],
|
|
22
|
+
"allowedPrefixes": ["LGPL-", "GPL-3.0", "AGPL-3.0"],
|
|
23
|
+
"allowedGpl2": ["GPL-2.0-or-later", "GPL-2.0+"]
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micelio/eslint-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The ESLint flat config of the Micelio repositories, and the licence allowlist behind lint:licenses.",
|
|
5
|
+
"license": "MIT-0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/bogd3v/micelio-engineering.git",
|
|
9
|
+
"directory": "packages/eslint-config"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./licenses.json": "./licenses.json",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"licenses.json",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.12"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"eslint-config-prettier": "^10.1.8",
|
|
33
|
+
"eslint-plugin-jsdoc": "^65.3.6",
|
|
34
|
+
"eslint-plugin-tsdoc": "0.5.4",
|
|
35
|
+
"typescript-eslint": "^8.71.2"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"eslint": "^10.12.0",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"provenance": true
|
|
44
|
+
}
|
|
45
|
+
}
|