Skip to content

Commit be3530f

Browse files
committed
feat: update DOCS and bump dependencies
1 parent 76d75d6 commit be3530f

File tree

5 files changed

+722
-631
lines changed

5 files changed

+722
-631
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ When a custom renderer is provided, not other renderers will be used.
122122

123123
The path to the `customRenderer` must be relative to the project root (i.e. `./myRenderer.js`).
124124

125-
The custom renderer itself should be a JavaScript file. The function will be called with three arguments: a `css` string, an `options` object and an `compilerOptions` object that is defined in `tsconfig.json` the `tsc` used. (see [`options.ts`](https://github.com/mrmckeb/typescript-plugin-css-modules/blob/master/src/options.ts#L33-L41)). It must be synchronous, and must return valid CSS.
125+
The custom renderer itself should be a JavaScript file. The function will be called with three arguments: a `css` string, an `options` object (see [`options.ts`](https://github.com/mrmckeb/typescript-plugin-css-modules/blob/master/src/options.ts#L33-L41)), and a `compilerOptions` object - which contains options as set in your `tsconfig.json`. It must be synchronous, and must return valid CSS.
126126

127127
```js
128128
module.exports = (css, { fileName, logger }) => {
@@ -139,7 +139,9 @@ You can find an example custom renderer in our test fixtures ([`customRenderer.j
139139

140140
The [internal `logger`](https://github.com/mrmckeb/typescript-plugin-css-modules/blob/master/src/helpers/logger.ts) is provided for [debugging](#troubleshooting).
141141

142-
> Note: If you are working with webpack and [`less-loader`](https://www.npmjs.com/package/less-loader), you can choose resolver that webpack provided and webpack will resolve the `@import` file path that start with `~`, but `~` is not support by less natively, and the plugin will break down, then we can use `less-plugin-aliases` npm package make it works again, more details can find [here](https://github.com/mrmckeb/typescript-plugin-css-modules/issues/77) and [here](https://github.com/dancon/less-plugin-aliases)
142+
> If you use Webpack, note that tilde (`~`) imports not supported by Less and Sass natively.
143+
>
144+
> For Less users, this package exports a customRenderer that enables tilde imports: [`less-plugin-aliases`](https://github.com/dancon/less-plugin-aliases).
143145
144146
#### `customTemplate`
145147

package.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@
5757
]
5858
},
5959
"prettier": {
60-
"arrowParens": "always",
61-
"singleQuote": true,
62-
"trailingComma": "all"
60+
"singleQuote": true
6361
},
6462
"resolutions": {
6563
"postcss": "7.0.27"
@@ -74,30 +72,30 @@
7472
"postcss-icss-selectors": "^2.0.3",
7573
"postcss-load-config": "^2.1.0",
7674
"reserved-words": "^0.1.2",
77-
"sass": "^1.26.1"
75+
"sass": "^1.26.5"
7876
},
7977
"devDependencies": {
8078
"@types/icss-utils": "^4.1.0",
81-
"@types/jest": "^25.1.3",
79+
"@types/jest": "^25.2.1",
8280
"@types/less": "^3.0.1",
8381
"@types/lodash.camelcase": "^4.3.6",
8482
"@types/node": "^12.12.17",
8583
"@types/postcss-load-config": "^2.0.1",
8684
"@types/postcss-nested": "^4.1.0",
8785
"@types/reserved-words": "^0.1.0",
8886
"@types/sass": "^1.16.0",
89-
"@typescript-eslint/eslint-plugin": "^2.21.0",
90-
"@typescript-eslint/parser": "^2.21.0",
87+
"@typescript-eslint/eslint-plugin": "^2.29.0",
88+
"@typescript-eslint/parser": "^2.29.0",
9189
"bootstrap": "4.4.1",
9290
"eslint": "^6.8.0",
93-
"eslint-config-prettier": "^6.10.0",
94-
"husky": "^4.2.3",
95-
"jest": "^25.1.0",
96-
"lint-staged": "^10.0.8",
91+
"eslint-config-prettier": "^6.11.0",
92+
"husky": "^4.2.5",
93+
"jest": "^25.4.0",
94+
"lint-staged": "^10.1.7",
9795
"postcss-import-sync2": "^1.1.0",
98-
"prettier": "^1.19.1",
99-
"ts-jest": "^25.2.1",
100-
"typescript": "^3.8.2"
96+
"prettier": "^2.0.5",
97+
"ts-jest": "^25.4.0",
98+
"typescript": "^3.8.3"
10199
},
102100
"peerDependencies": {
103101
"typescript": "^3.0.0"

src/helpers/getClasses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const getClasses = ({
6363
(error, output) => {
6464
if (error || output === undefined) throw error;
6565
transformedCss = output.css.toString();
66-
},
66+
}
6767
);
6868
} else if (fileType === FileTypes.scss || fileType === FileTypes.sass) {
6969
const filePath = getFilePath(fileName);

src/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
4141
if (dotenvOptions) {
4242
dotenvOptions.path = path.resolve(
4343
directory,
44-
dotenvOptions.path || '.env',
44+
dotenvOptions.path || '.env'
4545
);
4646
}
4747
dotenv.config(dotenvOptions);
@@ -52,7 +52,7 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
5252
.map((sassPath) =>
5353
path.isAbsolute(sassPath)
5454
? sassPath
55-
: path.resolve(directory, sassPath),
55+
: path.resolve(directory, sassPath)
5656
)
5757
.join(path.delimiter);
5858
}
@@ -77,15 +77,15 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
7777
if (fs.existsSync(path.resolve(directory, options.customRenderer))) {
7878
options.customRenderer = path.resolve(
7979
directory,
80-
options.customRenderer,
80+
options.customRenderer
8181
);
8282
} else if (fs.existsSync(require.resolve(options.customRenderer))) {
8383
options.customRenderer = require.resolve(options.customRenderer);
8484
} else {
8585
logger.error(
8686
new Error(
87-
`Invalid 'customRenderer', '${options.customRenderer}' does not exist.`,
88-
),
87+
`The file or package for \`customRenderer\` '${options.customRenderer}' could not be resolved.`
88+
)
8989
);
9090
}
9191
}
@@ -120,13 +120,13 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
120120
scriptSnapshot,
121121
options,
122122
logger,
123-
compilerOptions,
123+
compilerOptions
124124
);
125125
}
126126
const sourceFile = _createLanguageServiceSourceFile(
127127
fileName,
128128
scriptSnapshot,
129-
...rest,
129+
...rest
130130
);
131131
if (isCSS(fileName)) {
132132
sourceFile.isDeclarationFile = true;
@@ -149,13 +149,13 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
149149
scriptSnapshot,
150150
options,
151151
logger,
152-
compilerOptions,
152+
compilerOptions
153153
);
154154
}
155155
sourceFile = _updateLanguageServiceSourceFile(
156156
sourceFile,
157157
scriptSnapshot,
158-
...rest,
158+
...rest
159159
);
160160
if (isCSS(sourceFile.fileName)) {
161161
sourceFile.isDeclarationFile = true;
@@ -165,7 +165,7 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
165165

166166
if (info.languageServiceHost.resolveModuleNames) {
167167
const _resolveModuleNames = info.languageServiceHost.resolveModuleNames.bind(
168-
info.languageServiceHost,
168+
info.languageServiceHost
169169
);
170170

171171
info.languageServiceHost.resolveModuleNames = (
@@ -176,7 +176,7 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
176176
const resolvedModules = _resolveModuleNames(
177177
moduleNames,
178178
containingFile,
179-
...rest,
179+
...rest
180180
);
181181

182182
return moduleNames.map((moduleName, index) => {
@@ -187,15 +187,15 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
187187
isExternalLibraryImport: false,
188188
resolvedFileName: path.resolve(
189189
path.dirname(containingFile),
190-
moduleName,
190+
moduleName
191191
),
192192
};
193193
} else if (isCSS(moduleName)) {
194194
// TODO: Move this section to a separate file and add basic tests.
195195
// Attempts to locate the module using TypeScript's previous search paths. These include "baseUrl" and "paths".
196196
const failedModule = info.project.getResolvedModuleWithFailedLookupLocationsFromCache(
197197
moduleName,
198-
containingFile,
198+
containingFile
199199
);
200200
const baseUrl = info.project.getCompilerOptions().baseUrl;
201201
const match = '/index.ts';
@@ -219,12 +219,12 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
219219
}
220220
return locations;
221221
},
222-
[] as string[],
222+
[] as string[]
223223
);
224224

225225
// Find the imported CSS module, if it exists.
226226
const cssModulePath = normalizedLocations.find((location) =>
227-
fs.existsSync(location),
227+
fs.existsSync(location)
228228
);
229229

230230
if (cssModulePath) {

0 commit comments

Comments
 (0)