diff --git a/.vscode/settings.json b/.vscode/settings.json index 5a1a1f7..2deff29 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,5 +21,8 @@ "json", "jsonc", "yaml" + ], + "cSpell.words": [ + "ESLIT" ] } diff --git a/eslint.config.js b/eslint.config.js index f12c292..f340a50 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,4 +1,4 @@ -import { defineConfig } from '@eslit/core'; +import { defineConfig } from '@eslit/config'; export default defineConfig({ environment: { diff --git a/package.json b/package.json index 7618bba..ad19204 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "license": "MIT", "type": "module", "dependencies": { - "@eslit/core": "workspace:*" + "@eslit/config": "workspace:*" }, "devDependencies": { "@changesets/cli": "^2.26.2", diff --git a/packages/core/.lintstagedrc b/packages/config/.lintstagedrc similarity index 100% rename from packages/core/.lintstagedrc rename to packages/config/.lintstagedrc diff --git a/packages/config/index.d.ts b/packages/config/index.d.ts new file mode 100644 index 0000000..ce854f6 --- /dev/null +++ b/packages/config/index.d.ts @@ -0,0 +1,4 @@ +import type { EnvOptions } from './src/types'; +import type { Linter } from 'eslint'; + +export async function defineConfig(eslintConfig: Linter.FlatConfig[], environment: EnvOptions): Promise; diff --git a/packages/core/jsconfig.json b/packages/config/jsconfig.json similarity index 100% rename from packages/core/jsconfig.json rename to packages/config/jsconfig.json diff --git a/packages/core/package.json b/packages/config/package.json similarity index 97% rename from packages/core/package.json rename to packages/config/package.json index 4692434..d4f4aa2 100644 --- a/packages/core/package.json +++ b/packages/config/package.json @@ -1,5 +1,5 @@ { - "name": "@eslit/core", + "name": "@eslit/config", "version": "0.1.0", "description": "", "main": "index.js", diff --git a/packages/core/src/@types/eslint-plugin-jsdoc.d.ts b/packages/config/src/@types/eslint-plugin-jsdoc.d.ts similarity index 100% rename from packages/core/src/@types/eslint-plugin-jsdoc.d.ts rename to packages/config/src/@types/eslint-plugin-jsdoc.d.ts diff --git a/packages/core/src/@types/globals.d.ts b/packages/config/src/@types/globals.d.ts similarity index 100% rename from packages/core/src/@types/globals.d.ts rename to packages/config/src/@types/globals.d.ts diff --git a/packages/core/src/@types/typescript-eslint.d.ts b/packages/config/src/@types/typescript-eslint.d.ts similarity index 100% rename from packages/core/src/@types/typescript-eslint.d.ts rename to packages/config/src/@types/typescript-eslint.d.ts diff --git a/packages/core/src/configs/common.js b/packages/config/src/configs/common.js similarity index 100% rename from packages/core/src/configs/common.js rename to packages/config/src/configs/common.js diff --git a/packages/core/src/configs/environments.js b/packages/config/src/configs/environments.js similarity index 100% rename from packages/core/src/configs/environments.js rename to packages/config/src/configs/environments.js diff --git a/packages/core/src/configs/formatting.js b/packages/config/src/configs/formatting.js similarity index 100% rename from packages/core/src/configs/formatting.js rename to packages/config/src/configs/formatting.js diff --git a/packages/core/src/configs/index.js b/packages/config/src/configs/index.js similarity index 100% rename from packages/core/src/configs/index.js rename to packages/config/src/configs/index.js diff --git a/packages/core/src/configs/jsdoc.js b/packages/config/src/configs/jsdoc.js similarity index 100% rename from packages/core/src/configs/jsdoc.js rename to packages/config/src/configs/jsdoc.js diff --git a/packages/core/src/configs/typescript.js b/packages/config/src/configs/typescript.js similarity index 100% rename from packages/core/src/configs/typescript.js rename to packages/config/src/configs/typescript.js diff --git a/packages/core/src/env.d.ts b/packages/config/src/env.d.ts similarity index 100% rename from packages/core/src/env.d.ts rename to packages/config/src/env.d.ts diff --git a/packages/core/src/eslintrc-compact.js b/packages/config/src/eslintrc-compact.js similarity index 100% rename from packages/core/src/eslintrc-compact.js rename to packages/config/src/eslintrc-compact.js diff --git a/packages/core/src/index.js b/packages/config/src/index.js similarity index 95% rename from packages/core/src/index.js rename to packages/config/src/index.js index 410cfe4..f2f1cf3 100644 --- a/packages/core/src/index.js +++ b/packages/config/src/index.js @@ -7,9 +7,9 @@ import * as configs from './configs/index.js'; import { getTsConfigs } from './tsconfigs.js'; /** - * @param {import('./types').Config} userConfig + * @param {import('./types.js').Config} userConfig * User configuration - * @returns {Promise} + * @returns {Promise} * The complete list of configs for ESLint */ export async function defineConfig(userConfig) { diff --git a/packages/core/src/tsconfigs.js b/packages/config/src/tsconfigs.js similarity index 100% rename from packages/core/src/tsconfigs.js rename to packages/config/src/tsconfigs.js diff --git a/packages/core/src/types.d.ts b/packages/config/src/types.d.ts similarity index 74% rename from packages/core/src/types.d.ts rename to packages/config/src/types.d.ts index bbc5fdd..b3a5b5d 100644 --- a/packages/core/src/types.d.ts +++ b/packages/config/src/types.d.ts @@ -3,6 +3,44 @@ import type { Linter } from 'eslint'; export type ESConfig = Readonly; +export interface EnvOptions { + ESLIT_TSCONFIG?: string | string[] | true + ESLIT_ROOT?: string + ESLIT_INDENT?: 'tab' | 'space' | number + ESLIT_ECMASCRIPT?: Linter.ParserOptions['ecmaVersion'] + ESLIT_SEMI?: 'never' | 'always' + /** + * Typescript's type-checking is able to infer types from parameters. + * So using an explicit `:` type annotation isn't obligatory. + * + * But, **by default in strict mode**, type annotations are always mandated to make + * the code more readable, explicit and robust to changes. + * + * See {@link https://typescript-eslint.io/rules/no-inferrable-types typescript-eslint documentation } + * for more info. + * --- + * **Option: `never`** (default) + * Types are always explicit in Typescript + * + * @example ```ts + // Typescript + const id: number = 10; + const name: string = 'foo'; + ``` + * --- + * **Option: `always`** + * Types are always inferred in Typescript + * + * @example ```ts + // Typescript + const id = 10; + const name = 'foo'; + ``` + */ + ESLIT_INFER_TYPES?: inferrableTypesOptions + [ENV: string]: unknown +} + export interface Config { tsconfig?: string | string[] | true strict?: boolean diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts deleted file mode 100644 index 3f8c3ac..0000000 --- a/packages/core/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { Config, ESConfig } from './src/types'; - -export async function defineConfig(config: Config): Promise; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c39e1de..3faab23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,9 @@ importers: .: dependencies: - '@eslit/core': + '@eslit/config': specifier: workspace:* - version: link:packages/core + version: link:packages/config devDependencies: '@changesets/cli': specifier: ^2.26.2 @@ -76,7 +76,7 @@ importers: specifier: ^4.4.2 version: 4.4.2 - packages/core: + packages/config: dependencies: '@eslint/eslintrc': specifier: ^2.1.0