Skip to content

Commit d73e5a4

Browse files
authored
chore: bump dependencies (#131)
* chore: bump dependencies * chore: upgrade PostCSS and plugins * ci: bump Node version to current LTS
1 parent d322c24 commit d73e5a4

17 files changed

+2146
-2757
lines changed

.eslintrc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
{
2-
"extends": [
3-
"plugin:@typescript-eslint/recommended",
4-
"prettier",
5-
"prettier/@typescript-eslint"
6-
],
7-
"root": true,
8-
"rules": {
9-
"@typescript-eslint/explicit-function-return-type": 0
10-
}
2+
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
3+
"root": true
114
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v1
1010
- uses: actions/setup-node@v1
1111
with:
12-
node-version: 10.x
12+
node-version: 14.x
1313
- name: Install
1414
run: yarn install --frozen-lockfile
1515
- name: Lint

package.json

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
],
2727
"scripts": {
2828
"build": "rm -rf ./lib && tsc",
29-
"lint": "eslint './src/**/*.{js,ts}' --max-warnings 0 && yarn prettier './**/*.{json,md,js,ts,yml}' -c",
29+
"lint": "eslint --max-warnings 0 . && yarn prettier -c .",
3030
"prepublishOnly": "yarn build",
3131
"test": "jest ./src"
3232
},
@@ -42,6 +42,9 @@
4242
"src/**/*.{ts}"
4343
],
4444
"preset": "ts-jest",
45+
"setupFiles": [
46+
"<rootDir>/src/setup-tests.ts"
47+
],
4548
"testEnvironment": "node",
4649
"testPathIgnorePatterns": [
4750
"/node_modules/",
@@ -62,47 +65,47 @@
6265
"trailingComma": "all"
6366
},
6467
"resolutions": {
65-
"postcss": "7.0.27"
68+
"postcss": "8.3.0"
6669
},
6770
"dependencies": {
68-
"dotenv": "^8.2.0",
69-
"icss-utils": "^4.1.1",
70-
"less": "^3.11.1",
71+
"dotenv": "^10.0.0",
72+
"icss-utils": "^5.1.0",
73+
"less": "^4.1.1",
7174
"lodash.camelcase": "^4.3.0",
72-
"postcss": "^7.0.27",
75+
"postcss": "^8.3.0",
7376
"postcss-filter-plugins": "^3.0.1",
7477
"postcss-icss-keyframes": "^0.2.1",
7578
"postcss-icss-selectors": "^2.0.3",
76-
"postcss-load-config": "^2.1.0",
79+
"postcss-load-config": "^3.0.1",
7780
"reserved-words": "^0.1.2",
78-
"sass": "^1.26.5",
79-
"stylus": "^0.54.7",
81+
"sass": "^1.32.13",
82+
"stylus": "^0.54.8",
8083
"tsconfig-paths": "^3.9.0"
8184
},
8285
"devDependencies": {
8386
"@types/icss-utils": "^4.1.0",
84-
"@types/jest": "^25.2.1",
85-
"@types/less": "^3.0.1",
87+
"@types/jest": "^26.0.23",
88+
"@types/less": "^3.0.2",
8689
"@types/lodash.camelcase": "^4.3.6",
8790
"@types/node": "^12.12.17",
88-
"@types/postcss-load-config": "^2.0.1",
89-
"@types/postcss-nested": "^4.1.0",
91+
"@types/postcss-load-config": "^3.0.1",
92+
"@types/postcss-nested": "^4.2.3",
9093
"@types/reserved-words": "^0.1.0",
9194
"@types/sass": "^1.16.0",
92-
"@types/stylus": "^0.48.33",
93-
"@typescript-eslint/eslint-plugin": "^2.29.0",
94-
"@typescript-eslint/parser": "^2.29.0",
95-
"bootstrap": "4.4.1",
96-
"eslint": "^6.8.0",
97-
"eslint-config-prettier": "^6.11.0",
95+
"@types/stylus": "^0.48.34",
96+
"@typescript-eslint/eslint-plugin": "^4.25.0",
97+
"@typescript-eslint/parser": "^4.25.0",
98+
"bootstrap": "5.0.1",
99+
"eslint": "^7.27.0",
100+
"eslint-config-prettier": "^8.3.0",
98101
"husky": "^4.2.5",
99-
"jest": "^25.4.0",
100-
"lint-staged": "^10.1.7",
102+
"jest": "^27.0.2",
103+
"lint-staged": "^11.0.0",
101104
"postcss-import-sync2": "^1.1.0",
102-
"prettier": "^2.0.5",
105+
"prettier": "^2.3.0",
103106
"sass-svg": "1.2.0",
104-
"ts-jest": "^25.4.0",
105-
"typescript": "^3.8.3"
107+
"ts-jest": "^27.0.1",
108+
"typescript": "^4.3.2"
106109
},
107110
"peerDependencies": {
108111
"typescript": ">=3.0.0"

src/@types/postcss-filter-plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ declare module 'postcss-filter-plugins' {
55
exclude?: string[];
66
silent?: boolean;
77
}
8-
const filter: (options?: Options) => Plugin<unknown>;
8+
const filter: (options?: Options) => Plugin;
99
export = filter;
1010
}

src/@types/postcss-icss-keyframes.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare module 'postcss-icss-keyframes' {
2-
import { Plugin } from 'postcss';
3-
const plugin: Plugin<{
2+
import { PluginCreator } from 'postcss';
3+
const plugin: PluginCreator<{
44
generateScopeName: (
55
keyframesName: string,
66
filepath: string,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'postcss-icss-selectors' {
2-
import { Plugin } from 'postcss';
3-
const plugin: Plugin<{ mode: 'local' | 'global' }>;
2+
import { PluginCreator } from 'postcss';
3+
const plugin: PluginCreator<{ mode: 'local' | 'global' }>;
44
export = plugin;
55
}

src/@types/postcss-import-sync2.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'postcss-import-sync2' {
2-
import { Plugin } from 'postcss';
3-
const plugin: Plugin<{}>;
2+
import { PluginCreator } from 'postcss';
3+
const plugin: PluginCreator<unknown>;
44
export = plugin;
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.public-module {
2-
color: green;
2+
color: green;
33
}

src/helpers/classTransforms.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@ import { ClassnameTransformOptions } from '../options';
44
// The below is based on the CSS Modules implementation found here:
55
// https://github.com/webpack-contrib/css-loader/blob/master/lib/compile-exports.js
66

7-
const dashCase = (className: string) =>
8-
className.replace(/-+(\w)/g, (match, firstLetter) =>
7+
const dashCase = (className: string): string =>
8+
className.replace(/-+(\w)/g, (_match, firstLetter) =>
99
firstLetter.toUpperCase(),
1010
);
1111

12-
export const transformClasses = (
13-
camelCaseOption?: ClassnameTransformOptions,
14-
) => (className: string) => {
15-
const entries: string[] = [];
12+
export const transformClasses =
13+
(camelCaseOption?: ClassnameTransformOptions) =>
14+
(className: string): string[] => {
15+
const entries: string[] = [];
1616

17-
switch (camelCaseOption) {
18-
case 'camelCase': {
19-
entries.push(className);
20-
const targetClassName = camelCase(className);
21-
if (targetClassName !== className) {
22-
entries.push(targetClassName);
17+
switch (camelCaseOption) {
18+
case 'camelCase': {
19+
entries.push(className);
20+
const targetClassName = camelCase(className);
21+
if (targetClassName !== className) {
22+
entries.push(targetClassName);
23+
}
24+
break;
2325
}
24-
break;
25-
}
26-
case 'camelCaseOnly':
27-
entries.push(camelCase(className));
28-
break;
29-
case 'dashes': {
30-
entries.push(className);
31-
const targetClassName = dashCase(className);
32-
if (targetClassName !== className) {
33-
entries.push(targetClassName);
26+
case 'camelCaseOnly':
27+
entries.push(camelCase(className));
28+
break;
29+
case 'dashes': {
30+
entries.push(className);
31+
const targetClassName = dashCase(className);
32+
if (targetClassName !== className) {
33+
entries.push(targetClassName);
34+
}
35+
break;
3436
}
35-
break;
37+
case 'dashesOnly':
38+
entries.push(dashCase(className));
39+
break;
40+
case 'asIs':
41+
default:
42+
entries.push(className);
43+
break;
3644
}
37-
case 'dashesOnly':
38-
entries.push(dashCase(className));
39-
break;
40-
case 'asIs':
41-
default:
42-
entries.push(className);
43-
break;
44-
}
4545

46-
return entries;
47-
};
46+
return entries;
47+
};

src/helpers/createExports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const createExports = ({
2525
fileName: string;
2626
logger: Logger;
2727
options: Options;
28-
}) => {
28+
}): string => {
2929
const isCamelCase = (className: string) =>
3030
!NOT_CAMELCASE_REGEXP.test(className);
3131
const isReservedWord = (className: string) => !reserved.check(className);

src/helpers/createMatchers.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
import { Options } from '../options';
2-
import { createIsCSS, createIsRelativeCSS } from './cssExtensions';
2+
import {
3+
createIsCSS,
4+
createIsRelativeCSS,
5+
isCSSFn,
6+
isRelativeCSSFn,
7+
} from './cssExtensions';
38
import { Logger } from './logger';
49

5-
export const createMatchers = (logger: Logger, options: Options = {}) => {
10+
interface Matchers {
11+
isCSS: isCSSFn;
12+
isRelativeCSS: isRelativeCSSFn;
13+
}
14+
15+
export const createMatchers = (
16+
logger: Logger,
17+
options: Options = {},
18+
): Matchers => {
619
// Allow custom matchers to be used, and handle bad matcher patterns.
720
let isCSS = createIsCSS();
821
try {

src/helpers/cssExtensions.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
export type isCSSFn = (fileName: string) => boolean;
2+
export type isRelativeCSSFn = (fileName: string) => boolean;
3+
24
const DEFAULT_REGEXP = /\.module\.(((c|le|sa|sc)ss)|styl)$/;
35

46
const isRelative = (fileName: string) => /^\.\.?($|[\\/])/.test(fileName);
57

6-
export const createIsCSS = (
7-
customMatcher: RegExp = DEFAULT_REGEXP,
8-
): isCSSFn => (fileName: string) => customMatcher.test(fileName);
9-
export const createIsRelativeCSS = (isCSS: isCSSFn) => (fileName: string) =>
10-
isCSS(fileName) && isRelative(fileName);
8+
export const createIsCSS =
9+
(customMatcher: RegExp = DEFAULT_REGEXP): isCSSFn =>
10+
(fileName: string) =>
11+
customMatcher.test(fileName);
12+
export const createIsRelativeCSS =
13+
(isCSS: isCSSFn): isRelativeCSSFn =>
14+
(fileName: string) =>
15+
isCSS(fileName) && isRelative(fileName);

src/helpers/getClasses.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import path from 'path';
2-
import postcss from 'postcss';
2+
import Processor from 'postcss/lib/processor';
33
import less from 'less';
44
import sass from 'sass';
55
import stylus from 'stylus';
6-
import { extractICSS } from 'icss-utils';
6+
import { CSSExports, extractICSS } from 'icss-utils';
77
import tsModule from 'typescript/lib/tsserverlibrary';
88
import { createMatchPath } from 'tsconfig-paths';
99
import { sassTildeImporter } from '../importers/sassTildeImporter';
1010
import { Options, CustomRenderer } from '../options';
1111
import { Logger } from './logger';
1212

13-
export const enum FileTypes {
13+
export const enum FileType {
1414
css = 'css',
1515
less = 'less',
1616
sass = 'sass',
1717
scss = 'scss',
1818
styl = 'styl',
1919
}
2020

21-
export const getFileType = (fileName: string) => {
22-
if (fileName.endsWith('.css')) return FileTypes.css;
23-
if (fileName.endsWith('.less')) return FileTypes.less;
24-
if (fileName.endsWith('.sass')) return FileTypes.sass;
25-
if (fileName.endsWith('.styl')) return FileTypes.styl;
26-
return FileTypes.scss;
21+
export const getFileType = (fileName: string): FileType => {
22+
if (fileName.endsWith('.css')) return FileType.css;
23+
if (fileName.endsWith('.less')) return FileType.less;
24+
if (fileName.endsWith('.sass')) return FileType.sass;
25+
if (fileName.endsWith('.styl')) return FileType.styl;
26+
return FileType.scss;
2727
};
2828

2929
const getFilePath = (fileName: string) => path.dirname(fileName);
@@ -40,9 +40,9 @@ export const getClasses = ({
4040
fileName: string;
4141
logger: Logger;
4242
options: Options;
43-
processor: postcss.Processor;
43+
processor: Processor;
4444
compilerOptions: tsModule.CompilerOptions;
45-
}) => {
45+
}): CSSExports => {
4646
try {
4747
const fileType = getFileType(fileName);
4848
const rendererOptions = options.rendererOptions || {};
@@ -57,7 +57,7 @@ export const getClasses = ({
5757
logger,
5858
compilerOptions,
5959
});
60-
} else if (fileType === FileTypes.less) {
60+
} else if (fileType === FileType.less) {
6161
less.render(
6262
css,
6363
{
@@ -70,7 +70,7 @@ export const getClasses = ({
7070
transformedCss = output.css.toString();
7171
},
7272
);
73-
} else if (fileType === FileTypes.scss || fileType === FileTypes.sass) {
73+
} else if (fileType === FileType.scss || fileType === FileType.sass) {
7474
const filePath = getFilePath(fileName);
7575
const { includePaths, ...sassOptions } = rendererOptions.sass || {};
7676
const { baseUrl, paths } = compilerOptions;
@@ -87,13 +87,13 @@ export const getClasses = ({
8787
transformedCss = sass
8888
.renderSync({
8989
file: fileName,
90-
indentedSyntax: fileType === FileTypes.sass,
90+
indentedSyntax: fileType === FileType.sass,
9191
includePaths: [filePath, 'node_modules', ...(includePaths || [])],
9292
importer: importers,
9393
...sassOptions,
9494
})
9595
.css.toString();
96-
} else if (fileType === FileTypes.styl) {
96+
} else if (fileType === FileType.styl) {
9797
transformedCss = stylus(css, {
9898
...(rendererOptions.stylus || {}),
9999
filename: fileName,

src/helpers/getDtsSnapshot.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import postcss from 'postcss';
21
import tsModule from 'typescript/lib/tsserverlibrary';
32
import { Options } from '../options';
43
import { getClasses } from './getClasses';
54
import { createExports } from './createExports';
65
import { Logger } from './logger';
6+
import Processor from 'postcss/lib/processor';
77

88
export const getDtsSnapshot = (
99
ts: typeof tsModule,
10-
processor: postcss.Processor,
10+
processor: Processor,
1111
fileName: string,
1212
scriptSnapshot: ts.IScriptSnapshot,
1313
options: Options,
1414
logger: Logger,
1515
compilerOptions: tsModule.CompilerOptions,
16-
) => {
16+
): tsModule.IScriptSnapshot => {
1717
const css = scriptSnapshot.getText(0, scriptSnapshot.getLength());
1818

1919
/*

0 commit comments

Comments
 (0)