-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eslint Plugin: Add TypeScript as peer dependency and make it optional (…
…#29942) * Add explicit dependency on TypeScript * Move typescript to a peer dependency * Run TypeScript validation only when it is installed * ESLint Pluging: Add the changelog entry * Clarify the TS integration in the README file * Mark typescript as an optional peer dependency Co-authored-by: Grzegorz Ziolkowski <[email protected]>
- Loading branch information
1 parent
cdeaf87
commit f790903
Showing
7 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Checks whether the passed package name is installed in the project. | ||
* | ||
* @param {string} packageName The name of npm package. | ||
* @return {boolean} Returns true when the package is installed or false otherwise. | ||
*/ | ||
const isPackageInstalled = ( packageName ) => { | ||
try { | ||
if ( require.resolve( packageName ) ) { | ||
return true; | ||
} | ||
} catch ( error ) {} | ||
return false; | ||
}; | ||
|
||
module.exports = isPackageInstalled; |
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,18 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import isPackageInstalled from '../is-package-installed'; | ||
|
||
describe( 'isPackageInstalled', () => { | ||
test( 'returns false when package not installed', () => { | ||
const result = isPackageInstalled( 'nonexistent-package-name' ); | ||
|
||
expect( result ).toBe( false ); | ||
} ); | ||
|
||
test( 'returns true when package installed', () => { | ||
const result = isPackageInstalled( 'eslint' ); | ||
|
||
expect( result ).toBe( true ); | ||
} ); | ||
} ); |