@kristijorgji/eslint-config-typescript 0.0.3 → 1.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 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,52 @@
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,
20
+ // Prefer your repo's .prettierrc as the single source of truth:
21
+ prettier: 'prettierrc',
48
22
  });
49
-
50
- module.exports = defineConfig([
51
- {
52
- files: ['src/**/*.ts', '__tests__/**/*.ts'],
53
- extends: compat.extends('@kristijorgji/eslint-config-typescript'),
54
- },
55
- ]);
56
23
  ```
57
24
 
58
- ## Development
25
+ ### Options
59
26
 
60
- Learn more about creating custom ESLint configs here:
61
- [ESLint Shareable Configs Guide](https://eslint.org/docs/developer-guide/shareable-configs)
27
+ | Option | Description |
28
+ | --- | --- |
29
+ | `files` | Glob patterns (default `**/*.{ts,tsx}`) |
30
+ | `tsconfigRootDir` | Enables type-aware rules via `createTypedLintConfig` |
31
+ | `prettier` | `true` (default, embeds package defaults), `'prettierrc'` (defer to the consumer's Prettier config file), a Prettier options object (replaces defaults), or `false` |
32
+ | `ignores` | Extra ignore globs |
33
+ | `importOrder` | Options for `import-x/order`, shallow-merged over package defaults; `false` disables the rule |
34
+ | `sortImports` | Options for `sort-imports`, shallow-merged over package defaults; `false` disables the rule |
62
35
 
63
- To develop locally, you can link your local package using:
36
+ ### Named exports / subpaths
64
37
 
65
- ```bash
66
- yarn add --dev /path/to/local/eslint-config-typescript
67
- ```
38
+ - `@kristijorgji/eslint-config-typescript` — factory + all named parts
39
+ - `./base` — `createBaseConfig` / `baseRules`
40
+ - `./typed` — `createTypedLintConfig`
41
+ - `./ignores` — default ignore block
42
+
43
+ Also exported: `createImportOrderRules`, `importOrderRules`,
44
+ `defaultImportXOrderOptions`, `defaultSortImportsOptions`.
68
45
 
69
- > You need to run this command after every change to your local plugin.
46
+ ### Plugin rule placement
70
47
 
71
- ## License
48
+ This package enables **`kj/no-pure-type-alias` only**. JSX prop order
49
+ (`perfectionist/sort-jsx-props`), single-export barrels, and component extraction
50
+ live in `@kristijorgji/eslint-config-react-typescript`.
72
51
 
73
- [MIT](LICENSE)
52
+ 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,27 @@
1
+ import type { Linter } from 'eslint';
2
+ import { type ImportXOrderOptions, type SortImportsOptions } from './import-order.js';
3
+ import { type PrettierSetting } from './prettier.js';
4
+ export interface BaseRulesOptions {
5
+ /**
6
+ * Prettier integration. `true` (default) uses package defaults; `'prettierrc'`
7
+ * defers to the consumer's Prettier config file; pass an options object to
8
+ * replace defaults; `false` disables `prettier/prettier`.
9
+ */
10
+ prettier?: PrettierSetting;
11
+ /** `import-x/order` options (shallow merge). `false` disables the rule. */
12
+ importOrder?: false | ImportXOrderOptions;
13
+ /** `sort-imports` options (shallow merge). `false` disables the rule. */
14
+ sortImports?: false | SortImportsOptions;
15
+ }
16
+ /**
17
+ * Core TypeScript lint rules (no type-aware block).
18
+ * Includes `kj/no-pure-type-alias` only — single-export barrels and JSX prop order
19
+ * belong on the React factory.
20
+ */
21
+ export declare function baseRules(options?: BaseRulesOptions): Linter.RulesRecord;
22
+ export interface BaseConfigOptions extends BaseRulesOptions {
23
+ files?: string[];
24
+ }
25
+ /** Flat config block for TypeScript sources (parser + plugins + base rules). */
26
+ export declare function createBaseConfig(options?: BaseConfigOptions): Linter.Config;
27
+ //# 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;AAMrC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5F,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,2EAA2E;IAC3E,WAAW,CAAC,EAAE,KAAK,GAAG,mBAAmB,CAAC;IAC1C,yEAAyE;IACzE,WAAW,CAAC,EAAE,KAAK,GAAG,kBAAkB,CAAC;CAC1C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAmCxE;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,78 @@
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 { createImportOrderRules, } 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.
13
+ */
14
+ export function baseRules(options) {
15
+ const prettier = options?.prettier ?? true;
16
+ let prettierRuleBlock = {};
17
+ if (prettier === 'prettierrc') {
18
+ prettierRuleBlock = prettierRules('prettierrc');
19
+ }
20
+ else if (prettier === true) {
21
+ prettierRuleBlock = prettierRules(defaultPrettierOptions);
22
+ }
23
+ else if (prettier !== false) {
24
+ prettierRuleBlock = prettierRules(prettier);
25
+ }
26
+ return {
27
+ ...js.configs.recommended.rules,
28
+ 'no-unused-vars': 'off',
29
+ ...createImportOrderRules({
30
+ importOrder: options?.importOrder,
31
+ sortImports: options?.sortImports,
32
+ }),
33
+ 'import-x/no-unresolved': 'off',
34
+ '@typescript-eslint/no-explicit-any': 'error',
35
+ '@typescript-eslint/no-unused-vars': [
36
+ 'error',
37
+ {
38
+ args: 'all',
39
+ argsIgnorePattern: '^_',
40
+ caughtErrors: 'all',
41
+ caughtErrorsIgnorePattern: '^_',
42
+ destructuredArrayIgnorePattern: '^_',
43
+ varsIgnorePattern: '^_',
44
+ ignoreRestSiblings: true,
45
+ },
46
+ ],
47
+ 'kj/no-pure-type-alias': 'error',
48
+ ...prettierRuleBlock,
49
+ };
50
+ }
51
+ /** Flat config block for TypeScript sources (parser + plugins + base rules). */
52
+ export function createBaseConfig(options) {
53
+ const files = options?.files ?? ['**/*.{ts,tsx}'];
54
+ return {
55
+ files,
56
+ languageOptions: {
57
+ ecmaVersion: 'latest',
58
+ sourceType: 'module',
59
+ globals: {
60
+ ...globals.node,
61
+ ...globals.es2021,
62
+ },
63
+ parser: tseslint.parser,
64
+ parserOptions: {
65
+ ecmaVersion: 'latest',
66
+ sourceType: 'module',
67
+ },
68
+ },
69
+ plugins: {
70
+ '@typescript-eslint': tseslint.plugin,
71
+ 'import-x': importX,
72
+ prettier: prettierPlugin,
73
+ kj: kjPlugin,
74
+ },
75
+ rules: baseRules(options),
76
+ };
77
+ }
78
+ //# 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,EACL,sB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AAE,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,34 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { ImportXOrderOptions, SortImportsOptions } from './import-order.js';
3
+ import type { PrettierSetting } from './prettier.js';
4
+ export interface CreateTypescriptConfigOptions {
5
+ /** Glob patterns for TypeScript files. Defaults to all `.ts` / `.tsx` files. */
6
+ files?: string[];
7
+ /**
8
+ * When set, appends the type-aware block (`createTypedLintConfig`).
9
+ * Required for `kj/no-weak-typeof-satisfies`.
10
+ */
11
+ tsconfigRootDir?: string;
12
+ /**
13
+ * Prettier integration. `true` (default) uses package defaults; `'prettierrc'`
14
+ * defers to the consumer's Prettier config file; pass an options object to
15
+ * replace defaults; `false` disables `prettier/prettier` (still applies
16
+ * eslint-config-prettier last).
17
+ */
18
+ prettier?: PrettierSetting;
19
+ /** Extra ignore patterns merged into the default ignores block. */
20
+ ignores?: string[];
21
+ /** `import-x/order` options (shallow merge). `false` disables the rule. */
22
+ importOrder?: false | ImportXOrderOptions;
23
+ /** `sort-imports` options (shallow merge). `false` disables the rule. */
24
+ sortImports?: false | SortImportsOptions;
25
+ }
26
+ /**
27
+ * Flat ESLint config factory for TypeScript projects.
28
+ *
29
+ * Enables `kj/no-pure-type-alias` only from the plugin recommended set.
30
+ * Use `@kristijorgji/eslint-config-react-typescript` for JSX prop order,
31
+ * single-export barrels, and component-extraction rules.
32
+ */
33
+ export declare function createTypescriptConfig(options?: CreateTypescriptConfigOptions): Linter.Config[];
34
+ //# 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;AAKrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,MAAM,WAAW,6BAA6B;IAC5C,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,KAAK,GAAG,mBAAmB,CAAC;IAC1C,yEAAyE;IACzE,WAAW,CAAC,EAAE,KAAK,GAAG,kBAAkB,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,6BAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,CAwBnG"}
@@ -0,0 +1,34 @@
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
+ importOrder: options.importOrder,
25
+ sortImports: options.sortImports,
26
+ }),
27
+ ];
28
+ if (options.tsconfigRootDir) {
29
+ configs.push(createTypedLintConfig({ tsconfigRootDir: options.tsconfigRootDir }));
30
+ }
31
+ configs.push(prettierConfig);
32
+ return configs;
33
+ }
34
+ //# 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;AAEpD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAyBnD;;;;;;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;YAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,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,50 @@
1
+ import type { Linter } from 'eslint';
2
+ export interface ImportXOrderOptions {
3
+ groups?: (string | string[])[];
4
+ pathGroups?: {
5
+ pattern: string;
6
+ group: string;
7
+ position?: 'before' | 'after';
8
+ }[];
9
+ pathGroupsExcludedImportTypes?: string[];
10
+ 'newlines-between'?: 'always' | 'always-and-inside-groups' | 'never' | 'ignore';
11
+ alphabetize?: {
12
+ order: 'asc' | 'desc' | 'ignore';
13
+ caseInsensitive?: boolean;
14
+ };
15
+ distinctGroup?: boolean;
16
+ warnOnUnassignedImports?: boolean;
17
+ }
18
+ export interface SortImportsOptions {
19
+ ignoreCase?: boolean;
20
+ ignoreDeclarationSort?: boolean;
21
+ ignoreMemberSort?: boolean;
22
+ allowSeparatedGroups?: boolean;
23
+ memberSyntaxSortOrder?: string[];
24
+ }
25
+ export declare const defaultImportXOrderOptions: ImportXOrderOptions;
26
+ export declare const defaultSortImportsOptions: SortImportsOptions;
27
+ /**
28
+ * Import ordering rules using `eslint-plugin-import-x`.
29
+ * Exported so consumers can compose without taking the full factory.
30
+ * Prefer {@link createImportOrderRules} when you need overrides.
31
+ */
32
+ export declare const importOrderRules: Linter.RulesRecord;
33
+ export interface CreateImportOrderRulesOptions {
34
+ /**
35
+ * `import-x/order` options, shallow-merged over the defaults (arrays replace).
36
+ * `false` disables the rule.
37
+ */
38
+ importOrder?: false | ImportXOrderOptions;
39
+ /**
40
+ * `sort-imports` options, shallow-merged over the defaults (arrays replace).
41
+ * `false` disables the rule.
42
+ */
43
+ sortImports?: false | SortImportsOptions;
44
+ }
45
+ /**
46
+ * Builds import-order related rules. Called with no arguments, the result is
47
+ * deep-equal to {@link importOrderRules}.
48
+ */
49
+ export declare function createImportOrderRules(options?: CreateImportOrderRulesOptions): Linter.RulesRecord;
50
+ //# 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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pC,OAAO,CAAC,EAAE,6BAA6B,GACtC,MAAM,CAAC,WAAW,CA2BpB"}
@@ -0,0 +1,55 @@
1
+ export const defaultImportXOrderOptions = {
2
+ groups: ['builtin', 'external', 'internal', ['parent', 'sibling']],
3
+ 'newlines-between': 'always',
4
+ alphabetize: {
5
+ order: 'asc',
6
+ caseInsensitive: true,
7
+ },
8
+ };
9
+ export const defaultSortImportsOptions = {
10
+ ignoreCase: true,
11
+ ignoreDeclarationSort: true,
12
+ ignoreMemberSort: false,
13
+ allowSeparatedGroups: true,
14
+ };
15
+ /**
16
+ * Import ordering rules using `eslint-plugin-import-x`.
17
+ * Exported so consumers can compose without taking the full factory.
18
+ * Prefer {@link createImportOrderRules} when you need overrides.
19
+ */
20
+ export const importOrderRules = {
21
+ 'import-x/first': 'error',
22
+ 'import-x/no-duplicates': 'error',
23
+ 'import-x/order': ['error', defaultImportXOrderOptions],
24
+ 'sort-imports': ['error', defaultSortImportsOptions],
25
+ };
26
+ /**
27
+ * Builds import-order related rules. Called with no arguments, the result is
28
+ * deep-equal to {@link importOrderRules}.
29
+ */
30
+ export function createImportOrderRules(options) {
31
+ const rules = {
32
+ 'import-x/first': 'error',
33
+ 'import-x/no-duplicates': 'error',
34
+ };
35
+ if (options?.importOrder !== false) {
36
+ rules['import-x/order'] = [
37
+ 'error',
38
+ {
39
+ ...defaultImportXOrderOptions,
40
+ ...(options?.importOrder ?? {}),
41
+ },
42
+ ];
43
+ }
44
+ if (options?.sortImports !== false) {
45
+ rules['sort-imports'] = [
46
+ 'error',
47
+ {
48
+ ...defaultSortImportsOptions,
49
+ ...(options?.sortImports ?? {}),
50
+ },
51
+ ];
52
+ }
53
+ return rules;
54
+ }
55
+ //# sourceMappingURL=import-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-order.js","sourceRoot":"","sources":["../src/import-order.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,0BAA0B,GAAwB;IAC7D,MAAM,EAAE,CAAC,SAA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esOptions } from './base.js';
2
+ export { createTypescriptConfig, type CreateTypescriptConfigOptions, } from './create-typescript-config.js';
3
+ export { ignores } from './ignores.js';
4
+ export { createImportOrderRules, defaultImportXOrderOptions, defaultSortImportsOptions, importOrderRules, type CreateImportOrderRulesOptions, type ImportXOrderOptions, type SortImportsOptions, } from './import-order.js';
5
+ export { defaultPrettierOptions, prettierRules, type PrettierSetting } 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,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EAChB,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5F,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 { createImportOrderRules, defaultImportXOrderOptions, defaultSortImportsOptions, 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,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,GAIjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAwB,MAAM,eAAe,CAAC;AAC5F,OAAO,EACL,qBAAqB,GAEtB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,19 @@
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
+ * Prettier integration setting.
7
+ * - `true` (default): embed {@link defaultPrettierOptions}
8
+ * - `'prettierrc'`: emit bare `'prettier/prettier': 'error'` so the consumer's
9
+ * `.prettierrc` / `.prettierrc.js` is the single source of truth
10
+ * - object: replace the defaults entirely (not deep-merged)
11
+ * - `false`: omit the rule
12
+ */
13
+ export type PrettierSetting = boolean | 'prettierrc' | PrettierOptions;
14
+ /**
15
+ * Builds the `prettier/prettier` rule entry.
16
+ * Pass `false` to `createTypescriptConfig({ prettier: false })` to skip.
17
+ */
18
+ export declare function prettierRules(options?: PrettierOptions | 'prettierrc'): Linter.RulesRecord;
19
+ //# 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;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,YAAY,GAAG,eAAe,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,GAAE,eAAe,GAAG,YAAqC,GAC/D,MAAM,CAAC,WAAW,CAUpB"}
@@ -0,0 +1,27 @@
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
+ if (options === 'prettierrc') {
19
+ return {
20
+ 'prettier/prettier': 'error',
21
+ };
22
+ }
23
+ return {
24
+ 'prettier/prettier': ['error', options],
25
+ };
26
+ }
27
+ //# 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;AAYF;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,UAA0C,sBAAsB;IAEhE,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,OAAO;YACL,mBAAmB,EAAE,OAAO;SAC7B,CAAC;IACJ,CAAC;IAED,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.
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.
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.1.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": true
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": "^17",
55
+ "typescript-eslint": "^8",
56
+ "@kristijorgji/eslint-plugin": "^0.2.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": "^26",
60
+ "eslint": "^10",
61
+ "prettier": "^3",
62
+ "typescript": "^5",
63
+ "vitest": "^4"
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
- }