diff --git a/types/postcss-modules-local-by-default/index.d.ts b/types/postcss-modules-local-by-default/index.d.ts new file mode 100644 index 0000000000..5421ecd58b --- /dev/null +++ b/types/postcss-modules-local-by-default/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for postcss-modules-local-by-default 1.2 +// Project: https://github.com/css-modules/postcss-modules-local-by-default +// Definitions by: Jeow Li Huan +// Definitions: https://github.com/huan086/postcss-plugins-typings +// TypeScript Version: 2.2 + +import { Plugin } from "postcss"; + +declare namespace localByDefault { + interface Options { + mode?: "global" | "local" | "pure"; + rewriteUrl?: (global: boolean, url: string) => string; + } + + type LocalByDefault = Plugin; +} + +declare const localByDefault: localByDefault.LocalByDefault; +export = localByDefault; diff --git a/types/postcss-modules-local-by-default/package.json b/types/postcss-modules-local-by-default/package.json new file mode 100644 index 0000000000..1e1a719545 --- /dev/null +++ b/types/postcss-modules-local-by-default/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "postcss": "7.x.x" + } +} diff --git a/types/postcss-modules-local-by-default/postcss-modules-local-by-default-tests.ts b/types/postcss-modules-local-by-default/postcss-modules-local-by-default-tests.ts new file mode 100644 index 0000000000..7d388471ab --- /dev/null +++ b/types/postcss-modules-local-by-default/postcss-modules-local-by-default-tests.ts @@ -0,0 +1,21 @@ +import localByDefault = require("postcss-modules-local-by-default"); +import { Transformer } from "postcss"; + +const ap1: Transformer = localByDefault(); + +const ap2: Transformer = localByDefault({ + mode: "global", + rewriteUrl: (global, url) => { + url = url.trim(); + + if (!url.replace(/\s/g, "").length) { + return url; + } + + if (global) { + return url + "?request"; + } + + return url; + } +}); diff --git a/types/postcss-modules-local-by-default/tsconfig.json b/types/postcss-modules-local-by-default/tsconfig.json new file mode 100644 index 0000000000..6634c36375 --- /dev/null +++ b/types/postcss-modules-local-by-default/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "postcss-modules-local-by-default-tests.ts" + ] +} diff --git a/types/postcss-modules-local-by-default/tslint.json b/types/postcss-modules-local-by-default/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/postcss-modules-local-by-default/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }