Last active
January 26, 2024 09:37
-
-
Save baliyan9887/205ce3c12561f3ce46c90d955b94a1a7 to your computer and use it in GitHub Desktop.
This configuration file is designed to enhance the development experience in a JavaScript project. It leverages JavaScript Compiler Options for better code organization, readability, and maintainability.
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
{ | |
// JavaScript compiler options | |
"compilerOptions": { | |
// Set the base URL for all relative module imports. | |
// This helps in having cleaner and shorter import paths. | |
"baseUrl": ".", | |
// Define path aliases for commonly used directories. | |
// This improves the readability of import statements. | |
"paths": { | |
"@src/*": ["src/*"], | |
"@components/*": ["src/components/*"], | |
"@utils/*": ["src/utils/*"], | |
"@services/*": ["src/services/*"], | |
"@styles/*": ["src/styles/*"], | |
"@assets/*": ["src/assets/*"] | |
}, | |
// Enable ES module interoperability. | |
// This allows compatibility between CommonJS and ES module systems. | |
"esModuleInterop": true, | |
// Specify JSX as the target language. | |
// This is essential for working with React components. | |
"jsx": "react", | |
// Specify the module system for the emitted code. | |
// ESNext is a good choice for modern JavaScript applications. | |
"module": "esnext", | |
// Set the ECMAScript version to target. | |
// ESNext allows you to use the latest ECMAScript features. | |
"target": "esnext", | |
// Allow synthetic default imports from modules with no default export. | |
// This simplifies the import syntax for modules without default exports. | |
"allowSyntheticDefaultImports": true, | |
// Skip type checking of declaration files. | |
// Useful for improving build performance. | |
"skipLibCheck": true, | |
// Force consistent casing in file names. | |
// This helps avoid potential issues on case-sensitive file systems. | |
"forceConsistentCasingInFileNames": true | |
}, | |
// Exclude specified files and directories from JavaScript compilation. | |
// This ensures that certain directories are not processed by the TypeScript compiler. | |
"exclude": ["node_modules", "build", "dist", "coverage"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Now that you have set up the
jsconfig.json
file, you can leverage path aliases in your project for cleaner and more maintainable imports. Here's an example:Before:
After:
By using path aliases, you simplify your import statements, making your codebase more readable and easier to maintain.