@ankhorage/devtools 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 +78 -0
- package/dist/eslint.d.ts +11 -0
- package/dist/eslint.js +106 -0
- package/dist/prettier.cjs +9 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +1 -0
- package/examples/monorepo/eslint.config.mjs +12 -0
- package/examples/package/.prettierignore +5 -0
- package/examples/package/eslint.config.mjs +11 -0
- package/examples/package/prettier.config.cjs +2 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fabio Gartenmann
|
|
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,78 @@
|
|
|
1
|
+
# @ankhorage/devtools
|
|
2
|
+
|
|
3
|
+
Shared Lint and Format Configuration for Ankhorage.
|
|
4
|
+
|
|
5
|
+
This package provides a unified, modern ESLint and Prettier configuration policy used across Ankhorage projects. It is built on top of **ESLint Flat Config** and **typescript-eslint**, ensuring a seamless, type-safe development experience.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add -d @ankhorage/devtools
|
|
11
|
+
# or
|
|
12
|
+
npm install --save-dev @ankhorage/devtools
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **One Package, Two Exports**: Access everything via `@ankhorage/devtools/eslint` and `@ankhorage/devtools/prettier`.
|
|
18
|
+
- **Modern Standards**: Built for ESLint 9+ and Prettier 3+.
|
|
19
|
+
- **Type-Safe**: Uses `typescript-eslint`'s recommended type-checked and stylistic rules.
|
|
20
|
+
- **Unified Policy**: Converges all repositories to a single, high-quality linting standard.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### ESLint
|
|
25
|
+
|
|
26
|
+
Create an `eslint.config.mjs` file in your project root:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
import path from 'node:path';
|
|
30
|
+
import { fileURLToPath } from 'node:url';
|
|
31
|
+
import { createConfig } from '@ankhorage/devtools/eslint';
|
|
32
|
+
|
|
33
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
34
|
+
|
|
35
|
+
export default createConfig({
|
|
36
|
+
tsconfigRootDir: __dirname,
|
|
37
|
+
project: ['./tsconfig.json'],
|
|
38
|
+
files: ['src/**/*.ts'],
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Configuration Options
|
|
43
|
+
|
|
44
|
+
The `createConfig` function accepts the following required options:
|
|
45
|
+
|
|
46
|
+
- `tsconfigRootDir`: The root directory for tsconfig resolution (typically `import.meta.dirname` or equivalent).
|
|
47
|
+
- `project`: An array of paths to your `tsconfig` files (e.g., `['./tsconfig.json']`).
|
|
48
|
+
- `files`: An array of glob patterns for the files you want to lint (e.g., `['src/**/*.{ts,tsx}']`).
|
|
49
|
+
|
|
50
|
+
Optional options:
|
|
51
|
+
|
|
52
|
+
- `allowDefaultProject`: Glob patterns for files to allow in the default project.
|
|
53
|
+
- `additionalIgnores`: Extra glob patterns to ignore.
|
|
54
|
+
- `restrictedImports`: An array of `{ name, message }` objects to append to the default restricted imports.
|
|
55
|
+
- `overrides`: An array of raw ESLint flat config objects to append to the configuration.
|
|
56
|
+
- `includePrettier`: Whether to include the Prettier configuration (defaults to `true`).
|
|
57
|
+
|
|
58
|
+
### Prettier
|
|
59
|
+
|
|
60
|
+
Create a `prettier.config.cjs` file in your project root:
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
/** @type {import('prettier').Config} */
|
|
64
|
+
module.exports = require('@ankhorage/devtools/prettier');
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Note**: You should keep a local `.prettierignore` file in your repository to define ignored patterns.
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
Check the [examples](./examples) directory for copy-pasteable configurations:
|
|
72
|
+
|
|
73
|
+
- `examples/monorepo/eslint.config.mjs`: For monorepo project structures.
|
|
74
|
+
- `examples/package/eslint.config.mjs`: For standalone package structures.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
package/dist/eslint.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import tseslint from 'typescript-eslint';
|
|
2
|
+
import type { DevtoolsConfigOptions } from './types.js';
|
|
3
|
+
export declare const defaultIgnores: readonly ["**/ios/**", "**/android/**", "**/dist/**", "**/build/**", "**/.expo/**", "**/.next/**", "**/node_modules/**", "**/*.d.ts", "**/templates/**", "**/files/**"];
|
|
4
|
+
export declare const defaultRestrictedImports: readonly [{
|
|
5
|
+
readonly name: "react-native-reanimated-dnd";
|
|
6
|
+
readonly message: "Forbidden in monorepo. Use '@ankh/dnd' (boundary) instead.";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "@ankhorage/react-native-reanimated-dnd-web";
|
|
9
|
+
readonly message: "Forbidden in monorepo. Use '@ankh/dnd' (boundary) instead.";
|
|
10
|
+
}];
|
|
11
|
+
export declare function createConfig(options: DevtoolsConfigOptions): ReturnType<typeof tseslint.config>;
|
package/dist/eslint.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import prettierConfig from 'eslint-config-prettier';
|
|
3
|
+
import importPlugin from 'eslint-plugin-import';
|
|
4
|
+
import prettierPlugin from 'eslint-plugin-prettier';
|
|
5
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
6
|
+
import unusedImports from 'eslint-plugin-unused-imports';
|
|
7
|
+
import tseslint from 'typescript-eslint';
|
|
8
|
+
export const defaultIgnores = [
|
|
9
|
+
'**/ios/**',
|
|
10
|
+
'**/android/**',
|
|
11
|
+
'**/dist/**',
|
|
12
|
+
'**/build/**',
|
|
13
|
+
'**/.expo/**',
|
|
14
|
+
'**/.next/**',
|
|
15
|
+
'**/node_modules/**',
|
|
16
|
+
'**/*.d.ts',
|
|
17
|
+
'**/templates/**',
|
|
18
|
+
'**/files/**',
|
|
19
|
+
];
|
|
20
|
+
export const defaultRestrictedImports = [
|
|
21
|
+
{
|
|
22
|
+
name: 'react-native-reanimated-dnd',
|
|
23
|
+
message: "Forbidden in monorepo. Use '@ankh/dnd' (boundary) instead.",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: '@ankhorage/react-native-reanimated-dnd-web',
|
|
27
|
+
message: "Forbidden in monorepo. Use '@ankh/dnd' (boundary) instead.",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
export function createConfig(options) {
|
|
31
|
+
const normalizedOptions = {
|
|
32
|
+
allowDefaultProject: [],
|
|
33
|
+
additionalIgnores: [],
|
|
34
|
+
restrictedImports: [],
|
|
35
|
+
overrides: [],
|
|
36
|
+
includePrettier: true,
|
|
37
|
+
...options,
|
|
38
|
+
};
|
|
39
|
+
const combinedRestrictedImports = [
|
|
40
|
+
...defaultRestrictedImports,
|
|
41
|
+
...normalizedOptions.restrictedImports,
|
|
42
|
+
];
|
|
43
|
+
const plugins = {
|
|
44
|
+
import: importPlugin,
|
|
45
|
+
prettier: prettierPlugin,
|
|
46
|
+
'simple-import-sort': simpleImportSort,
|
|
47
|
+
'unused-imports': unusedImports,
|
|
48
|
+
};
|
|
49
|
+
return tseslint.config({
|
|
50
|
+
ignores: [...defaultIgnores, ...normalizedOptions.additionalIgnores],
|
|
51
|
+
}, js.configs.recommended, ...tseslint.configs.recommendedTypeChecked.map((config) => ({
|
|
52
|
+
...config,
|
|
53
|
+
files: normalizedOptions.files,
|
|
54
|
+
})), ...tseslint.configs.stylisticTypeChecked.map((config) => ({
|
|
55
|
+
...config,
|
|
56
|
+
files: normalizedOptions.files,
|
|
57
|
+
})), {
|
|
58
|
+
files: normalizedOptions.files,
|
|
59
|
+
languageOptions: {
|
|
60
|
+
parser: tseslint.parser,
|
|
61
|
+
parserOptions: {
|
|
62
|
+
project: normalizedOptions.project,
|
|
63
|
+
tsconfigRootDir: normalizedOptions.tsconfigRootDir,
|
|
64
|
+
allowDefaultProject: normalizedOptions.allowDefaultProject,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
plugins,
|
|
68
|
+
rules: {
|
|
69
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
70
|
+
'@typescript-eslint/prefer-readonly': 'error',
|
|
71
|
+
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
72
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
73
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
|
74
|
+
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
75
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
|
76
|
+
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
|
|
77
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
|
78
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
79
|
+
'no-restricted-imports': [
|
|
80
|
+
'error',
|
|
81
|
+
{
|
|
82
|
+
paths: combinedRestrictedImports,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
'prefer-destructuring': 'off',
|
|
86
|
+
'@typescript-eslint/prefer-destructuring': 'error',
|
|
87
|
+
'simple-import-sort/imports': 'error',
|
|
88
|
+
'simple-import-sort/exports': 'error',
|
|
89
|
+
'unused-imports/no-unused-imports': 'error',
|
|
90
|
+
'unused-imports/no-unused-vars': [
|
|
91
|
+
'error',
|
|
92
|
+
{
|
|
93
|
+
vars: 'all',
|
|
94
|
+
varsIgnorePattern: '^_',
|
|
95
|
+
args: 'after-used',
|
|
96
|
+
argsIgnorePattern: '^_',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
'import/order': 'off',
|
|
100
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
101
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
102
|
+
'prettier/prettier': 'error',
|
|
103
|
+
'no-console': 'off',
|
|
104
|
+
},
|
|
105
|
+
}, ...normalizedOptions.overrides, ...(normalizedOptions.includePrettier ? [prettierConfig] : []));
|
|
106
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type tseslint from 'typescript-eslint';
|
|
2
|
+
export type FlatConfig = ReturnType<typeof tseslint.config>;
|
|
3
|
+
export type FlatConfigItem = FlatConfig[number];
|
|
4
|
+
export interface RestrictedImport {
|
|
5
|
+
name: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DevtoolsConfigOptions {
|
|
9
|
+
tsconfigRootDir: string;
|
|
10
|
+
project: string[];
|
|
11
|
+
files: string[];
|
|
12
|
+
allowDefaultProject?: string[];
|
|
13
|
+
additionalIgnores?: string[];
|
|
14
|
+
restrictedImports?: RestrictedImport[];
|
|
15
|
+
overrides?: FlatConfigItem[];
|
|
16
|
+
includePrettier?: boolean;
|
|
17
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { createConfig } from '@ankhorage/devtools/eslint';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
export default createConfig({
|
|
8
|
+
tsconfigRootDir: __dirname,
|
|
9
|
+
project: ['./tsconfig.base.json'],
|
|
10
|
+
files: ['packages/**/src/**/*.{ts,tsx}', 'apps/**/src/**/*.{ts,tsx}', 'scripts/**/*.{ts,tsx}'],
|
|
11
|
+
allowDefaultProject: ['scripts/**/*.ts'],
|
|
12
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createConfig } from '@ankhorage/devtools/eslint';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
export default createConfig({
|
|
8
|
+
tsconfigRootDir: __dirname,
|
|
9
|
+
project: ['./tsconfig.eslint.json'],
|
|
10
|
+
files: ['src/**/*.{ts,tsx}'],
|
|
11
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ankhorage/devtools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared Lint and Format Configuration for Ankhorage",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
"./eslint": {
|
|
11
|
+
"types": "./dist/eslint.d.ts",
|
|
12
|
+
"import": "./dist/eslint.js"
|
|
13
|
+
},
|
|
14
|
+
"./prettier": {
|
|
15
|
+
"require": "./dist/prettier.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"examples"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc && cp src/prettier.cjs dist/prettier.cjs",
|
|
26
|
+
"lint": "eslint .",
|
|
27
|
+
"format": "prettier --write .",
|
|
28
|
+
"format:check": "prettier --check .",
|
|
29
|
+
"test": "bun test"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@eslint/js": "^10.0.1",
|
|
33
|
+
"eslint": "^10.2.0",
|
|
34
|
+
"eslint-config-prettier": "^10.1.8",
|
|
35
|
+
"eslint-plugin-import": "^2.32.0",
|
|
36
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
37
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
38
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
39
|
+
"prettier": "^3.8.1",
|
|
40
|
+
"typescript-eslint": "^8.24.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@changesets/cli": "^2.30.0",
|
|
44
|
+
"@types/node": "^25.2.3",
|
|
45
|
+
"bun-types": "^1.3.11",
|
|
46
|
+
"typescript": "^5.9.3"
|
|
47
|
+
}
|
|
48
|
+
}
|