Skip to content

Commit f307cf8

Browse files
committed
strict-plugin | CR fixes
1 parent 46c2796 commit f307cf8

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Jarosław Glegoła Kamil Krysiak
3+
Copyright (c) 2021 Jarosław Glegoła Kamil Krysiak
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

e2e/fixtures/lang-server.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ class TSServer {
99
this._responseCommandEmitter = new EventEmitter();
1010
const tsserverPath = require.resolve('typescript/lib/tsserver');
1111

12-
// to open ts log from tests
13-
// process.env['TSS_LOG'] =
14-
// '-logToFile true -file /Users/jaroslaw.glegola/Documents/Praca/typescript-strict-plugin/log1.txt -level
15-
// verbose';
12+
// to create ts log from tests
13+
// process.env['TSS_LOG'] = '-logToFile true -file /path/typescript-strict-plugin/log1.txt -level verbose';
1614
const server = fork(tsserverPath, {
1715
cwd: path.join(__dirname, '../project-fixture/src'),
1816
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],

package-lock.json

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "typescript-strict-plugin",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.0.0-beta.2",
44
"description": "https://github.com/Microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin",
55
"main": "dist/index.js",
66
"private": false,
7+
"files": [
8+
"dist"
9+
],
710
"scripts": {
811
"test": "npm run e2e",
912
"build": "tsc",
@@ -20,9 +23,6 @@
2023
],
2124
"author": "Sebastián Gurin",
2225
"license": "MIT",
23-
"dependencies": {
24-
"typescript": "4.1.3"
25-
},
2626
"devDependencies": {
2727
"@types/node": "^14.14.35",
2828
"@typescript-eslint/eslint-plugin": "^4.18.0",
@@ -32,7 +32,8 @@
3232
"glob": "^7.1.6",
3333
"husky": "4.3.8",
3434
"lint-staged": "^10.5.4",
35-
"prettier": "^2.2.1"
35+
"prettier": "^2.2.1",
36+
"typescript": "4.1.3"
3637
},
3738
"lint-staged": {
3839
"*.(js|ts)": [

sample-project/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "sample-ts-plugin1-sample-project",
3-
"version": "1.0.4",
2+
"name": "sample-project",
3+
"version": "1.0.0",
44
"description": "https://github.com/Microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin",
55
"main": "index.js",
66
"private": true,

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { PluginInfo, setupProxy, turnOffStrictMode, turnOnStrictMode } from './utils';
1+
import { PluginInfo, setupProxy, turnOffStrictMode, turnOnStrictMode, log } from './utils';
22
import { StrictFileChecker } from './strictFiles';
33

44
const init: ts.server.PluginModuleFactory = () => {
55
function create(info: PluginInfo) {
66
const proxy = setupProxy(info);
7+
log(info, 'Plugin initialized');
78

89
proxy.getSemanticDiagnostics = function (fileName) {
910
const strictFile = new StrictFileChecker(info).isFileStrict(fileName);

src/strictFiles.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export class StrictFileChecker {
1111
}
1212

1313
public isFileStrict(filePath: string): boolean {
14-
const { paths: pathsToTurnOnStrictMode } = this.info.config as Config;
14+
const { paths: pathsToTurnOnStrictMode = [] } = this.info.config as Config;
1515

1616
if (this.isTsStrictCommentPresent(filePath)) {
1717
return true;
1818
}
1919

20-
return !!pathsToTurnOnStrictMode?.some((strictPath) => this.isFileOnPath(filePath, strictPath));
20+
return pathsToTurnOnStrictMode.some((strictPath) => this.isFileOnPath(filePath, strictPath));
2121
}
2222

2323
private isFileOnPath(currentFilePath: string, pathToStrictFiles: string) {

0 commit comments

Comments
 (0)