Skip to content

Commit

Permalink
Switch to ESLint Flat Config (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Nov 12, 2023
1 parent 6bea504 commit a441b57
Show file tree
Hide file tree
Showing 44 changed files with 700 additions and 1,541 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc.cjs

This file was deleted.

4 changes: 0 additions & 4 deletions __tests__/.eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions __tests__/.eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions __tests__/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'eslint-config-upleveled';
3 changes: 2 additions & 1 deletion __tests__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"Karl Horky <karl.horky@gmail.com>",
"Jose Höwer <josehower@gmail.com>"
],
"type": "module",
"main": "index.js",
"scripts": {
"update-config-version": "pnpm add --save-dev eslint-config-upleveled@latest && pnpm upleveled-eslint-install"
Expand All @@ -18,7 +19,7 @@
"devDependencies": {
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"eslint-config-upleveled": "^6.1.2",
"eslint-config-upleveled": "^7.0.0-1",
"postcss-styled-syntax": "^0.5.0",
"stylelint": "^15.9.0",
"stylelint-config-upleveled": "^1.0.2",
Expand Down
304 changes: 151 additions & 153 deletions __tests__/pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion __tests__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
]
},
"include": [
"**/.eslintrc.cjs",
"**/*.ts",
"**/*.tsx",
"**/*.js",
Expand Down
23 changes: 18 additions & 5 deletions bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import {
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const projectPackageJsonPath = join(process.cwd(), 'package.json');
const projectPackageJson = JSON.parse(
readFileSync(join(process.cwd(), 'package.json'), 'utf-8'),
readFileSync(projectPackageJsonPath, 'utf-8'),
);

const projectDependencies = projectPackageJson.dependencies || {};
Expand Down Expand Up @@ -45,10 +46,22 @@ console.log(`Detected project type: ${projectTypeTitle}`);
// }
// }
//
// writeFileSync(
// projectPackageJsonPath,
// JSON.stringify(projectPackageJson, null, 2) + '\n',
// );

// Set "type": "module" in package.json for support
// of ESM syntax in eslint.config.js
//
// ESLint does not support other ways of specifying
// that the config file is ESM such as an .mjs extension:
// https://github.com/eslint/eslint/issues/13440
// https://github.com/eslint/eslint/issues/16580
if (projectPackageJson.type !== 'module') {
projectPackageJson.type = 'module';

writeFileSync(
projectPackageJsonPath,
JSON.stringify(projectPackageJson, null, 2) + '\n',
);
}

const newDevDependenciesToInstall = [
// pnpm v8+ automatically installs peer dependencies (auto-install-peers=true
Expand Down
11 changes: 11 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import upleveled from './index.js';

/** @type {import('eslint').Linter.FlatConfig[]} */
const config = [
...upleveled,
{
ignores: ['__tests__/**/*'],
},
];

export default config;

0 comments on commit a441b57

Please sign in to comment.