Skip to content

Commit a0208ba

Browse files
committed
feat: change configuration to support Node.js 6
1 parent 1d410d9 commit a0208ba

28 files changed

+283
-1245
lines changed

.eslintrc.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
extends: [
4-
'plugin:node/recommended',
5-
'plugin:@typescript-eslint/recommended',
6-
'prettier/@typescript-eslint',
7-
'plugin:prettier/recommended'
8-
],
3+
extends: ['plugin:node/recommended', 'plugin:prettier/recommended'],
94
parserOptions: {
105
ecmaVersion: 2018,
116
sourceType: 'module'
@@ -18,8 +13,19 @@ module.exports = {
1813
rules: {
1914
'no-process-exit': 'off', // to investigate if we should throw an error instead of process.exit()
2015
'node/no-unsupported-features/es-builtins': 'off',
21-
'node/no-unsupported-features/es-syntax': 'off',
22-
'@typescript-eslint/explicit-function-return-type': 'off',
23-
'@typescript-eslint/no-namespace': 'off' // maybe we should consider enabling it in the future
24-
}
16+
'node/no-unsupported-features/es-syntax': 'off'
17+
},
18+
overrides: [
19+
{
20+
files: ['*.ts'],
21+
extends: [
22+
'plugin:@typescript-eslint/recommended',
23+
'prettier/@typescript-eslint'
24+
],
25+
rules: {
26+
'@typescript-eslint/explicit-function-return-type': 'off',
27+
'@typescript-eslint/no-namespace': 'off' // maybe we should consider enabling it in the future
28+
}
29+
}
30+
]
2531
};

.github/workflows/main.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ jobs:
4343
- ubuntu-latest
4444
- macos-latest
4545
- windows-latest
46-
node:
46+
node:
47+
- '6'
4748
- '8'
4849
- '10'
4950
- '12'
5051
packages:
5152
- [email protected] ts-loader@^5.0.0 vue-loader@^15.2.4
5253
- webpack@^4.0.0 ts-loader@^5.0.0 vue-loader@^15.2.4
53-
54+
exclude:
55+
- node: '6'
56+
packages: '[email protected] ts-loader@^5.0.0 vue-loader@^15.2.4'
5457
steps:
5558
- uses: actions/checkout@v1
5659

@@ -71,10 +74,10 @@ jobs:
7174
${{ runner.os }}-node-${{ matrix.node }}-yarn-
7275
7376
- name: Install dependencies
74-
run: yarn install --frozen-lockfile
77+
run: yarn install --frozen-lockfile --ignore-engines
7578

7679
- name: Replace dependencies
77-
run: yarn add ${{ matrix.packages }} -D
80+
run: yarn add ${{ matrix.packages }} -D --ignore-engines
7881

7982
- name: Download build artifact
8083
uses: actions/download-artifact@v1

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
## Installation
1717

18-
This plugin requires minimum **webpack 4.0**, **TypeScript 2.1** and optionally **ESLint 6.0.0**
18+
This plugin requires minimum **Node.js 6.11.5**, **webpack 4**, **TypeScript 2.1** and optionally **ESLint 6** (which itself requires minimum **Node.js 8.10.0**)
1919

20-
If you depend on **webpack 2.0**, **webpack 3.0**, or **tslint 4.0**, please use [older version](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.
20+
If you depend on **webpack 2**, **webpack 3**, or **tslint 4**, please use [older version](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.
2121

2222
```sh
2323
# with npm
@@ -168,7 +168,7 @@ new ForkTsCheckerWebpackPlugin({
168168

169169
- **measureCompilationTime** `boolean`:
170170
If true, the plugin will measure the time spent inside the compilation code. This may be useful to compare modes,
171-
especially if there are other loaders/plugins involved in the compilation. **requires node 8+**
171+
especially if there are other loaders/plugins involved in the compilation. **requires Node.js >= 8.5.0**
172172

173173
- **typescript** `string`:
174174
If supplied this is a custom path where `typescript` can be found. Defaults to `require.resolve('typescript')`.

jest.config.js

Lines changed: 2 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,5 @@
1-
// For a detailed explanation regarding each configuration property, visit:
2-
// https://jestjs.io/docs/en/configuration.html
3-
4-
const path = require('path');
5-
61
module.exports = {
7-
// All imported modules in your tests should be mocked automatically
8-
// automock: false,
9-
10-
// Stop running tests after `n` failures
11-
// bail: 0,
12-
13-
// Respect "browser" field in package.json when resolving modules
14-
// browser: false,
15-
16-
// The directory where Jest should store its cached dependency information
17-
// cacheDirectory: "/tmp/jest_rs",
18-
19-
// Automatically clear mock calls and instances between every test
20-
clearMocks: true,
21-
22-
// Indicates whether the coverage information should be collected while executing the test
23-
// collectCoverage: false,
24-
25-
// An array of glob patterns indicating a set of files for which coverage information should be collected
26-
// collectCoverageFrom: null,
27-
28-
// The directory where Jest should output its coverage files
29-
coverageDirectory: 'coverage',
30-
31-
// An array of regexp pattern strings used to skip coverage collection
32-
// coveragePathIgnorePatterns: [
33-
// "/node_modules/"
34-
// ],
35-
36-
// A list of reporter names that Jest uses when writing coverage reports
37-
// coverageReporters: [
38-
// "json",
39-
// "text",
40-
// "lcov",
41-
// "clover"
42-
// ],
43-
44-
// An object that configures minimum threshold enforcement for coverage results
45-
// coverageThreshold: null,
46-
47-
// A path to a custom dependency extractor
48-
// dependencyExtractor: null,
49-
50-
// Make calling deprecated APIs throw helpful error messages
51-
// errorOnDeprecated: false,
52-
53-
// Force coverage collection from ignored files using an array of glob patterns
54-
// forceCoverageMatch: [],
55-
56-
// A path to a module which exports an async function that is triggered once before all test suites
57-
// globalSetup: null,
58-
59-
// A path to a module which exports an async function that is triggered once after all test suites
60-
// globalTeardown: null,
61-
62-
// A set of global variables that need to be available in all test environments
63-
// globals: {},
64-
65-
// An array of directory names to be searched recursively up from the requiring module's location
66-
// moduleDirectories: [
67-
// "node_modules"
68-
// ],
69-
70-
// An array of file extensions your modules use
71-
// moduleFileExtensions: [
72-
// "js",
73-
// "json",
74-
// "jsx",
75-
// "ts",
76-
// "tsx",
77-
// "node"
78-
// ],
79-
80-
// A map from regular expressions to module names that allow to stub out resources with a single module
81-
// moduleNameMapper: {},
82-
83-
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
84-
// modulePathIgnorePatterns: [],
85-
86-
// Activates notifications for test results
87-
// notify: false,
88-
89-
// An enum that specifies notification mode. Requires { notify: true }
90-
// notifyMode: "failure-change",
91-
92-
// A preset that is used as a base for Jest's configuration
93-
// preset: 'ts-jest',
94-
95-
// Run tests from one or more projects
96-
// projects: null,
97-
98-
// Use this configuration option to add custom reporters to Jest
99-
// reporters: undefined,
100-
101-
// Automatically reset mock state between every test
102-
// resetMocks: false,
103-
104-
// Reset the module registry before running each individual test
105-
// resetModules: false,
106-
107-
// A path to a custom resolver
108-
// resolver: null,
109-
110-
// Automatically restore mock state between every test
111-
// restoreMocks: false,
112-
113-
// The root directory that Jest should scan for tests and modules within
114-
// rootDir: null,
115-
116-
// A list of paths to directories that Jest should use to search for files in
117-
// roots: [
118-
// "<rootDir>"
119-
// ],
120-
121-
// Allows you to use a custom runner instead of Jest's default test runner
122-
// runner: "jest-runner",
123-
124-
// The paths to modules that run some code to configure or set up the testing environment before each test
125-
// setupFiles: [],
126-
127-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
128-
setupFilesAfterEnv: ['./test/setupTestFramework.ts'],
129-
130-
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
131-
// snapshotSerializers: [],
132-
133-
// The test environment that will be used for testing
2+
preset: 'ts-jest',
1343
testEnvironment: 'node',
135-
136-
// Options that will be passed to the testEnvironment
137-
// testEnvironmentOptions: {},
138-
139-
// Adds a location field to test results
140-
// testLocationInResults: false,
141-
142-
// The glob patterns Jest uses to detect test files
143-
// testMatch: [
144-
// "**/__tests__/**/*.[jt]s?(x)",
145-
// "**/?(*.)+(spec|test).[tj]s?(x)"
146-
// ],
147-
testMatch: ['**/?(*.)+(spec).[tj]s?(x)']
148-
149-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
150-
// testPathIgnorePatterns: [
151-
// "/node_modules/"
152-
// ],
153-
154-
// The regexp pattern or array of patterns that Jest uses to detect test files
155-
// testRegex: [],
156-
157-
// This option allows the use of a custom results processor
158-
// testResultsProcessor: null,
159-
160-
// This option allows use of a custom test runner
161-
// testRunner: "jasmine2",
162-
163-
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
164-
// testURL: "http://localhost",
165-
166-
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
167-
// timers: "real",
168-
169-
// A map from regular expressions to paths to transformers
170-
// transform: null,
171-
172-
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
173-
// transformIgnorePatterns: [
174-
// "/node_modules/"
175-
// ],
176-
177-
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
178-
// unmockedModulePathPatterns: undefined,
179-
180-
// Indicates whether each individual test should be reported during the run
181-
// verbose: null,
182-
183-
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
184-
// watchPathIgnorePatterns: [],
185-
186-
// Whether to use watchman for file crawling
187-
// watchman: true,
4+
setupFilesAfterEnv: ['./test/setup.ts']
1885
};

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,14 @@
9898
"worker-rpc": "^0.1.0"
9999
},
100100
"devDependencies": {
101-
"@babel/core": "^7.7.7",
102-
"@babel/preset-env": "^7.7.7",
103-
"@babel/preset-typescript": "^7.7.7",
104101
"@commitlint/config-conventional": "^7.5.0",
105102
"@types/babel-code-frame": "^6.20.1",
106103
"@types/eslint": "^4.16.6",
107104
"@types/jest": "^24.0.11",
108105
"@types/lodash": "^4.14.134",
109106
"@types/micromatch": "^3.1.0",
110107
"@types/minimatch": "^3.0.1",
108+
"@types/mock-fs": "^4.10.0",
111109
"@types/mock-require": "^2.0.0",
112110
"@types/node": "^11.0.0",
113111
"@types/rimraf": "^2.0.2",
@@ -124,7 +122,6 @@
124122
"eslint-plugin-prettier": "^3.1.2",
125123
"git-cz": "^3.0.1",
126124
"husky": "^1.1.4",
127-
"istanbul": "^0.4.5",
128125
"jest": "^24.7.1",
129126
"lint-staged": "^8.0.5",
130127
"lodash": "^4.17.11",
@@ -133,6 +130,7 @@
133130
"nativescript-vue-template-compiler": "^2.4.0",
134131
"prettier": "^1.14.3",
135132
"rimraf": "^3.0.0",
133+
"ts-jest": "^24.2.0",
136134
"ts-loader": "^5.0.0",
137135
"typescript": "^3.0.1",
138136
"unixify": "^1.0.0",

src/IncrementalChecker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ export class IncrementalChecker implements IncrementalCheckerInterface {
273273
});
274274

275275
// set lints in files register
276-
for (const [filePath, lint] of currentEsLintErrors) {
276+
currentEsLintErrors.forEach((lint, filePath) => {
277277
this.files.mutateData(filePath, data => {
278278
data.linted = true;
279279
data.eslints.push(lint);
280280
});
281-
}
281+
});
282282

283283
// set all files as linted
284284
this.files.keys().forEach(filePath => {

src/formatter/CodeframeFormatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { fileExistsSync } from '../FsHelper';
66
import { IssueSeverity, IssueOrigin } from '../issue';
77
import { Formatter } from './Formatter';
88
import { createInternalFormatter } from './InternalFormatter';
9-
// eslint-disable-next-line @typescript-eslint/no-var-requires
10-
const codeFrame = require('babel-code-frame');
9+
import codeFrame from 'babel-code-frame';
1110

1211
interface CodeFrameFormatterOptions {
1312
/** Syntax highlight the code as JavaScript for terminals. default: false */

src/index.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as path from 'path';
2-
import * as process from 'process';
32
import * as childProcess from 'child_process';
43
import * as webpack from 'webpack';
54
import * as ts from 'typescript';
65
import * as semver from 'semver';
7-
import * as micromatch from 'micromatch';
6+
import micromatch from 'micromatch';
87
import chalk from 'chalk';
98
import { RpcProvider } from 'worker-rpc';
109

@@ -185,7 +184,14 @@ class ForkTsCheckerWebpackPlugin {
185184

186185
this.measureTime = options.measureCompilationTime === true;
187186
if (this.measureTime) {
187+
if (semver.lt(process.version, '8.5.0')) {
188+
throw new Error(
189+
`To use 'measureCompilationTime' option, please update to Node.js >= v8.5.0 ` +
190+
`(current version is ${process.version})`
191+
);
192+
}
188193
// Node 8+ only
194+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
189195
this.performance = require('perf_hooks').performance;
190196
}
191197
}
@@ -231,11 +237,18 @@ class ForkTsCheckerWebpackPlugin {
231237
const eslintOptions =
232238
typeof options.eslintOptions === 'object' ? options.eslintOptions : {};
233239

240+
if (semver.lt(process.version, '8.10.0')) {
241+
throw new Error(
242+
`To use 'eslint' option, please update to Node.js >= v8.10.0 ` +
243+
`(current version is ${process.version})`
244+
);
245+
}
246+
234247
try {
235248
eslintVersion = require('eslint').Linter.version;
236-
} catch (_ignored) {
249+
} catch (error) {
237250
throw new Error(
238-
'When you use `eslint` option, make sure to install `eslint`.'
251+
`When you use 'eslint' option, make sure to install 'eslint'.`
239252
);
240253
}
241254

src/service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as process from 'process';
21
import * as ts from 'typescript'; // import for types alone
32

43
import { IncrementalChecker } from './IncrementalChecker';

0 commit comments

Comments
 (0)