diff --git a/types/postcss-modules-scope/index.d.ts b/types/postcss-modules-scope/index.d.ts new file mode 100644 index 0000000000..b5f9e2c231 --- /dev/null +++ b/types/postcss-modules-scope/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for postcss-modules-scope 1.1 +// Project: https://github.com/css-modules/postcss-modules-scope +// Definitions by: Jeow Li Huan +// Definitions: https://github.com/huan086/postcss-plugins-typings +// TypeScript Version: 2.2 + +import { Plugin } from "postcss"; + +declare namespace scope { + interface Options { + generateScopedName?: (exportedName: string, path: string, css: string) => string; + } + + type Scope = Plugin; +} + +declare const scope: scope.Scope; +export = scope; diff --git a/types/postcss-modules-scope/package.json b/types/postcss-modules-scope/package.json new file mode 100644 index 0000000000..1e1a719545 --- /dev/null +++ b/types/postcss-modules-scope/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "postcss": "7.x.x" + } +} diff --git a/types/postcss-modules-scope/postcss-modules-scope-tests.ts b/types/postcss-modules-scope/postcss-modules-scope-tests.ts new file mode 100644 index 0000000000..b77fa74ab9 --- /dev/null +++ b/types/postcss-modules-scope/postcss-modules-scope-tests.ts @@ -0,0 +1,15 @@ +import scope = require("postcss-modules-scope"); +import { Transformer } from "postcss"; + +const ap1: Transformer = scope(); + +const ap2: Transformer = scope({ + generateScopedName(exportedName, path, css) { + if (css.substring(0, 7) === "@ignore") { + return exportedName; + } + + const sanitisedPath = path.replace(/\.[^\.\/\\]+$/, "").replace(/[\W_]+/g, "_").replace(/^_|_$/g, ""); +return `_${sanitisedPath}__${exportedName}`; + } +}); diff --git a/types/postcss-modules-scope/tsconfig.json b/types/postcss-modules-scope/tsconfig.json new file mode 100644 index 0000000000..b90423a698 --- /dev/null +++ b/types/postcss-modules-scope/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-scope-tests.ts" + ] +} diff --git a/types/postcss-modules-scope/tslint.json b/types/postcss-modules-scope/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/postcss-modules-scope/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }