mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Before migrating `eslint-config-next` project to TypeScript and Flat config, add a reliable test so that we can detect regression during the process. The patterns and utils are ported from https://github.com/vercel/next.js/blob/ad17ea67c2d4140ac2c59caeb37d1ea6d8e6ad8b/test/production/eslint/test/next-build-and-lint.test.ts, which was removed at https://github.com/vercel/next.js/pull/83136.
20 lines
727 B
TypeScript
20 lines
727 B
TypeScript
/**
|
|
* Rules being turned off (i.e. remove from snapshot) would be breaking change (requires removal of eslint-disable directive)
|
|
* Rules being added that are turned off would not be a breaking change (no eslint-disable directive required)
|
|
* Rules being added with a severity would be a breaking change (requires addition of eslint-disable directive)
|
|
*/
|
|
export function getEslintConfigSnapshot(eslintConfig: any) {
|
|
return {
|
|
...eslintConfig,
|
|
rules: Object.fromEntries(
|
|
Object.entries(eslintConfig.rules).filter(
|
|
([, config]: [ruleName: string, config: [severity: unknown]]) => {
|
|
const [severity] = config
|
|
|
|
return severity !== 0 && severity !== 'off'
|
|
}
|
|
)
|
|
),
|
|
}
|
|
}
|