Skip to content

Commit

Permalink
Fix TypeScript exports (#6703)
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Mar 14, 2023
1 parent c9ad356 commit 7f801dd
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 214 deletions.
2 changes: 1 addition & 1 deletion lib/createPlugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

/**
* @type {import('stylelint').default['createPlugin']}
* @type {import('stylelint')['createPlugin']}
*/
module.exports = function createPlugin(ruleName, rule) {
return {
Expand Down
2 changes: 1 addition & 1 deletion lib/createStylelint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const IS_TEST = process.env.NODE_ENV === 'test';
const STOP_DIR = IS_TEST ? process.cwd() : undefined;

/**
* @type {import('stylelint').default['_createLinter']}
* @type {import('stylelint')['_createLinter']}
*/
module.exports = function createStylelint(options = {}) {
const cwd = options.cwd || process.cwd();
Expand Down
2 changes: 1 addition & 1 deletion lib/formatters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const importLazy = require('import-lazy');

/** @type {import('stylelint').default['formatters']} */
/** @type {import('stylelint')['formatters']} */
const formatters = {
compact: importLazy(() => require('./compactFormatter'))(),
github: importLazy(() => require('./githubFormatter'))(),
Expand Down
4 changes: 1 addition & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { longhandSubPropertiesOfShorthandProperties } = require('./reference/prop
const standalone = require('./standalone');
const validateOptions = require('./utils/validateOptions');

/** @type {import('stylelint').default} */
/** @type {import('stylelint')} */
const stylelint = Object.assign(postcssPlugin, {
lint: standalone,
rules,
Expand All @@ -33,5 +33,3 @@ const stylelint = Object.assign(postcssPlugin, {
});

module.exports = stylelint;
// @ts-ignore -- To adjust type for CommonJS, we export the default property.
module.exports.default = stylelint;
2 changes: 1 addition & 1 deletion lib/resolveConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const createStylelint = require('./createStylelint');
const getConfigForFile = require('./getConfigForFile');

/**
* @type {import('stylelint').default['resolveConfig']}
* @type {import('stylelint')['resolveConfig']}
*/
module.exports = async function resolveConfig(
filePath,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const importLazy = require('import-lazy');

/** @type {import('stylelint').default['rules']} */
/** @type {import('stylelint')['rules']} */
const rules = {
'alpha-value-notation': importLazy(() => require('./alpha-value-notation'))(),
'annotation-no-unknown': importLazy(() => require('./annotation-no-unknown'))(),
Expand Down
2 changes: 1 addition & 1 deletion lib/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const writeFileAtomic = require('write-file-atomic');
/** @typedef {import('stylelint').FormatterType} FormatterType */

/**
* @type {import('stylelint').default['lint']}
* @type {import('stylelint')['lint']}
*/
async function standalone({
allowEmptyInput = false,
Expand Down
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
"@types/micromatch": "^4.0.2",
"@types/normalize-path": "^3.0.0",
"@types/postcss-less": "^4.0.2",
"@types/postcss-media-query-parser": "^0.2.0",
"@types/postcss-resolve-nested-selector": "^0.1.0",
"@types/postcss-safe-parser": "^5.0.1",
"@types/style-search": "^0.1.3",
"@types/svg-tags": "^1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
Expand All @@ -13,10 +12,11 @@
"noImplicitReturns": false,
"noUnusedParameters": true,
"noUncheckedIndexedAccess": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": false,
"typeRoots": ["./types", "./node_modules/@types"]
"paths": {
"*": ["./node_modules/@types/*", "./types/*"]
}
},
"include": ["lib", "types", "package.json"],
"exclude": ["**/*.test.js", "**/__tests__/"]
Expand Down
35 changes: 0 additions & 35 deletions types/postcss-media-query-parser/index.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions types/postcss-resolve-nested-selector/index.d.ts

This file was deleted.

0 comments on commit 7f801dd

Please sign in to comment.