typescript-plugin-css-modules
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,2 +0,3 @@ | ||
export declare const isCSS: (fileName: string) => boolean; | ||
export declare const isRelativeCSS: (fileName: string) => boolean; | ||
export declare type isCSSFn = (fileName: string) => boolean; | ||
export declare const createIsCSS: (customMatcher?: RegExp) => isCSSFn; | ||
export declare const createIsRelativeCSS: (isCSS: isCSSFn) => (fileName: string) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var DEFAULT_REGEXP = /\.module\.(sa|sc|c)ss$/; | ||
var isRelative = function (fileName) { return /^\.\.?($|[\\/])/.test(fileName); }; | ||
exports.isCSS = function (fileName) { | ||
return /\.module\.(sa|sc|c)ss$/.test(fileName); | ||
exports.createIsCSS = function (customMatcher) { | ||
if (customMatcher === void 0) { customMatcher = DEFAULT_REGEXP; } | ||
return function (fileName) { return customMatcher.test(fileName); }; | ||
}; | ||
exports.isRelativeCSS = function (fileName) { | ||
return exports.isCSS(fileName) && isRelative(fileName); | ||
}; | ||
exports.createIsRelativeCSS = function (isCSS) { return function (fileName) { | ||
return isCSS(fileName) && isRelative(fileName); | ||
}; }; |
"use strict"; | ||
var path = require("path"); | ||
var ts_module = require("typescript/lib/tsserverlibrary"); | ||
var cssExtensions_1 = require("./helpers/cssExtensions"); | ||
var createMatchers_1 = require("./helpers/createMatchers"); | ||
var cssSnapshots_1 = require("./helpers/cssSnapshots"); | ||
function init(_a) { | ||
var ts = _a.typescript; | ||
var isCSS = cssExtensions_1.isCSS; | ||
var _isCSS; | ||
function create(info) { | ||
// User options for plugin. | ||
var options = info.config.options || {}; | ||
// Allow custom matchers to be used, handling bad matcher patterns; | ||
try { | ||
var customMatcher_1 = options.customMatcher; | ||
if (customMatcher_1) { | ||
isCSS = function (fileName) { return new RegExp(customMatcher_1).test(fileName); }; | ||
} | ||
} | ||
catch (e) { | ||
// TODO: Provide error/warning to user. | ||
} | ||
// Create matchers using options object. | ||
var _a = createMatchers_1.createMatchers(options), isCSS = _a.isCSS, isRelativeCSS = _a.isRelativeCSS; | ||
_isCSS = isCSS; | ||
// Creates new virtual source files for the CSS modules. | ||
@@ -61,3 +54,3 @@ var _createLanguageServiceSourceFile = ts.createLanguageServiceSourceFile; | ||
return moduleNames.map(function (moduleName, index) { | ||
if (cssExtensions_1.isRelativeCSS(moduleName)) { | ||
if (isRelativeCSS(moduleName)) { | ||
return { | ||
@@ -76,3 +69,3 @@ extension: ts_module.Extension.Dts, | ||
function getExternalFiles(project) { | ||
return project.getFileNames().filter(isCSS); | ||
return project.getFileNames().filter(_isCSS); | ||
} | ||
@@ -79,0 +72,0 @@ return { create: create, getExternalFiles: getExternalFiles }; |
{ | ||
"name": "typescript-plugin-css-modules", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "author": "Brody McKee <mrmckeb@hotmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152951
36
671