Skip to content

Commit 253c034

Browse files
committed
fix: remove references to external typings
Solves: #339
1 parent 1ff3ce4 commit 253c034

File tree

10 files changed

+60
-61
lines changed

10 files changed

+60
-61
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,20 @@ hooks.waiting.tap('yourListenerName', () => {
349349
});
350350
```
351351

352+
## Typings
353+
354+
To use the plugin typings, you have to install `@types/webpack`. It's not included by default to not collide with your
355+
existing typings (`@types/webpack` imports `@types/node`). [It's an old TypeScript issue](https://github.com/microsoft/TypeScript/issues/18588),
356+
the alternative is to set `skipLibCheck: true` in the `compilerOptions` 😉
357+
```sh
358+
# with npm
359+
npm install --save-dev @types/webpack
360+
361+
# with yarn
362+
yarn add --dev @types/webpack
363+
```
364+
365+
352366
## Related projects
353367

354368
* [`ts-loader`](https://github.com/TypeStrong/ts-loader) - TypeScript loader for webpack.

src/formatter/CodeframeFormatter.ts renamed to src/formatter/CodeFrameFormatter.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import os from 'os';
22
import fs from 'fs-extra';
3-
import { codeFrameColumns, BabelCodeFrameOptions } from '@babel/code-frame';
3+
import { codeFrameColumns } from '@babel/code-frame';
44
import { Formatter } from './Formatter';
55
import { createBasicFormatter } from './BasicFormatter';
6+
import { BabelCodeFrameOptions } from './types/babel__code-frame';
67

7-
function createCodeframeFormatter(options?: BabelCodeFrameOptions): Formatter {
8+
function createCodeFrameFormatter(options?: BabelCodeFrameOptions): Formatter {
89
const basicFormatter = createBasicFormatter();
910

10-
return function codeframeFormatter(issue) {
11+
return function codeFrameFormatter(issue) {
1112
const source = issue.file && fs.existsSync(issue.file) && fs.readFileSync(issue.file, 'utf-8');
1213

1314
let frame = '';
@@ -30,4 +31,4 @@ function createCodeframeFormatter(options?: BabelCodeFrameOptions): Formatter {
3031
};
3132
}
3233

33-
export { createCodeframeFormatter, BabelCodeFrameOptions };
34+
export { createCodeFrameFormatter, BabelCodeFrameOptions };

src/formatter/FormatterFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Formatter } from './Formatter';
2-
import { BabelCodeFrameOptions, createCodeframeFormatter } from './CodeframeFormatter';
2+
import { BabelCodeFrameOptions, createCodeFrameFormatter } from './CodeFrameFormatter';
33
import { createBasicFormatter } from './BasicFormatter';
44

55
type NotConfigurableFormatterType = undefined | 'basic';
@@ -31,7 +31,7 @@ function createFormatter(type?: FormatterType, options?: object): Formatter {
3131
return createBasicFormatter();
3232

3333
case 'codeframe':
34-
return createCodeframeFormatter(options);
34+
return createCodeFrameFormatter(options);
3535

3636
default:
3737
throw new Error(`Unknown "${type}" formatter. Available types are: basic, codeframe.`);

src/formatter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from './Formatter';
22
export * from './BasicFormatter';
3-
export * from './CodeframeFormatter';
3+
export * from './CodeFrameFormatter';
44
export * from './WebpackFormatter';
55
export * from './FormatterFactory';
66
export * from './FormatterOptions';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Base on the type definitions for @babel/code-frame 7.0
2+
// Project: https://github.com/babel/babel/tree/master/packages/babel-code-frame, https://babeljs.io
3+
// Definitions by: Mohsen Azimi <https://github.com/mohsen1>
4+
// Forbes Lindesay <https://github.com/ForbesLindesay>
5+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6+
7+
export interface BabelCodeFrameOptions {
8+
/** Syntax highlight the code as JavaScript for terminals. default: false */
9+
highlightCode?: boolean;
10+
/** The number of lines to show above the error. default: 2 */
11+
linesAbove?: number;
12+
/** The number of lines to show below the error. default: 3 */
13+
linesBelow?: number;
14+
/**
15+
* Forcibly syntax highlight the code as JavaScript (for non-terminals);
16+
* overrides highlightCode.
17+
* default: false
18+
*/
19+
forceColor?: boolean;
20+
/**
21+
* Pass in a string to be displayed inline (if possible) next to the
22+
* highlighted location in the code. If it can't be positioned inline,
23+
* it will be placed above the code frame.
24+
* default: nothing
25+
*/
26+
message?: string;
27+
}

src/types/eslint.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/typescript-reporter/reporter/PassiveFileSystem.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { dirname, basename, join, normalize } from 'path';
2-
import fs, { Stats, Dirent } from 'fs-extra';
2+
import fs from 'fs-extra';
33
import { fs as mem } from 'memfs';
4+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
5+
import { Stats, Dirent } from 'fs';
46

57
interface PassiveFileSystem {
68
// read

test/e2e/fixtures/type-definitions.fixture

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"tsc": "tsc"
99
},
1010
"devDependencies": {
11+
"@types/webpack": "^4.0.0",
1112
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
1213
"typescript": "~3.8.0"
1314
}
@@ -21,8 +22,8 @@
2122
"lib": ["ES6", "DOM"],
2223
"moduleResolution": "node",
2324
"esModuleInterop": true,
24-
"skipLibCheck": true,
25-
"skipDefaultLibCheck": true,
25+
"skipLibCheck": false,
26+
"skipDefaultLibCheck": false,
2627
"strict": true,
2728
"baseUrl": "./"
2829
},

test/unit/formatter/CodeframeFormatter.spec.ts renamed to test/unit/formatter/CodeFrameFormatter.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as os from 'os';
22
import mockFs from 'mock-fs';
33
import { Issue } from 'lib/issue';
4-
import { createCodeframeFormatter } from 'lib/formatter';
4+
import { createCodeFrameFormatter } from 'lib/formatter';
55

6-
describe('formatter/CodeframeFormatter', () => {
6+
describe('formatter/CodeFrameFormatter', () => {
77
beforeEach(() => {
88
mockFs({
99
src: {
@@ -128,7 +128,7 @@ describe('formatter/CodeframeFormatter', () => {
128128
],
129129
])('formats issue message "%p" to "%p"', (...args) => {
130130
const [issue, expectedFormatted] = args as [Issue, string];
131-
const formatter = createCodeframeFormatter({
131+
const formatter = createCodeFrameFormatter({
132132
linesAbove: 1,
133133
linesBelow: 1,
134134
});

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"strict": true,
1212
"declaration": true,
1313
"baseUrl": "./src",
14-
"outDir": "./lib"
14+
"outDir": "./lib",
15+
"forceConsistentCasingInFileNames": true
1516
},
1617
"include": ["./src"],
1718
"exclude": ["node_modules", "test", "lib"]

0 commit comments

Comments
 (0)