Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Ezequiel Fabbroni Assum committed Nov 29, 2024
1 parent f2a455d commit c2a784f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
46 changes: 44 additions & 2 deletions configs/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,52 @@ import strict from './strict.js';
import style from './style.js';
import variables from './variables.js';

const isTSAvailable = await isPackageAvailable('typescript');
async function checkIsTSAvailable() {
try {
// Dynamically import the package
await import('typescript');
console.log(`Package typescript is available`);
return true;
} catch (error) {
console.log(error);
console.log(`Package typescript is not available`);
return false;
}
}

async function checkJestTSAvailable() {
try {
// Dynamically import the package
await import('jest');
console.log(`Package jest is available`);
return true;
} catch (error) {
console.log(error);
console.log(`Package jest is not available`);
return false;
}
}

async function checkNextJSAvailable() {
try {
// Dynamically import the package
await import('next');
console.log(`Package next is available`);
return true;
} catch (error) {
console.log(error);
console.log(`Package next is not available`);
return false;
}
}

const isTSAvailable = true;
let tsConfigs = [];
if (isTSAvailable) {
tsConfigs = await import('./ts.js');
}
const isJestAvailable = await isPackageAvailable('jest');
const isJestAvailable = await checkJestTSAvailable();
checkNextJSAvailable();

const configs = [
bestPractices,
Expand Down Expand Up @@ -54,6 +94,8 @@ const overrides = [
},
].filter(Boolean);

console.log({ tsConfigs });

export default [
...configs,
{
Expand Down
6 changes: 3 additions & 3 deletions configs/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ const tsCustomConfig = {
};

const tsLintConfig = tseslint.config(
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{ ...tsCustomConfig },
tseslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tsCustomConfig,
);

if (tsLintConfig.length) {
Expand Down

0 comments on commit c2a784f

Please sign in to comment.