Skip to content

Commit

Permalink
fix: extract typescript specific eslint default rules to an override
Browse files Browse the repository at this point in the history
- new export:
  - createPossibleTypeScriptErrorRules
  - createBestPracticesTypescriptRules
  - createVariableTypeScriptRules
  - createStylisticIssuesTypeScriptRules
  - createES6TypeScriptRules
  - eslintDefaultRulesTypeScriptOverride
- expose `files` from typescript override
- add js ts migration integration test
- add `eslintDefaultRulesTypeScriptOverride`
  • Loading branch information
ljosberinn committed Aug 7, 2022
1 parent 99785d7 commit 2170572
Show file tree
Hide file tree
Showing 37 changed files with 4,942 additions and 2,325 deletions.
1 change: 0 additions & 1 deletion __tests__/getDependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ describe('getDependencies', () => {
allowUnreachableCode: false,
allowUnusedLabels: false,
alwaysStrict: true,
checkJs: true,
declaration: true,
declarationMap: false,
esModuleInterop: true,
Expand Down
49 changes: 31 additions & 18 deletions __tests__/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jest/no-conditional-expect, import/no-dynamic-require, @typescript-eslint/no-require-imports */
import { execSync } from 'child_process';
import { readFileSync } from 'fs';
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';

type Snaphot = {
Expand Down Expand Up @@ -33,29 +33,30 @@ const variablePathDelimiter = 'eslint-config-galex';

const normalizeSnapshot = (content: string) => {
return (
content // iterate each line in results.txt
content
// iterate each line in results.txt
.split('\n')
// skip yarn start/end
.filter(
line => !line.startsWith('yarn run') && !line.startsWith('info Visit')
)
.map(line =>
// and in each line that includes a path
line.includes(variablePathDelimiter)
? line
.split(' ')
.map(word =>
// remove anything in front of the path to normalize across envs
word.includes(variablePathDelimiter)
? word.slice(word.indexOf(variablePathDelimiter) - 1)
: word
)
.join(' ')
: line
)
.map(line => {
if (!line.includes(variablePathDelimiter)) {
return line;
}

return line
.split(' ')
.map(word => {
if (!word.includes(variablePathDelimiter)) {
return word;
}

return word.slice(word.indexOf(variablePathDelimiter));
})
.join(' ');
})
.join('\n')
.replaceAll(' ', ' ')
.replaceAll('\\', '/')
);
};

Expand All @@ -68,6 +69,14 @@ const cases = [
{ name: 'create-remix typescript', path: 'remix-ts' },
{ name: 'jest', path: 'jest' },
{ name: 'nest typescript', path: 'next-ts' },
{
name: 'js ts migration mix checkJs off',
path: 'js-ts-migration-mix-checkJs-off',
},
{
name: 'js ts migration mix checkJs on',
path: 'js-ts-migration-mix-checkJs-on',
},
];

describe.each(cases)('$case.name', ({ path, name }) => {
Expand All @@ -92,6 +101,10 @@ describe.each(cases)('$case.name', ({ path, name }) => {
expect(config).toStrictEqual(updatedSnapshots.config);
expect(deps).toStrictEqual(updatedSnapshots.deps);
}
} finally {
const results = readFileSync(resolve(cwd, 'results.txt'), 'utf-8');
const normalizedResults = normalizeSnapshot(results);
writeFileSync(resolve(cwd, 'results.txt'), normalizedResults);
}
});
});
Loading

0 comments on commit 2170572

Please sign in to comment.