Skip to content

Commit

Permalink
Merge pull request #217 from gjsify/upgrade-eslint
Browse files Browse the repository at this point in the history
Upgrade ESLint 8 to 9
  • Loading branch information
JumpLink authored Nov 9, 2024
2 parents 0af4133 + 684a342 commit 9bb612d
Show file tree
Hide file tree
Showing 64 changed files with 979 additions and 935 deletions.
14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

30 changes: 0 additions & 30 deletions .eslintrc.json

This file was deleted.

12 changes: 11 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
@types/
node_modules/
lib/
tmp/
test/
templates/
examples/
@types/
*.js
*.cjs
*/*.js
*/*.cjs
64 changes: 64 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import eslint from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
import prettier from 'eslint-config-prettier';

export default [
// Base config for all files
{
ignores: [
'**/node_modules/**',
'**/cli/lib/**',
'**/generator-base/lib/**',
'**/generator-html-doc/lib/**',
'**/lib/lib/**',
'**/generator-typescript/lib/**',
'**/parser/lib/**',
'**/tmp/**',
'**/dist/**',
'**/test/**',
'**/templates/**',
'**/examples/**',
'**/@types/**',
'**/*.js',
'**/*.cjs',
]
},

// TypeScript files
{
files: ['**/*.ts'], // Explicitly specify files to lint
languageOptions: {
parser: tsparser,
parserOptions: {
project: ['./packages/*/tsconfig.json'],
},
globals: {
imports: true
}
},
plugins: {
'@typescript-eslint': tseslint
},
rules: {
'semi': ['error', 'never'],
'quotes': ['error', 'single'],
'no-debugger': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'camelcase': 'off',
'@typescript-eslint/camelcase': 'off'
}
},

// Special rules for .d.ts files
{
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
},

prettier
];
2 changes: 1 addition & 1 deletion examples/gtk-3-hello/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.3.0",
"rollup": "^4.24.3",
"rollup": "^4.24.4",
"typescript": "^5.6.3"
},
"dependencies": {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
"type definitions"
],
"devDependencies": {
"@eslint/js": "^9.14.0",
"@ts-for-gir/cli": "workspace:^",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"concurrently": "^9.0.1",
"eslint": "^8.57.1",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"concurrently": "^9.1.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3",
Expand Down
16 changes: 0 additions & 16 deletions packages/cli/.eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions packages/cli/.eslintrc.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/cli/.prettierrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"clear": "yarn clear:build",
"clear:build": "rimraf ./lib",
"watch": "yarn build:ts --watch",
"lint": "eslint . --ext .ts,.tsx --fix"
"lint": "eslint . --fix"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -54,11 +54,11 @@
],
"devDependencies": {
"@types/inquirer": "^9.0.7",
"@types/node": "^22.8.6",
"@types/node": "^22.9.0",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"eslint": "^8.57.1",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"rimraf": "^6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const command = 'copy [modules..]'

const description = 'Scan for *.gir files and copy them to a new directory'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
const optionNames = Object.keys(Config.copyOptions)
for (const optionName of optionNames) {
Expand Down Expand Up @@ -43,7 +43,7 @@ const copyGirFile = async (config: UserConfig, depModule: GirModuleResolvedBy) =
await copyFile(depModule.path, dest)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handler = async (args: ConfigFlags) => {
const config = await Config.load(args)
const generateConfig = Config.getOptionsGeneration(config)
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const command = 'doc [modules..]'

const description = 'The HTML documentation generator is not yet implemented, but feel free to implement it 🤗'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
const optionNames = Object.keys(Config.docOptions)
for (const optionName of optionNames) {
Expand All @@ -24,7 +24,7 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
return yargs.example(examples) as Argv<ConfigFlags>
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handler = async (args: ConfigFlags) => {
const config = await Config.load(args)

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const command = 'generate [modules..]'

const description = 'Generates Typescript type definition .d.ts files from GIR for GJS'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
const optionNames = Object.keys(Config.generateOptions)
for (const optionName of optionNames) {
Expand All @@ -26,7 +26,7 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
return yargs.example(examples) as Argv<ConfigFlags>
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handler = async (args: ConfigFlags) => {
const config = await Config.load(args)

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const command = 'list [modules..]'

const description = 'Lists all available GIR modules'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
const optionNames = Object.keys(Config.listOptions)
for (const optionName of optionNames) {
Expand All @@ -22,7 +22,7 @@ const builder: BuilderCallback<any, ConfigFlags> = (yargs: Argv<any>) => {
return yargs.example(examples) as Argv<ConfigFlags>
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handler = async (args: ConfigFlags) => {
const config = await Config.load(args)
const generateConfig = Config.getOptionsGeneration(config)
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/**
* Default values, parse the config file and handle CLI flags
*/
Expand Down Expand Up @@ -261,7 +261,7 @@ export class Config {
loaders: {
// ESM loader
'.js': async (filepath) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const file = await import(filepath)

// Files with `exports.default = { ... }`
Expand Down
16 changes: 0 additions & 16 deletions packages/generator-base/.eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions packages/generator-base/.eslintrc.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/generator-base/.prettierrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions packages/generator-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clear": "yarn clear:build",
"clear:build": "rimraf ./lib",
"watch": "yarn build:ts --watch",
"lint": "eslint . --ext .ts,.tsx --fix"
"lint": "eslint . --fix"
},
"repository": {
"type": "git",
Expand All @@ -34,10 +34,10 @@
"generator"
],
"devDependencies": {
"@types/node": "^22.8.6",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"eslint": "^8.57.1",
"@types/node": "^22.9.0",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3",
Expand Down
Loading

0 comments on commit 9bb612d

Please sign in to comment.