Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generate ESLint globals file for auto-imports #450

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
aklinker1 committed Feb 15, 2024
commit 074db50c905fdec9dc79f85ec5725ef3e7ec3621
1 change: 0 additions & 1 deletion e2e/tests/auto-imports.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, it, expect } from 'vitest';
import { TestProject } from '../utils';
import { resolve } from 'path';

describe('Auto Imports', () => {
describe('imports: { ... }', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/building/generate-wxt-dir.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Unimport, UnimportOptions, createUnimport } from 'unimport';
import {
ESLintGlobalsPropValue,
EslintGlobalsPropValue,
Entrypoint,
WxtResolvedUnimportOptions,
} from '~/types';
Expand All @@ -13,7 +13,7 @@
import { Message, parseI18nMessages } from '~/core/utils/i18n';
import { writeFileIfDifferent, getPublicFiles } from '~/core/utils/fs';
import { wxt } from '../../wxt';
import { isModuleInstalled } from '../package';

Check failure on line 16 in src/core/utils/building/generate-wxt-dir.ts

View workflow job for this annotation

GitHub Actions / type-check

'isModuleInstalled' is declared but its value is never read.

/**
* Generate and write all the files inside the `InternalConfig.typesDir` directory.
Expand Down Expand Up @@ -64,7 +64,7 @@
unimport: Unimport,
options: WxtResolvedUnimportOptions,
) {
const globals: Record<string, ESLintGlobalsPropValue> = {};
const globals: Record<string, EslintGlobalsPropValue> = {};
const eslintrc = { globals };

(await unimport.getImports())
Expand Down
14 changes: 7 additions & 7 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,14 @@ export type VirtualEntrypointType =
| 'background'
| 'unlisted-script';

export type ESLintGlobalsPropValue =
export type EslintGlobalsPropValue =
| boolean
| 'readonly'
| 'readable'
| 'writable'
| 'writeable';

export interface ESLintrc {
export interface Eslintrc {
/**
* When true, generates a file that can be used by ESLint to know which variables are valid globals.
*
Expand All @@ -982,23 +982,23 @@ export interface ESLintrc {
/**
* @default true
*/
globalsPropValue?: ESLintGlobalsPropValue;
globalsPropValue?: EslintGlobalsPropValue;
}

export interface ResolvedESLintrc {
export interface ResolvedEslintrc {
enabled: boolean;
/** Absolute path */
filePath: string;
globalsPropValue: ESLintGlobalsPropValue;
globalsPropValue: EslintGlobalsPropValue;
}

export type WxtUnimportOptions = Partial<UnimportOptions> & {
/**
* When eslint is installed,
*/
eslintrc?: ESLintrc;
eslintrc?: Eslintrc;
};

export type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
eslintrc: ResolvedESLintrc;
eslintrc: ResolvedEslintrc;
};
Loading