Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoTomeES committed Nov 5, 2023
1 parent 2d5c3d3 commit 156cb31
Show file tree
Hide file tree
Showing 5 changed files with 506 additions and 1,252 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Regular expresion to match class names now is more strict, avoiding matches with incomplete class names.

## [1.1.2] - 2023-11-04

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Here's an example of the plugin in action in my [awa-db](https://github.com/Rodr

Here's a list of tasks I plan to work on:

- [ ] Fix error types
- [x] Fix error types
- [x] Add test coverage
- [ ] Add support for IDs
- [ ] Enable handling of multiple CSS files
Expand Down
17 changes: 13 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import postcssRename from 'postcss-rename';
import type { InternalRenameOptions } from './types.js';
import type { Options as PostcssRenameOptions } from 'postcss-rename';
import type { CSSOptions, UserConfig } from 'vite';
import type { ProcessOptions } from 'postcss';
import type { ResultPlugin } from 'postcss-load-config';
import type { Document as Document_, Root as Root_ } from 'postcss';

export const MAPS_DIRECTORY = './class-maps';

Expand Down Expand Up @@ -36,9 +39,6 @@ export const getPostCssConfig = async (
if (
!(typeof postcssInlineOptions === 'object' && postcssInlineOptions !== null)
) {
// TODO: Check types
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const { default: postcssrc } = await import('postcss-load-config');
const searchPath =
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand All @@ -54,10 +54,19 @@ export const getPostCssConfig = async (
return postcssConfigResult;
};

// Explicitly type the return value because of a bug in typescript
// @see https://github.com/microsoft/TypeScript/issues/42873
export const getViteConfiguration = async (
options: InternalRenameOptions['rename'],
viteConfig: UserConfig,
) => {
): Promise<{
css: {
postcss: {
options: ProcessOptions<Document_ | Root_>;
plugins: ResultPlugin[];
};
};
}> => {
// We need to manually load postcss config files because when inlining the tailwind and autoprefixer plugins,
// that causes vite to ignore postcss config files
const postcssConfigResult = await getPostCssConfig(
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": false,
"allowSyntheticDefaultImports": true,
"allowUmdGlobalAccess": false,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
Expand Down
Loading

0 comments on commit 156cb31

Please sign in to comment.