Skip to content

Commit

Permalink
Merge pull request #211 from tal-rofe/allow-typescript-config
Browse files Browse the repository at this point in the history
feat: 🔥 allow TypeScript configuration for Inflint
  • Loading branch information
tal-rofe authored Nov 9, 2023
2 parents a03dda3 + f524668 commit 874ce2f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 17 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ Configuration can be set in the following files:
- a `package.json` property: `"inflint": {...}`
- a `.inflintrc` file in JSON or YAML format
- a `.inflintrc.json`, `.inflintrc.yaml`, `.inflintrc.yml`, `.inflintrc.js`, `.inflintrc.ts`, or `.inflintrc.cjs` file
- a `inflint.config.js`, or `inflint.config.cjs` CommonJS module exporting an object

Currently, a TypeScript configuration file is not supported: https://github.com/Codex-/cosmiconfig-typescript-loader/issues/60
- a `inflint.config.ts`, `inflint.config.js`, or `inflint.config.cjs` CommonJS module exporting an object

### Rules format
When applying rules either via the CLI or other configuration, you must follow the rules format.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"dependencies": {
"@expo/spawn-async": "1.7.2",
"chalk": "5.3.0",
"cosmiconfig": "8.1.3",
"cosmiconfig": "8.3.6",
"cosmiconfig-typescript-loader": "5.0.0",
"fast-glob": "3.3.1",
"micromatch": "4.0.5",
"minimist": "1.2.8",
Expand Down
56 changes: 44 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/modules/app/utils/merge-configurations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';

import { cosmiconfig } from 'cosmiconfig';
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';

import type { IBaseConfiguration, ISourceConfiguration } from '@/interfaces/configuration';
import { withCleanObject } from '@/utils/object';
Expand Down Expand Up @@ -56,7 +57,7 @@ export const recurseSourceConfiguration = async (
}

const extendsFilePath = path.join(configPath, '..', config.extends);
const explorer = cosmiconfig('');
const explorer = cosmiconfig('', { loaders: { '.ts': TypeScriptLoader() } });
const result = await explorer.load(extendsFilePath).catch(() => null);

if (!result) {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/configuration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'node:path';

import { cosmiconfig } from 'cosmiconfig';
import type { CosmiconfigResult } from 'cosmiconfig/dist/types';
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';

import type { ISourceConfiguration } from '@/interfaces/configuration';
import CLILoggerModule from '@/shared/modules/cli-logger';
Expand All @@ -15,6 +16,7 @@ const StartConfiguration = async (
): Promise<[ISourceConfiguration, string | undefined] | null> => {
const explorer = cosmiconfig(CONFIGURATION_MODULE_NAME, {
searchPlaces: configFilePath ? [configFilePath] : DEFAULT_SEARCH_PLACES,
loaders: { '.ts': TypeScriptLoader() },
});

let result: CosmiconfigResult | null;
Expand Down

0 comments on commit 874ce2f

Please sign in to comment.