Skip to content

Commit e00338e

Browse files
committed
build(deps-dev): update dev dependencies
1 parent 663a6ac commit e00338e

File tree

7 files changed

+1406
-799
lines changed

7 files changed

+1406
-799
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.ru.md

package-lock.json

Lines changed: 1380 additions & 759 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"author": {
4646
"name": "Igor Teplostanski",
47-
"email": "teplostanski@yandex.ru",
47+
"email": "igor@teplostanski.dev",
4848
"url": "https://teplostanski.dev"
4949
},
5050
"funding": {
@@ -85,22 +85,22 @@
8585
"docs:preview": "vitepress preview docs"
8686
},
8787
"devDependencies": {
88-
"@eslint/js": "^9.0.0",
89-
"@types/node": "^22.15.2",
90-
"@vitest/coverage-v8": "^3.1.2",
91-
"eslint": "^9.25.1",
92-
"eslint-config-prettier": "^9.0.0",
93-
"eslint-plugin-prettier": "^5.0.0",
88+
"@eslint/js": "^9.27.0",
89+
"@types/node": "^22.15.21",
90+
"@vitest/coverage-v8": "^3.1.4",
91+
"eslint": "^9.27.0",
92+
"eslint-config-prettier": "^10.1.5",
93+
"eslint-plugin-prettier": "^5.4.0",
9494
"husky": "^9.1.7",
9595
"prettier": "^3.5.3",
9696
"standard-version": "^9.5.0",
97-
"tsdown": "^0.9.7",
97+
"tsdown": "^0.11.12",
9898
"typescript": "^5.8.3",
99-
"typescript-eslint": "^8.31.0",
100-
"vite": "^6.3.2",
99+
"typescript-eslint": "^8.32.1",
100+
"vite": "^6.3.5",
101101
"vite-plugin-qrcode": "^0.2.4",
102-
"vitepress": "^2.0.0-alpha.5",
103-
"vitepress-plugin-group-icons": "^1.5.2",
104-
"vitest": "^3.1.2"
102+
"vitepress": "^1.6.3",
103+
"vitepress-plugin-group-icons": "^1.5.5",
104+
"vitest": "^3.1.4"
105105
}
106106
}

src/constants.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import type { Options } from './types'
22

3-
export const GENERATE_SCOPED_NAME_WARNING =
3+
export const WARNING_MSG_GENERATE_SCOPED_NAME =
44
"[vite-plugin-readable-classnames]:: The 'generateScopedName' configuration has already been set. Your vite.config configuration or other plugins might be attempting to override this setting, which could affect the proper functioning of vite-plugin-readable-classnames."
55

6+
export const ERROR_MSG_INVALID_TYPE =
7+
'The filename must be string and cannot be undefined.'
8+
export const ERROR_MSG_INVALID_NAME = 'Filename must include a valid file name.'
9+
610
export const defaultOptions: Options = {
711
lineNumber: false,
812
separator: {

src/index.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Plugin, UserConfig } from 'vite'
2-
import { defaultOptions, GENERATE_SCOPED_NAME_WARNING } from './constants'
2+
import { defaultOptions, WARNING_MSG_GENERATE_SCOPED_NAME } from './constants'
33
import { deepMerge, getLineNumber, sanitizeModuleClassname } from './utils'
44
import type { DeepPartial, Options } from './types'
55

@@ -20,15 +20,6 @@ export default function readableClassnames(
2020
): Plugin {
2121
return {
2222
name: 'vite-plugin-readable-classnames',
23-
/**
24-
* Modifies the Vite configuration object to include custom settings for CSS module class name generation.
25-
* It checks if generateScopedName is already set by the user and throws an error if so.
26-
* If not set, it applies a custom generateScopedName function.
27-
*
28-
* @param {UserConfig} config - The original Vite configuration provided by the user.
29-
* @throws {Error} Throws an error if generateScopedName is already defined in the user's configuration.
30-
* @returns {UserConfig} A modified Vite configuration object with custom settings for CSS module class name generation.
31-
*/
3223
config(config: UserConfig): UserConfig {
3324
const options = deepMerge(defaultOptions, userOptions)
3425
const cssModules = config.css?.modules
@@ -44,7 +35,7 @@ export default function readableClassnames(
4435
'generateScopedName' in cssModules &&
4536
cssModules.generateScopedName
4637
) {
47-
console.warn(GENERATE_SCOPED_NAME_WARNING)
38+
console.warn(WARNING_MSG_GENERATE_SCOPED_NAME)
4839
}
4940

5041
const newCssConfig = {

src/utils.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createHash } from 'crypto'
22
import type { DeepPartial } from './types'
3+
import { ERROR_MSG_INVALID_TYPE, ERROR_MSG_INVALID_NAME } from './constants'
34

45
function getHash(input: string): string {
56
return createHash('sha256').update(input).digest('hex').slice(0, 5)
@@ -30,17 +31,6 @@ export function deepMerge<T>(
3031
return result
3132
}
3233

33-
/**
34-
* Generates a unique class name for CSS modules based on the file name and the specified class name.
35-
* The file name is processed to remove specific parts such as ".module" and file extensions.
36-
* If `lineNumber` is provided, it's added to the generated class name.
37-
*
38-
* @param name - The name of the CSS class that will be part of the generated unique name.
39-
* @param filename is the full path to the style file, which can be undefined. If the parameter is undefined, the function throws an exception.
40-
* @param lineNumber is the line number where the CSS class is defined, optional.
41-
* @returns A string with a unique class name, including a sanitized file name, the original class name, a randomly generated hash, and optionally the line number.
42-
* @throws Error if `filename` is not provided or is not a string.
43-
*/
4434
export function sanitizeModuleClassname(
4535
name: string,
4636
filename: string | undefined,
@@ -52,14 +42,14 @@ export function sanitizeModuleClassname(
5242
lineNumber?: number,
5343
): string {
5444
if (typeof filename !== 'string') {
55-
throw new Error('The filename must be string and cannot be undefined.')
45+
throw new Error(ERROR_MSG_INVALID_TYPE)
5646
}
5747

5848
const parts = filename.split('?')[0].split('/')
5949
const lastSegment = parts.pop()
6050

6151
if (!lastSegment) {
62-
throw new Error('Filename must include a valid file name.')
52+
throw new Error(ERROR_MSG_INVALID_NAME)
6353
}
6454

6555
const baseFilename = lastSegment.replace(/(\.vue|\.module)?(\.\w+)$/, '')

tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
22
import readableClassnames from '../src/index.js'
33
import type { UserConfig } from 'vite'
4-
import { GENERATE_SCOPED_NAME_WARNING } from '../src/constants.js'
4+
import { WARNING_MSG_GENERATE_SCOPED_NAME } from '../src/constants.js'
55

66
describe('readableClassnames', () => {
77
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -48,7 +48,7 @@ describe('readableClassnames', () => {
4848
}
4949

5050
callPluginConfig(plugin, config)
51-
expect(consoleSpy).toHaveBeenCalledWith(GENERATE_SCOPED_NAME_WARNING)
51+
expect(consoleSpy).toHaveBeenCalledWith(WARNING_MSG_GENERATE_SCOPED_NAME)
5252
})
5353

5454
it('should configure generateScopedName correctly without lineNumber', () => {

0 commit comments

Comments
 (0)