@kristijorgji/eslint-config-typescript 0.0.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Kristi Jorgji
3
+ Copyright (c) 2026 kristijorgji
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,73 +1,45 @@
1
1
  # @kristijorgji/eslint-config-typescript
2
2
 
3
- A general-purpose ESLint and Prettier configuration for TypeScript projects (non-browser environments).
4
- If you need rules specific to React, Next.js, or other frameworks, you can extend or override these rules after including this config.
3
+ Flat ESLint config factory for TypeScript projects, built on
4
+ [`@kristijorgji/eslint-plugin`](https://www.npmjs.com/package/@kristijorgji/eslint-plugin).
5
5
 
6
- # Table of Contents
7
-
8
- - [Requirements](#requirements)
9
- - [Installation](#installation)
10
- - [Usage](#usage)
11
- - [Configuration](#configuration)
12
- - [Development](#development)
13
- - [License](#license)
14
-
15
- ## Requirements
16
-
17
- - ESLint version **>= 8.21.0** with support for Flat Config.
18
-
19
- ## Installation
20
-
21
- Install the package and peer dependencies using:
6
+ ## Install
22
7
 
23
8
  ```bash
24
- yarn add --dev @kristijorgji/eslint-config-typescript@latest
9
+ pnpm add -D @kristijorgji/eslint-config-typescript eslint typescript prettier
25
10
  ```
26
11
 
27
- > **Note:**
28
- > When migrating from an older ESLint setup, please remove conflicting or duplicate dependencies first, for example:
29
- > `yarn remove eslint prettier @typescript-eslint/eslint-plugin`
30
-
31
12
  ## Usage
32
13
 
33
- ### Configuration
34
-
35
- For ESLint **>= 9.x**, use `FlatCompat.extends` for compatibility.
36
-
37
- Example `eslint.config.js`:
38
-
39
14
  ```js
40
- const { FlatCompat } = require('@eslint/eslintrc');
41
- const js = require('@eslint/js');
42
- const { defineConfig } = require('eslint/config');
15
+ // eslint.config.js
16
+ import { createTypescriptConfig } from '@kristijorgji/eslint-config-typescript';
43
17
 
44
- const compat = new FlatCompat({
45
- baseDirectory: __dirname,
46
- recommendedConfig: js.configs.recommended,
47
- allConfig: js.configs.all,
18
+ export default createTypescriptConfig({
19
+ tsconfigRootDir: import.meta.dirname,
48
20
  });
49
-
50
- module.exports = defineConfig([
51
- {
52
- files: ['src/**/*.ts', '__tests__/**/*.ts'],
53
- extends: compat.extends('@kristijorgji/eslint-config-typescript'),
54
- },
55
- ]);
56
21
  ```
57
22
 
58
- ## Development
23
+ ### Options
59
24
 
60
- Learn more about creating custom ESLint configs here:
61
- [ESLint Shareable Configs Guide](https://eslint.org/docs/developer-guide/shareable-configs)
25
+ | Option | Description |
26
+ | --- | --- |
27
+ | `files` | Glob patterns (default `**/*.{ts,tsx}`) |
28
+ | `tsconfigRootDir` | Enables type-aware rules via `createTypedLintConfig` |
29
+ | `prettier` | `true` (default), `false`, or Prettier options object |
30
+ | `ignores` | Extra ignore globs |
62
31
 
63
- To develop locally, you can link your local package using:
32
+ ### Named exports / subpaths
64
33
 
65
- ```bash
66
- yarn add --dev /path/to/local/eslint-config-typescript
67
- ```
34
+ - `@kristijorgji/eslint-config-typescript` — factory + all named parts
35
+ - `./base` — `createBaseConfig` / `baseRules`
36
+ - `./typed` — `createTypedLintConfig`
37
+ - `./ignores` — default ignore block
68
38
 
69
- > You need to run this command after every change to your local plugin.
39
+ ### Plugin rule placement
70
40
 
71
- ## License
41
+ This package enables **`kj/no-pure-type-alias` only**. JSX leading-prop order,
42
+ single-export barrels, and component extraction live in
43
+ `@kristijorgji/eslint-config-react-typescript`.
72
44
 
73
- [MIT](LICENSE)
45
+ Vendored from [`eslint-config-typescript@702410cb`](https://github.com/kristijorgji/eslint-config-typescript/commit/702410cb03fb6f506d148cde7aa94d8a844d3621) and rewritten as an ESM flat-config factory.
package/dist/base.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { Linter } from 'eslint';
2
+ import { defaultPrettierOptions } from './prettier.js';
3
+ export interface BaseRulesOptions {
4
+ /** Whether to enable `prettier/prettier`. Defaults to true. */
5
+ prettier?: boolean | typeof defaultPrettierOptions;
6
+ }
7
+ /**
8
+ * Core TypeScript lint rules (no type-aware block).
9
+ * Includes `kj/no-pure-type-alias` only — single-export barrels and JSX prop order
10
+ * belong on the React factory (prona/sb split placement).
11
+ */
12
+ export declare function baseRules(options?: BaseRulesOptions): Linter.RulesRecord;
13
+ export interface BaseConfigOptions extends BaseRulesOptions {
14
+ files?: string[];
15
+ }
16
+ /** Flat config block for TypeScript sources (parser + plugins + base rules). */
17
+ export declare function createBaseConfig(options?: BaseConfigOptions): Linter.Config;
18
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOrC,OAAO,EAAE,sBAAsB,EAAiB,MAAM,eAAe,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,sBAAsB,CAAC;CACpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC,WAAW,CA0BxE;AAED,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,CA0B3E"}
package/dist/base.js ADDED
@@ -0,0 +1,66 @@
1
+ import js from '@eslint/js';
2
+ import { plugin as kjPlugin } from '@kristijorgji/eslint-plugin';
3
+ import importX from 'eslint-plugin-import-x';
4
+ import prettierPlugin from 'eslint-plugin-prettier';
5
+ import globals from 'globals';
6
+ import tseslint from 'typescript-eslint';
7
+ import { importOrderRules } from './import-order.js';
8
+ import { defaultPrettierOptions, prettierRules } from './prettier.js';
9
+ /**
10
+ * Core TypeScript lint rules (no type-aware block).
11
+ * Includes `kj/no-pure-type-alias` only — single-export barrels and JSX prop order
12
+ * belong on the React factory (prona/sb split placement).
13
+ */
14
+ export function baseRules(options) {
15
+ const prettier = options?.prettier ?? true;
16
+ const prettierOpts = prettier === false ? null : prettier === true ? defaultPrettierOptions : prettier;
17
+ return {
18
+ ...js.configs.recommended.rules,
19
+ 'no-unused-vars': 'off',
20
+ ...importOrderRules,
21
+ 'import-x/no-unresolved': 'off',
22
+ '@typescript-eslint/no-explicit-any': 'error',
23
+ '@typescript-eslint/no-unused-vars': [
24
+ 'error',
25
+ {
26
+ args: 'all',
27
+ argsIgnorePattern: '^_',
28
+ caughtErrors: 'all',
29
+ caughtErrorsIgnorePattern: '^_',
30
+ destructuredArrayIgnorePattern: '^_',
31
+ varsIgnorePattern: '^_',
32
+ ignoreRestSiblings: true,
33
+ },
34
+ ],
35
+ 'kj/no-pure-type-alias': 'error',
36
+ ...(prettierOpts ? prettierRules(prettierOpts) : {}),
37
+ };
38
+ }
39
+ /** Flat config block for TypeScript sources (parser + plugins + base rules). */
40
+ export function createBaseConfig(options) {
41
+ const files = options?.files ?? ['**/*.{ts,tsx}'];
42
+ return {
43
+ files,
44
+ languageOptions: {
45
+ ecmaVersion: 'latest',
46
+ sourceType: 'module',
47
+ globals: {
48
+ ...globals.node,
49
+ ...globals.es2021,
50
+ },
51
+ parser: tseslint.parser,
52
+ parserOptions: {
53
+ ecmaVersion: 'latest',
54
+ sourceType: 'module',
55
+ },
56
+ },
57
+ plugins: {
58
+ '@typescript-eslint': tseslint.plugin,
59
+ 'import-x': importX,
60
+ prettier: prettierPlugin,
61
+ kj: kjPlugin,
62
+ },
63
+ rules: baseRules(options),
64
+ };
65
+ }
66
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAOtE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAA0B;IAClD,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC;IAC3C,MAAM,YAAY,GAChB,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEpF,OAAO;QACL,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;QAC/B,gBAAgB,EAAE,KAAK;QACvB,GAAG,gBAAgB;QACnB,wBAAwB,EAAE,KAAK;QAC/B,oCAAoC,EAAE,OAAO;QAC7C,mCAAmC,EAAE;YACnC,OAAO;YACP;gBACE,IAAI,EAAE,KAAK;gBACX,iBAAiB,EAAE,IAAI;gBACvB,YAAY,EAAE,KAAK;gBACnB,yBAAyB,EAAE,IAAI;gBAC/B,8BAA8B,EAAE,IAAI;gBACpC,iBAAiB,EAAE,IAAI;gBACvB,kBAAkB,EAAE,IAAI;aACzB;SACF;QACD,uBAAuB,EAAE,OAAO;QAChC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC;AAMD,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,OAA2B;IAC1D,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,CAAC;IAElD,OAAO;QACL,KAAK;QACL,eAAe,EAAE;YACf,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE;gBACP,GAAG,OAAO,CAAC,IAAI;gBACf,GAAG,OAAO,CAAC,MAAM;aAClB;YACD,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,aAAa,EAAE;gBACb,WAAW,EAAE,QAAQ;gBACrB,UAAU,EAAE,QAAQ;aACrB;SACF;QACD,OAAO,EAAE;YACP,oBAAoB,EAAE,QAAQ,CAAC,MAAM;YACrC,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,cAAc;YACxB,EAAE,EAAE,QAAQ;SACb;QACD,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { Options as PrettierOptions } from 'prettier';
3
+ export interface CreateTypescriptConfigOptions {
4
+ /** Glob patterns for TypeScript files. Defaults to all `.ts` / `.tsx` files. */
5
+ files?: string[];
6
+ /**
7
+ * When set, appends the type-aware block (`createTypedLintConfig`).
8
+ * Required for `kj/no-weak-typeof-satisfies`.
9
+ */
10
+ tsconfigRootDir?: string;
11
+ /**
12
+ * Prettier integration. `true` (default) uses package defaults; pass an options
13
+ * object to override; `false` disables `prettier/prettier` (still applies prettierConfig last).
14
+ */
15
+ prettier?: boolean | PrettierOptions;
16
+ /** Extra ignore patterns merged into the default ignores block. */
17
+ ignores?: string[];
18
+ }
19
+ /**
20
+ * Flat ESLint config factory for TypeScript projects.
21
+ *
22
+ * Enables `kj/no-pure-type-alias` only from the plugin recommended set.
23
+ * Use `@kristijorgji/eslint-config-react-typescript` for JSX prop order,
24
+ * single-export barrels, and component-extraction rules.
25
+ */
26
+ export declare function createTypescriptConfig(options?: CreateTypescriptConfigOptions): Linter.Config[];
27
+ //# sourceMappingURL=create-typescript-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-typescript-config.d.ts","sourceRoot":"","sources":["../src/create-typescript-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAO3D,MAAM,WAAW,6BAA6B;IAC5C,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACrC,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,6BAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,CAsBnG"}
@@ -0,0 +1,32 @@
1
+ import prettierConfig from 'eslint-config-prettier';
2
+ import tseslint from 'typescript-eslint';
3
+ import { createBaseConfig } from './base.js';
4
+ import { ignores as defaultIgnores } from './ignores.js';
5
+ import { createTypedLintConfig } from './typed.js';
6
+ /**
7
+ * Flat ESLint config factory for TypeScript projects.
8
+ *
9
+ * Enables `kj/no-pure-type-alias` only from the plugin recommended set.
10
+ * Use `@kristijorgji/eslint-config-react-typescript` for JSX prop order,
11
+ * single-export barrels, and component-extraction rules.
12
+ */
13
+ export function createTypescriptConfig(options = {}) {
14
+ const files = options.files ?? ['**/*.{ts,tsx}'];
15
+ const ignorePatterns = options.ignores ?? [];
16
+ const configs = [
17
+ {
18
+ ignores: [...(defaultIgnores.ignores ?? []), ...ignorePatterns],
19
+ },
20
+ ...tseslint.configs.recommended,
21
+ createBaseConfig({
22
+ files,
23
+ prettier: options.prettier,
24
+ }),
25
+ ];
26
+ if (options.tsconfigRootDir) {
27
+ configs.push(createTypedLintConfig({ tsconfigRootDir: options.tsconfigRootDir }));
28
+ }
29
+ configs.push(prettierConfig);
30
+ return configs;
31
+ }
32
+ //# sourceMappingURL=create-typescript-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-typescript-config.js","sourceRoot":"","sources":["../src/create-typescript-config.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,wBAAwB,CAAC;AAGpD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAmBnD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAyC,EAAE;IAChF,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAE7C,MAAM,OAAO,GAAoB;QAC/B;YACE,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC;SAChE;QACD,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW;QAC/B,gBAAgB,CAAC;YACf,KAAK;YACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC;KACH,CAAC;IAEF,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAE7B,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ /** Default ignore patterns for TypeScript projects. */
3
+ export declare const ignores: Linter.Config;
4
+ //# sourceMappingURL=ignores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignores.d.ts","sourceRoot":"","sources":["../src/ignores.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,uDAAuD;AACvD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAS5B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** Default ignore patterns for TypeScript projects. */
2
+ export const ignores = {
3
+ ignores: [
4
+ '**/node_modules/**',
5
+ '**/dist/**',
6
+ '**/build/**',
7
+ '**/coverage/**',
8
+ '**/.next/**',
9
+ '**/storybook-static/**',
10
+ ],
11
+ };
12
+ //# sourceMappingURL=ignores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignores.js","sourceRoot":"","sources":["../src/ignores.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,OAAO,EAAE;QACP,oBAAoB;QACpB,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,aAAa;QACb,wBAAwB;KACzB;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ /**
3
+ * Import ordering rules using `eslint-plugin-import-x`.
4
+ * Exported so consumers can compose without taking the full factory.
5
+ */
6
+ export declare const importOrderRules: Linter.RulesRecord;
7
+ //# sourceMappingURL=import-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-order.d.ts","sourceRoot":"","sources":["../src/import-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,WAuBrC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Import ordering rules using `eslint-plugin-import-x`.
3
+ * Exported so consumers can compose without taking the full factory.
4
+ */
5
+ export const importOrderRules = {
6
+ 'import-x/first': 'error',
7
+ 'import-x/no-duplicates': 'error',
8
+ 'import-x/order': [
9
+ 'error',
10
+ {
11
+ groups: ['builtin', 'external', 'internal', ['parent', 'sibling']],
12
+ 'newlines-between': 'always',
13
+ alphabetize: {
14
+ order: 'asc',
15
+ caseInsensitive: true,
16
+ },
17
+ },
18
+ ],
19
+ 'sort-imports': [
20
+ 'error',
21
+ {
22
+ ignoreCase: true,
23
+ ignoreDeclarationSort: true,
24
+ ignoreMemberSort: false,
25
+ allowSeparatedGroups: true,
26
+ },
27
+ ],
28
+ };
29
+ //# sourceMappingURL=import-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-order.js","sourceRoot":"","sources":["../src/import-order.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuB;IAClD,gBAAgB,EAAE,OAAO;IACzB,wBAAwB,EAAE,OAAO;IACjC,gBAAgB,EAAE;QAChB,OAAO;QACP;YACE,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAClE,kBAAkB,EAAE,QAAQ;YAC5B,WAAW,EAAE;gBACX,KAAK,EAAE,KAAK;gBACZ,eAAe,EAAE,IAAI;aACtB;SACF;KACF;IACD,cAAc,EAAE;QACd,OAAO;QACP;YACE,UAAU,EAAE,IAAI;YAChB,qBAAqB,EAAE,IAAI;YAC3B,gBAAgB,EAAE,KAAK;YACvB,oBAAoB,EAAE,IAAI;SAC3B;KACF;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { baseRules, createBaseConfig, type BaseConfigOptions, type BaseRulesOptions } from './base.js';
2
+ export { createTypescriptConfig, type CreateTypescriptConfigOptions, } from './create-typescript-config.js';
3
+ export { ignores } from './ignores.js';
4
+ export { importOrderRules } from './import-order.js';
5
+ export { defaultPrettierOptions, prettierRules } from './prettier.js';
6
+ export { createTypedLintConfig, type CreateTypedLintConfigOptions, } from './typed.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvG,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { baseRules, createBaseConfig } from './base.js';
2
+ export { createTypescriptConfig, } from './create-typescript-config.js';
3
+ export { ignores } from './ignores.js';
4
+ export { importOrderRules } from './import-order.js';
5
+ export { defaultPrettierOptions, prettierRules } from './prettier.js';
6
+ export { createTypedLintConfig, } from './typed.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAiD,MAAM,WAAW,CAAC;AACvG,OAAO,EACL,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,qBAAqB,GAEtB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { Options as PrettierOptions } from 'prettier';
3
+ /** Default Prettier options embedded in `prettier/prettier` (legacy config parity). */
4
+ export declare const defaultPrettierOptions: PrettierOptions;
5
+ /**
6
+ * Builds the `prettier/prettier` rule entry.
7
+ * Pass `false` to `createTypescriptConfig({ prettier: false })` to skip.
8
+ */
9
+ export declare function prettierRules(options?: PrettierOptions): Linter.RulesRecord;
10
+ //# sourceMappingURL=prettier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../src/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3D,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,eAUpC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,eAAwC,GAAG,MAAM,CAAC,WAAW,CAInG"}
@@ -0,0 +1,22 @@
1
+ /** Default Prettier options embedded in `prettier/prettier` (legacy config parity). */
2
+ export const defaultPrettierOptions = {
3
+ arrowParens: 'avoid',
4
+ bracketSpacing: true,
5
+ printWidth: 120,
6
+ semi: true,
7
+ singleQuote: true,
8
+ tabWidth: 4,
9
+ trailingComma: 'all',
10
+ useTabs: false,
11
+ endOfLine: 'lf',
12
+ };
13
+ /**
14
+ * Builds the `prettier/prettier` rule entry.
15
+ * Pass `false` to `createTypescriptConfig({ prettier: false })` to skip.
16
+ */
17
+ export function prettierRules(options = defaultPrettierOptions) {
18
+ return {
19
+ 'prettier/prettier': ['error', options],
20
+ };
21
+ }
22
+ //# sourceMappingURL=prettier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.js","sourceRoot":"","sources":["../src/prettier.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,MAAM,CAAC,MAAM,sBAAsB,GAAoB;IACrD,WAAW,EAAE,OAAO;IACpB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,GAAG;IACf,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,KAAK;IACpB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,UAA2B,sBAAsB;IAC7E,OAAO;QACL,mBAAmB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;KACxC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Linter } from 'eslint';
2
+ export interface CreateTypedLintConfigOptions {
3
+ /** Directory containing the consumer's `tsconfig.json`. */
4
+ tsconfigRootDir: string;
5
+ severity?: 'error' | 'warn';
6
+ }
7
+ /**
8
+ * Type-aware ESLint block (ported from prona365 `createTypedLintConfig`).
9
+ * Enables `kj/no-weak-typeof-satisfies` plus `@typescript-eslint/no-unnecessary-type-assertion`.
10
+ */
11
+ export declare function createTypedLintConfig(options: CreateTypedLintConfigOptions): Linter.Config;
12
+ //# sourceMappingURL=typed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../src/typed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,WAAW,4BAA4B;IAC3C,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAiB1F"}
package/dist/typed.js ADDED
@@ -0,0 +1,22 @@
1
+ import { typed } from '@kristijorgji/eslint-plugin';
2
+ /**
3
+ * Type-aware ESLint block (ported from prona365 `createTypedLintConfig`).
4
+ * Enables `kj/no-weak-typeof-satisfies` plus `@typescript-eslint/no-unnecessary-type-assertion`.
5
+ */
6
+ export function createTypedLintConfig(options) {
7
+ const [weakTypeofConfig] = typed({
8
+ tsconfigRootDir: options.tsconfigRootDir,
9
+ severity: options.severity,
10
+ });
11
+ if (!weakTypeofConfig) {
12
+ throw new Error('typed() returned no config blocks');
13
+ }
14
+ return {
15
+ ...weakTypeofConfig,
16
+ rules: {
17
+ '@typescript-eslint/no-unnecessary-type-assertion': 'error',
18
+ ...weakTypeofConfig.rules,
19
+ },
20
+ };
21
+ }
22
+ //# sourceMappingURL=typed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed.js","sourceRoot":"","sources":["../src/typed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AASpD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAqC;IACzE,MAAM,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC;QAC/B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,OAAO;QACL,GAAG,gBAAgB;QACnB,KAAK,EAAE;YACL,kDAAkD,EAAE,OAAO;YAC3D,GAAG,gBAAgB,CAAC,KAAK;SAC1B;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,43 +1,71 @@
1
1
  {
2
2
  "name": "@kristijorgji/eslint-config-typescript",
3
- "version": "0.0.3",
4
- "description": "eslint config for typescript based projects",
3
+ "version": "1.0.0",
4
+ "description": "Flat ESLint TypeScript config factory built on @kristijorgji/eslint-plugin",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "kristijorgji",
8
+ "engines": {
9
+ "node": ">=22.16.0"
10
+ },
5
11
  "publishConfig": {
6
- "access": "public"
12
+ "access": "public",
13
+ "provenance": false
7
14
  },
8
- "type": "module",
9
- "main": "index.cjs",
10
- "scripts": {
11
- "test": "NODE_OPTIONS='--experimental-vm-modules' jest"
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/kristijorgji/js-devkit.git",
18
+ "directory": "packages/eslint-config-typescript"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./base": {
31
+ "types": "./dist/base.d.ts",
32
+ "import": "./dist/base.js"
33
+ },
34
+ "./typed": {
35
+ "types": "./dist/typed.d.ts",
36
+ "import": "./dist/typed.js"
37
+ },
38
+ "./ignores": {
39
+ "types": "./dist/ignores.d.ts",
40
+ "import": "./dist/ignores.js"
41
+ }
42
+ },
43
+ "types": "./dist/index.d.ts",
44
+ "peerDependencies": {
45
+ "eslint": "^9 || ^10",
46
+ "prettier": "^3",
47
+ "typescript": "^5 || ^6"
12
48
  },
13
49
  "dependencies": {
14
- "@eslint/eslintrc": "^3.3.1",
15
- "@eslint/js": "^9.27.0",
16
- "@typescript-eslint/eslint-plugin": "^8.33.0",
17
- "@typescript-eslint/parser": "^8.33.0",
18
- "eslint": "^9.27.0",
19
- "eslint-config-prettier": "^10.1.5",
20
- "eslint-config-standard": "^17.1.0",
21
- "eslint-import-resolver-typescript": "^4.4.1",
22
- "eslint-plugin-import": "^2.31.0",
23
- "eslint-plugin-prettier": "^5.4.0",
24
- "globals": "^16.2.0",
25
- "prettier": "3.5.3"
50
+ "@eslint/js": "^9",
51
+ "eslint-config-prettier": "^10",
52
+ "eslint-plugin-import-x": "^4",
53
+ "eslint-plugin-prettier": "^5",
54
+ "globals": "^16",
55
+ "typescript-eslint": "^8",
56
+ "@kristijorgji/eslint-plugin": "^0.1.0"
26
57
  },
27
- "keywords": [
28
- "eslint",
29
- "typescript"
30
- ],
31
- "author": "kristijorgji",
32
- "license": "MIT",
33
58
  "devDependencies": {
34
- "@types/callsite": "^1.0.34",
35
- "@types/jest": "^29.5.14",
36
- "@types/node": "^22.15.24",
37
- "callsite": "^1.0.0",
38
- "jest": "^29.7.0",
39
- "ts-jest": "^29.3.4",
40
- "ts-node": "^10.9.2",
41
- "typescript": "^5.8.3"
59
+ "@types/node": "^22",
60
+ "eslint": "^9",
61
+ "prettier": "^3",
62
+ "typescript": "^5",
63
+ "vitest": "^3"
64
+ },
65
+ "scripts": {
66
+ "build": "tsc -p tsconfig.json",
67
+ "typecheck": "tsc -p tsconfig.json --noEmit",
68
+ "test": "vitest run",
69
+ "test:watch": "vitest"
42
70
  }
43
- }
71
+ }
@@ -1,32 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
-
4
- import Callsite from 'callsite';
5
-
6
- const fixturesPath = (name: string, ext = '.json'): string => {
7
- const _ext = getExt(name);
8
- return path.resolve(__dirname, `../data/fixtures/${name}${_ext.length !== 0 ? '' : ext}`);
9
- };
10
-
11
- export const rawFixture = (name: string): string => {
12
- return fs.readFileSync(fixturesPath(name)).toString();
13
- };
14
-
15
- export const rawLocalFixture = (name: string, ext = '.json'): string => {
16
- const _ext = getExt(name);
17
- const fpath = `${path.dirname(Callsite()[2].getFileName())}/fixtures/${name}${_ext.length !== 0 ? '' : ext}`;
18
- return fs.readFileSync(fpath).toString();
19
- };
20
-
21
- export const readLocalFixture = <T>(name: string): T => {
22
- return JSON.parse(rawLocalFixture(name)) as unknown as T;
23
- };
24
-
25
- export const readFixture = <T>(name: string): T => {
26
- return JSON.parse(rawFixture(name)) as unknown as T;
27
- };
28
-
29
- function getExt(filename: string): string {
30
- const t = path.extname(filename || '').split('.');
31
- return t[t.length - 1];
32
- }
@@ -1,17 +0,0 @@
1
- import { FlatESLint } from 'eslint/use-at-your-own-risk';
2
- import {rawFixture, readFixture} from "./__utils/data";
3
-
4
- describe('eslint config', () => {
5
- it('should lint a basic TypeScript file without errors', async () => {
6
- const eslint = new FlatESLint({
7
- overrideConfigFile: './index.cjs',
8
- });
9
-
10
- const results = await eslint.lintText(rawFixture('1/file.txt'), { filePath: 'test.ts' });
11
- const expected = await readFixture('1/expected.json');
12
- // @ts-ignore
13
- expected[0].filePath = `${process.cwd()}/test.ts`
14
-
15
- expect(results).toEqual(expected)
16
- });
17
- });
@@ -1,241 +0,0 @@
1
- [
2
- {
3
- "filePath": "/Users/kristi.jorgji/Desktop/libs/eslint-config-typescript/test.ts",
4
- "messages": [
5
- {
6
- "ruleId": "@typescript-eslint/no-unused-vars",
7
- "severity": 2,
8
- "message": "'bip39' is defined but never used. Allowed unused vars must match /^_/u.",
9
- "line": 1,
10
- "column": 13,
11
- "nodeType": null,
12
- "messageId": "unusedVar",
13
- "endLine": 1,
14
- "endColumn": 18
15
- },
16
- {
17
- "ruleId": "import/no-unresolved",
18
- "severity": 2,
19
- "message": "Unable to resolve path to module 'bip39'.",
20
- "line": 1,
21
- "column": 24,
22
- "nodeType": "Literal",
23
- "endLine": 1,
24
- "endColumn": 31
25
- },
26
- {
27
- "ruleId": "@typescript-eslint/no-unused-vars",
28
- "severity": 2,
29
- "message": "'bs58' is defined but never used. Allowed unused vars must match /^_/u.",
30
- "line": 2,
31
- "column": 8,
32
- "nodeType": null,
33
- "messageId": "unusedVar",
34
- "endLine": 2,
35
- "endColumn": 12
36
- },
37
- {
38
- "ruleId": "import/no-unresolved",
39
- "severity": 2,
40
- "message": "Unable to resolve path to module 'bs58'.",
41
- "line": 2,
42
- "column": 18,
43
- "nodeType": "Literal",
44
- "endLine": 2,
45
- "endColumn": 24
46
- },
47
- {
48
- "ruleId": "import/order",
49
- "severity": 2,
50
- "message": "There should be at least one empty line between import groups",
51
- "line": 3,
52
- "column": 1,
53
- "nodeType": "ImportDeclaration",
54
- "endLine": 3,
55
- "endColumn": 43,
56
- "fix": {
57
- "range": [
58
- 99,
59
- 99
60
- ],
61
- "text": "\n"
62
- }
63
- },
64
- {
65
- "ruleId": "@typescript-eslint/no-unused-vars",
66
- "severity": 2,
67
- "message": "'ed25519' is defined but never used. Allowed unused vars must match /^_/u.",
68
- "line": 3,
69
- "column": 13,
70
- "nodeType": null,
71
- "messageId": "unusedVar",
72
- "endLine": 3,
73
- "endColumn": 20
74
- },
75
- {
76
- "ruleId": "import/no-unresolved",
77
- "severity": 2,
78
- "message": "Unable to resolve path to module 'ed25519-hd-key'.",
79
- "line": 3,
80
- "column": 26,
81
- "nodeType": "Literal",
82
- "endLine": 3,
83
- "endColumn": 42
84
- },
85
- {
86
- "ruleId": "prettier/prettier",
87
- "severity": 2,
88
- "message": "Replace `z,·x,·c` with `·z,·x,·c·`",
89
- "line": 4,
90
- "column": 9,
91
- "nodeType": null,
92
- "messageId": "replace",
93
- "endLine": 4,
94
- "endColumn": 16,
95
- "fix": {
96
- "range": [
97
- 108,
98
- 115
99
- ],
100
- "text": " z, x, c "
101
- }
102
- },
103
- {
104
- "ruleId": "@typescript-eslint/no-unused-vars",
105
- "severity": 2,
106
- "message": "'z' is defined but never used. Allowed unused vars must match /^_/u.",
107
- "line": 4,
108
- "column": 9,
109
- "nodeType": null,
110
- "messageId": "unusedVar",
111
- "endLine": 4,
112
- "endColumn": 10
113
- },
114
- {
115
- "ruleId": "sort-imports",
116
- "severity": 2,
117
- "message": "Member 'x' of the import declaration should be sorted alphabetically.",
118
- "line": 4,
119
- "column": 12,
120
- "nodeType": "ImportSpecifier",
121
- "messageId": "sortMembersAlphabetically",
122
- "endLine": 4,
123
- "endColumn": 13,
124
- "fix": {
125
- "range": [
126
- 108,
127
- 115
128
- ],
129
- "text": "c, x, z"
130
- }
131
- },
132
- {
133
- "ruleId": "@typescript-eslint/no-unused-vars",
134
- "severity": 2,
135
- "message": "'c' is defined but never used. Allowed unused vars must match /^_/u.",
136
- "line": 4,
137
- "column": 15,
138
- "nodeType": null,
139
- "messageId": "unusedVar",
140
- "endLine": 4,
141
- "endColumn": 16
142
- },
143
- {
144
- "ruleId": "import/no-unresolved",
145
- "severity": 2,
146
- "message": "Unable to resolve path to module './a'.",
147
- "line": 4,
148
- "column": 23,
149
- "nodeType": "Literal",
150
- "endLine": 4,
151
- "endColumn": 28
152
- },
153
- {
154
- "ruleId": "no-redeclare",
155
- "severity": 2,
156
- "message": "'x' is already defined.",
157
- "line": 6,
158
- "column": 7,
159
- "nodeType": "Identifier",
160
- "messageId": "redeclared",
161
- "endLine": 6,
162
- "endColumn": 16
163
- },
164
- {
165
- "ruleId": "no-import-assign",
166
- "severity": 2,
167
- "message": "'x' is read-only.",
168
- "line": 6,
169
- "column": 7,
170
- "nodeType": "Identifier",
171
- "messageId": "readonly",
172
- "endLine": 6,
173
- "endColumn": 16
174
- },
175
- {
176
- "ruleId": "prettier/prettier",
177
- "severity": 2,
178
- "message": "Delete `····`",
179
- "line": 7,
180
- "column": 1,
181
- "nodeType": null,
182
- "messageId": "delete",
183
- "endLine": 7,
184
- "endColumn": 5,
185
- "fix": {
186
- "range": [
187
- 151,
188
- 155
189
- ],
190
- "text": ""
191
- }
192
- },
193
- {
194
- "ruleId": "@typescript-eslint/no-unused-vars",
195
- "severity": 2,
196
- "message": "'d' is assigned a value but never used. Allowed unused vars must match /^_/u.",
197
- "line": 9,
198
- "column": 5,
199
- "nodeType": null,
200
- "messageId": "unusedVar",
201
- "endLine": 9,
202
- "endColumn": 6
203
- }
204
- ],
205
- "suppressedMessages": [],
206
- "errorCount": 16,
207
- "fatalErrorCount": 0,
208
- "warningCount": 0,
209
- "fixableErrorCount": 4,
210
- "fixableWarningCount": 0,
211
- "source": "import * as bip39 from 'bip39';\nimport bs58 from 'bs58';\nimport * as ed25519 from 'ed25519-hd-key';\nimport {z, x, c} from './a';\n\nconst x: number = 5;\n console.log(x);\n\nlet d = 2;\n",
212
- "usedDeprecatedRules": [
213
- {
214
- "ruleId": "quotes",
215
- "replacedBy": [
216
- "@stylistic/js/quotes"
217
- ],
218
- "info": {
219
- "message": "Formatting rules are being moved out of ESLint core.",
220
- "url": "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
221
- "deprecatedSince": "8.53.0",
222
- "availableUntil": "10.0.0",
223
- "replacedBy": [
224
- {
225
- "message": "ESLint Stylistic now maintains deprecated stylistic core rules.",
226
- "url": "https://eslint.style/guide/migration",
227
- "plugin": {
228
- "name": "@stylistic/eslint-plugin-js",
229
- "url": "https://eslint.style/packages/js"
230
- },
231
- "rule": {
232
- "name": "quotes",
233
- "url": "https://eslint.style/rules/js/quotes"
234
- }
235
- }
236
- ]
237
- }
238
- }
239
- ]
240
- }
241
- ]
@@ -1,9 +0,0 @@
1
- import * as bip39 from 'bip39';
2
- import bs58 from 'bs58';
3
- import * as ed25519 from 'ed25519-hd-key';
4
- import {z, x, c} from './a';
5
-
6
- const x: number = 5;
7
- console.log(x);
8
-
9
- let d = 2;
package/index.cjs DELETED
@@ -1,103 +0,0 @@
1
- const globals = require('globals');
2
- const js = require('@eslint/js');
3
- const importPlugin = require('eslint-plugin-import');
4
- const tseslint = require('@typescript-eslint/eslint-plugin');
5
- const parser = require('@typescript-eslint/parser');
6
- const prettierPlugin = require('eslint-plugin-prettier');
7
-
8
- module.exports = [
9
- {
10
- files: ['**/*.ts'],
11
- languageOptions: {
12
- parser,
13
- ecmaVersion: 'latest',
14
- sourceType: 'module',
15
- globals: {
16
- ...globals.node,
17
- ...globals.jest,
18
- ...globals.es2021,
19
- },
20
- },
21
- plugins: {
22
- '@typescript-eslint': tseslint,
23
- import: importPlugin,
24
- prettier: prettierPlugin,
25
- },
26
- settings: {
27
- 'import/resolver': {
28
- typescript: {
29
- // always try to resolve types under `<root>@types` directory even it doesn't contain source code,
30
- // this can help resolve things like `@types/node` correctly
31
- alwaysTryTypes: true,
32
- // optionally, you can specify project root if your tsconfig.json is not in the root
33
- // project: './path/to/tsconfig.json',
34
- },
35
- },
36
- },
37
- rules: {
38
- ...js.configs.recommended.rules,
39
- 'no-unused-vars': 'off',
40
- ...importPlugin.configs.recommended.rules,
41
- ...importPlugin.configs.typescript.rules,
42
- 'import/order': [
43
- 'error',
44
- {
45
- groups: ['builtin', 'external', 'internal', ['parent', 'sibling']],
46
- 'newlines-between': 'always',
47
- alphabetize: {
48
- order: 'asc',
49
- caseInsensitive: true,
50
- },
51
- },
52
- ],
53
- 'sort-imports': [
54
- 'error',
55
- {
56
- ignoreDeclarationSort: true,
57
- },
58
- ],
59
- 'no-unmodified-loop-condition': 'error',
60
- 'import/no-unresolved': 'error',
61
- 'import/no-extraneous-dependencies': [
62
- 'error',
63
- {
64
- devDependencies: ['{tests,__tests__,mocks,__mocks__}/**/*.ts'],
65
- bundledDependencies: true,
66
- optionalDependencies: false,
67
- peerDependencies: false,
68
- },
69
- ],
70
- // typescript-eslint rules
71
- '@typescript-eslint/no-explicit-any': 'error',
72
- '@typescript-eslint/no-unused-vars': [
73
- 'error',
74
- {
75
- args: 'all',
76
- argsIgnorePattern: '^_',
77
- caughtErrors: 'all',
78
- caughtErrorsIgnorePattern: '^_',
79
- destructuredArrayIgnorePattern: '^_',
80
- varsIgnorePattern: '^_',
81
- ignoreRestSiblings: true,
82
- },
83
- ],
84
- // stylistic rules
85
- quotes: ['error', 'single'],
86
- 'object-shorthand': 'off',
87
- 'prettier/prettier': [
88
- 'error',
89
- {
90
- arrowParens: 'avoid',
91
- bracketSpacing: true,
92
- printWidth: 120,
93
- semi: true,
94
- singleQuote: true,
95
- tabWidth: 4,
96
- trailingComma: 'all',
97
- useTabs: false,
98
- endOfLine: 'lf',
99
- },
100
- ],
101
- },
102
- },
103
- ];
package/jest-setup.ts DELETED
File without changes
package/jest.config.ts DELETED
@@ -1,44 +0,0 @@
1
- process.env.TZ = 'UTC';
2
-
3
- const TS_CONFIG_PATH = './tsconfig.json';
4
- const SRC_PATH = '<rootDir>';
5
-
6
- export default {
7
- testEnvironment: 'node',
8
- preset: 'ts-jest',
9
- setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
10
- testMatch: ['**/__tests__/**/*.test.ts'],
11
- collectCoverage: true,
12
- collectCoverageFrom: [
13
- 'src/**/*.{js,jsx,ts,tsx}',
14
- '!**/__mocks__/**',
15
- '!<rootDir>/node_modules/',
16
- ],
17
- coverageThreshold: {
18
- global: {
19
- statements: 49,
20
- branches: 50,
21
- functions: 40,
22
- lines: 45,
23
- },
24
- },
25
- moduleNameMapper: {
26
- ...makeModuleNameMapper(SRC_PATH, TS_CONFIG_PATH),
27
- },
28
- };
29
-
30
- function makeModuleNameMapper(srcPath: string, tsconfigPath: string) {
31
- // Get paths from tsconfig
32
- const { paths } = require(tsconfigPath).compilerOptions;
33
-
34
- const aliases: Record<string, string> = {};
35
-
36
- // Iterate over paths and convert them into moduleNameMapper format
37
- Object.keys(paths || {}).forEach(item => {
38
- const key = item.replace('/*', '/(.*)');
39
- const path = paths[item][0].replace('/*', '/$1');
40
- aliases[key] = srcPath + '/' + path;
41
- });
42
-
43
- return aliases;
44
- }
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "allowJs": true,
4
- "esModuleInterop": true,
5
- "moduleResolution": "node",
6
- "target": "ES2020",
7
- "module": "CommonJS",
8
- "types": ["node", "jest"],
9
- "strict": true,
10
- "resolveJsonModule": true
11
- },
12
- "include": ["__tests__/**/*.ts"]
13
- }