Skip to content

Commit

Permalink
Merge pull request #19 from pixijs/feat/eslint-v9
Browse files Browse the repository at this point in the history
feat!: upgrade to eslint v9
  • Loading branch information
Zyie authored Dec 9, 2024
2 parents 2a93359 + 3802cc9 commit b616c13
Show file tree
Hide file tree
Showing 9 changed files with 1,953 additions and 1,300 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- name: Install npm
run: npm install -g npm@8
- name: Install Dependencies
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from './lib/configs/eslint.config.mjs';

export default config;
3 changes: 3 additions & 0 deletions lib/configs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '@pixi/eslint-config';

export default config;
3 changes: 0 additions & 3 deletions lib/configs/eslint.json

This file was deleted.

18 changes: 6 additions & 12 deletions lib/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,34 +122,29 @@ const fixGlobalTypes = async () =>
/** Run ESlint with built-in config */
const lint = async (additionalArgs = []) =>
{
const eslintrcJson = path.join(process.cwd(), '.eslintrc.json');
const eslintrcJs = path.join(process.cwd(), '.eslintrc.js');
const eslintrc = path.join(process.cwd(), '.eslintrc');
const eslintMJS = path.join(process.cwd(), 'eslint.config.mjs');
const eslintJS = path.join(process.cwd(), 'eslint.config.js');
const isDefined = 'eslintConfig' in packageInfo
|| await pathExists(eslintrcJson)
|| await pathExists(eslintrcJs)
|| await pathExists(eslintrc);
|| await pathExists(eslintMJS)
|| await pathExists(eslintJS);

if (!isDefined)
{
// We copy this file to the project if one doesn't exist
// because using ESLint's -c parameter turns off eslintrc
// which means that, tests, etc. won't be linted with a local .eslintrc
await promises.copyFile(path.join(__dirname, 'configs/eslint.json'), eslintrcJson);
await promises.copyFile(path.join(__dirname, 'configs/eslint.config.mjs'), eslintMJS);
}

const cleanup = async () =>
{
if (!isDefined)
{
await promises.unlink(eslintrcJson);
await promises.unlink(eslintMJS);
}
};

await spawn('eslint', [
'--ext', '.ts',
'--ext', '.js',
'--ext', '.mjs',
'--no-error-on-unmatched-pattern',
...extensionConfig.lint,
...additionalArgs,
Expand Down Expand Up @@ -320,7 +315,6 @@ const runCommand = async (command, additionalArgs) =>
}
case Command.Watch: bundle('-w'); break;
default: {
// eslint-disable-next-line no-console
console.error(chalk.red(`${prefix} Error: Unknown command "${command}". `
+ `Only the following comands are supported: "${Object.values(Command).join('", "')}"\n`));
process.exit(1);
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/pathExists.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const pathExists = async (path) =>

return true;
}
catch (e)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
catch (_e)
{
return false;
}
Expand Down
Loading

0 comments on commit b616c13

Please sign in to comment.