-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add/skip-interface-or-type
- Loading branch information
Showing
18 changed files
with
227 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"description": "Example used by integration tests (ispec)", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pzavolinsky/ts-unused-exports.git" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsc -p ./tsconfig.json", | ||
"test": "npm i && npm run build && npm run test:test", | ||
"test:test": "../../bin/ts-unused-exports ./tsconfig.json" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.6.4" | ||
}, | ||
"devDependencies": {} | ||
} |
5 changes: 5 additions & 0 deletions
5
example/absolute-paths-2-tsconfigs/project/project-1/src/app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { MyComponent1 } from 'components/MyComponent'; | ||
|
||
const comp1: MyComponent1 = new MyComponent1(); | ||
|
||
export class UnusedComponent {} |
7 changes: 7 additions & 0 deletions
7
example/absolute-paths-2-tsconfigs/project/project-1/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src"], | ||
"compilerOptions": { | ||
"baseUrl": "src" | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
example/absolute-paths-2-tsconfigs/src/config/components/MyComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export class MyComponent1 {} | ||
export class UnusedComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"baseDir": ".", | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "src/config", | ||
"lib": ["es6", "es2017", "dom"], | ||
"strict": true, | ||
"noEmit": true, | ||
"resolveJsonModule": true, | ||
"downlevelIteration": true, | ||
"module": "commonjs", | ||
"types": ["node"], | ||
"jsx": "react", | ||
"target": "es5", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "absolute-paths-simple", | ||
"version": "1.0.0", | ||
"description": "Test harness", | ||
"main": "main.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "npm i && npm run build && ../../bin/ts-unused-exports ./tsconfig.json --ignorePaths=to-ignore" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.7.4" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class MyComponent1 {} |
1 change: 1 addition & 0 deletions
1
example/absolute-paths-simple/src/components/UnusedComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class UnusedComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { MyComponent1 } from 'components/MyComponent'; | ||
|
||
export class UnusedClassFromMain {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"baseDir": ".", | ||
"compilerOptions": { | ||
"baseUrl": "src" | ||
}, | ||
"include": ["./src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Feature: absolute-paths without paths set in tsconfig | ||
|
||
Background: | ||
Given file "tsconfig.json" is | ||
""" | ||
{ | ||
"baseDir": ".", | ||
"compilerOptions": { | ||
"baseUrl": "src" | ||
}, | ||
"include": [ | ||
"./src" | ||
] | ||
} | ||
""" | ||
|
||
Scenario: Import component using absolute path | ||
Given file "./src/components/MyComponent.ts" is | ||
""" | ||
export class MyComponent1 {}; | ||
export class UnusedComponent {}; | ||
""" | ||
And file "src/b.ts" is | ||
""" | ||
import {MyComponent1} from "components/MyComponent"; | ||
""" | ||
When analyzing "tsconfig.json" | ||
Then the result is { "src/components/MyComponent.ts": ["UnusedComponent"] } | ||
|
||
Scenario: Import component using absolute path, from sub-folder | ||
Given file "./src/components/MyComponent.ts" is | ||
""" | ||
export class MyComponent1 {}; | ||
export class UnusedComponent {}; | ||
""" | ||
And file "src/subFolder/b.ts" is | ||
""" | ||
import {MyComponent1} from "components/MyComponent"; | ||
""" | ||
When analyzing "tsconfig.json" | ||
Then the result is { "src/components/MyComponent.ts": ["UnusedComponent"] } | ||
|
||
Scenario: Import function using absolute path | ||
Given file "src/helpers/form/myFunctions.ts" is | ||
""" | ||
export function doSomething({isTheFieldRequired} = defaultRequiredParam) {} | ||
export function unusedDoSomething() {} | ||
""" | ||
And file "src/b.ts" is | ||
""" | ||
import { doSomething } from "helpers/form/myFunctions"; | ||
""" | ||
When analyzing "tsconfig.json" | ||
Then the result is { "src/helpers/form/myFunctions.ts": ["unusedDoSomething"] } | ||
|
||
# TODO xxx test namespace using absolute path - search ON | ||
# When analyzing "tsconfig.json" with files ["--searchNamespaces"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Feature: import alias | ||
|
||
Scenario: One unused export const | ||
Given file "a.ts" is | ||
""" | ||
export const a = 1; | ||
export const unused_a = 1; | ||
""" | ||
And file "b.ts" is import { a as a1 } from './a'; | ||
When analyzing "tsconfig.json" | ||
Then the result at a.ts is ["unused_a"] | ||
|
||
Scenario: Used export default - import * as x | ||
Given file "a.ts" is export default 1; | ||
And file "b.ts" is import * as ax from './a'; | ||
When analyzing "tsconfig.json" | ||
Then the result at a.ts is ["default"] | ||
# see star.feature - Import * marks 'default' as unused | ||
|
||
Scenario: Used export default - import x | ||
Given file "a.ts" is export default 1; | ||
And file "b.ts" is import x from './a'; | ||
When analyzing "tsconfig.json" | ||
Then the result is {} | ||
|
||
Scenario: Export { symbol as x } from | ||
Given file "a.ts" is export const a = 1; | ||
And file "b.ts" is export { a as a1 } from './a'; | ||
And file "c.ts" is import { a1 as a2 } from './b'; | ||
When analyzing "tsconfig.json" | ||
Then the result is {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters