@stride.it/appoint-lint-governance 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/README.md +63 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @stride-info-tech/appoint-lint-governance
|
|
2
|
+
|
|
3
|
+
Shareable ESLint **flat-config** profiles for normalizing lint rules across repositories.
|
|
4
|
+
|
|
5
|
+
## MVP: TypeScript profile
|
|
6
|
+
|
|
7
|
+
This package currently ships a minimal TypeScript profile to prove end-to-end packaging + consumption.
|
|
8
|
+
|
|
9
|
+
Exports:
|
|
10
|
+
|
|
11
|
+
- `typescriptMinimal()` — MVP profile (enables TS parsing + 1 rule)
|
|
12
|
+
- `typescriptRecommended()` — optional profile that layers in TypeScript ESLint recommended presets
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
In a consumer repo:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add -D @stride-info-tech/appoint-lint-governance eslint
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Use in a consumer repo (ESLint v9 flat config)
|
|
23
|
+
|
|
24
|
+
Create (or edit) `eslint.config.mjs`:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { typescriptMinimal } from "@stride-info-tech/appoint-lint-governance";
|
|
28
|
+
|
|
29
|
+
export default [
|
|
30
|
+
...typescriptMinimal(),
|
|
31
|
+
// overrides go last
|
|
32
|
+
{
|
|
33
|
+
rules: {
|
|
34
|
+
// example override
|
|
35
|
+
"@typescript-eslint/consistent-type-imports": "warn",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Local testing (before publishing to npm)
|
|
42
|
+
|
|
43
|
+
From this repo:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm install
|
|
47
|
+
pnpm build
|
|
48
|
+
npm pack
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Then in a different repo, install the generated `.tgz`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm add -D ../appoint-lint-governance/<generated-file>.tgz
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Can consumer repos override rules?
|
|
58
|
+
|
|
59
|
+
Yes.
|
|
60
|
+
|
|
61
|
+
In flat config, **later config entries win**. So a consumer can override by adding their own config object after spreading the profile (as shown above).
|
|
62
|
+
|
|
63
|
+
If you want to prevent overrides for governance reasons, ESLint itself cannot “lock” consumer rules — you’d enforce that via policy/CI (for example: validate `eslint.config.*` in consumers and fail if it sets forbidden overrides).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ESLint } from 'eslint';
|
|
2
|
+
import * as typescript_eslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Placeholder for future custom rules.
|
|
6
|
+
*
|
|
7
|
+
* Exporting a plugin object now keeps the package structure stable as you add
|
|
8
|
+
* domain-specific rules later.
|
|
9
|
+
*/
|
|
10
|
+
declare const plugin: ESLint.Plugin;
|
|
11
|
+
|
|
12
|
+
type TypescriptConfigFiles = string[];
|
|
13
|
+
interface TypescriptMinimalOptions {
|
|
14
|
+
files?: TypescriptConfigFiles;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* MVP TypeScript profile.
|
|
18
|
+
*
|
|
19
|
+
* Intentionally minimal: enables TypeScript parsing and one rule to prove
|
|
20
|
+
* end-to-end packaging + consumption.
|
|
21
|
+
*/
|
|
22
|
+
declare function typescriptMinimal(options?: TypescriptMinimalOptions): typescript_eslint.FlatConfig.ConfigArray;
|
|
23
|
+
|
|
24
|
+
interface TypescriptRecommendedOptions {
|
|
25
|
+
/**
|
|
26
|
+
* When set, enables type-aware rules (more powerful, can be slower).
|
|
27
|
+
*
|
|
28
|
+
* Recommended for mature codebases, but not required for MVP.
|
|
29
|
+
*/
|
|
30
|
+
typeChecked?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Type-aware linting requires a project TSConfig.
|
|
33
|
+
* Example: "./tsconfig.json".
|
|
34
|
+
*/
|
|
35
|
+
tsconfigPath?: string | string[];
|
|
36
|
+
/**
|
|
37
|
+
* tsconfigRootDir should usually be import.meta.dirname from the consumer repo.
|
|
38
|
+
*/
|
|
39
|
+
tsconfigRootDir?: string;
|
|
40
|
+
files?: string[];
|
|
41
|
+
}
|
|
42
|
+
declare function typescriptRecommended(options?: TypescriptRecommendedOptions): typescript_eslint.FlatConfig.ConfigArray;
|
|
43
|
+
|
|
44
|
+
export { type TypescriptMinimalOptions, type TypescriptRecommendedOptions, plugin, typescriptMinimal, typescriptRecommended };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/plugin/index.ts
|
|
2
|
+
var plugin = {
|
|
3
|
+
rules: {}
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// src/configs/typescript/minimal.ts
|
|
7
|
+
import tseslint from "typescript-eslint";
|
|
8
|
+
function typescriptMinimal(options = {}) {
|
|
9
|
+
const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
|
|
10
|
+
return tseslint.config(
|
|
11
|
+
{
|
|
12
|
+
files,
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parserOptions: {
|
|
15
|
+
ecmaVersion: "latest",
|
|
16
|
+
sourceType: "module"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
rules: {
|
|
22
|
+
"@typescript-eslint/consistent-type-imports": "error"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/configs/typescript/recommended.ts
|
|
29
|
+
import tseslint2 from "typescript-eslint";
|
|
30
|
+
function typescriptRecommended(options = {}) {
|
|
31
|
+
const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
|
|
32
|
+
const configs = options.typeChecked ? tseslint2.configs.recommendedTypeChecked : tseslint2.configs.recommended;
|
|
33
|
+
return tseslint2.config(...configs, {
|
|
34
|
+
files,
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
ecmaVersion: "latest",
|
|
38
|
+
sourceType: "module",
|
|
39
|
+
...options.typeChecked ? {
|
|
40
|
+
project: options.tsconfigPath ?? "./tsconfig.json",
|
|
41
|
+
tsconfigRootDir: options.tsconfigRootDir
|
|
42
|
+
} : {}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
plugin,
|
|
49
|
+
typescriptMinimal,
|
|
50
|
+
typescriptRecommended
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin/index.ts","../src/configs/typescript/minimal.ts","../src/configs/typescript/recommended.ts"],"sourcesContent":["import type { ESLint } from \"eslint\";\r\n\r\n/**\r\n * Placeholder for future custom rules.\r\n *\r\n * Exporting a plugin object now keeps the package structure stable as you add\r\n * domain-specific rules later.\r\n */\r\nexport const plugin: ESLint.Plugin = {\r\n rules: {},\r\n};\r\n","import tseslint from \"typescript-eslint\";\r\n\r\nexport type TypescriptConfigFiles = string[];\r\n\r\nexport interface TypescriptMinimalOptions {\r\n files?: TypescriptConfigFiles;\r\n}\r\n\r\n/**\r\n * MVP TypeScript profile.\r\n *\r\n * Intentionally minimal: enables TypeScript parsing and one rule to prove\r\n * end-to-end packaging + consumption.\r\n */\r\nexport function typescriptMinimal(options: TypescriptMinimalOptions = {}) {\r\n const files = options.files ?? [\"**/*.{ts,tsx,mts,cts}\"];\r\n\r\n return tseslint.config(\r\n {\r\n files,\r\n languageOptions: {\r\n parserOptions: {\r\n ecmaVersion: \"latest\",\r\n sourceType: \"module\",\r\n },\r\n },\r\n },\r\n {\r\n rules: {\r\n \"@typescript-eslint/consistent-type-imports\": \"error\",\r\n },\r\n }\r\n );\r\n}\r\n","import tseslint from \"typescript-eslint\";\r\n\r\nexport interface TypescriptRecommendedOptions {\r\n /**\r\n * When set, enables type-aware rules (more powerful, can be slower).\r\n *\r\n * Recommended for mature codebases, but not required for MVP.\r\n */\r\n typeChecked?: boolean;\r\n\r\n /**\r\n * Type-aware linting requires a project TSConfig.\r\n * Example: \"./tsconfig.json\".\r\n */\r\n tsconfigPath?: string | string[];\r\n\r\n /**\r\n * tsconfigRootDir should usually be import.meta.dirname from the consumer repo.\r\n */\r\n tsconfigRootDir?: string;\r\n\r\n files?: string[];\r\n}\r\n\r\nexport function typescriptRecommended(\r\n options: TypescriptRecommendedOptions = {}\r\n) {\r\n const files = options.files ?? [\"**/*.{ts,tsx,mts,cts}\"];\r\n\r\n const configs = options.typeChecked\r\n ? tseslint.configs.recommendedTypeChecked\r\n : tseslint.configs.recommended;\r\n\r\n return tseslint.config(...configs, {\r\n files,\r\n languageOptions: {\r\n parserOptions: {\r\n ecmaVersion: \"latest\",\r\n sourceType: \"module\",\r\n ...(options.typeChecked\r\n ? {\r\n project: options.tsconfigPath ?? \"./tsconfig.json\",\r\n tsconfigRootDir: options.tsconfigRootDir,\r\n }\r\n : {}),\r\n },\r\n },\r\n });\r\n}\r\n"],"mappings":";AAQO,IAAM,SAAwB;AAAA,EACnC,OAAO,CAAC;AACV;;;ACVA,OAAO,cAAc;AAcd,SAAS,kBAAkB,UAAoC,CAAC,GAAG;AACxE,QAAM,QAAQ,QAAQ,SAAS,CAAC,uBAAuB;AAEvD,SAAO,SAAS;AAAA,IACd;AAAA,MACE;AAAA,MACA,iBAAiB;AAAA,QACf,eAAe;AAAA,UACb,aAAa;AAAA,UACb,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,OAAO;AAAA,QACL,8CAA8C;AAAA,MAChD;AAAA,IACF;AAAA,EACF;AACF;;;ACjCA,OAAOA,eAAc;AAwBd,SAAS,sBACd,UAAwC,CAAC,GACzC;AACA,QAAM,QAAQ,QAAQ,SAAS,CAAC,uBAAuB;AAEvD,QAAM,UAAU,QAAQ,cACpBA,UAAS,QAAQ,yBACjBA,UAAS,QAAQ;AAErB,SAAOA,UAAS,OAAO,GAAG,SAAS;AAAA,IACjC;AAAA,IACA,iBAAiB;AAAA,MACf,eAAe;AAAA,QACb,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,GAAI,QAAQ,cACR;AAAA,UACE,SAAS,QAAQ,gBAAgB;AAAA,UACjC,iBAAiB,QAAQ;AAAA,QAC3B,IACA,CAAC;AAAA,MACP;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":["tseslint"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stride.it/appoint-lint-governance",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shareable ESLint flat-config profiles (MVP: TypeScript) for normalizing lint across repos.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"typescript-eslint": "^8.44.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"eslint": "^9.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^25.0.8",
|
|
29
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
30
|
+
"eslint": "^9.39.2",
|
|
31
|
+
"husky": "^9.1.7",
|
|
32
|
+
"lint-staged": "^16.2.7",
|
|
33
|
+
"tsup": "^8.5.0",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vitest": "^4.0.17"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"lint": "eslint .",
|
|
40
|
+
"lint:fix": "eslint . --fix",
|
|
41
|
+
"test": "vitest run --passWithNoTests"
|
|
42
|
+
}
|
|
43
|
+
}
|