feat!: upgrade to eslint 9, update configs

BREAKING CHANGE: this changes the configuration format,
also adds support for module, and commonjs types
This commit is contained in:
Ismo Vuorinen
2024-08-21 17:44:50 +03:00
parent 93ea840406
commit ad9ed820d6
15 changed files with 125 additions and 44 deletions

View File

@@ -2,6 +2,7 @@
const fs = require('fs')
const path = require('path')
// noinspection NpmUsedModulesInstalled
const process = require('process')
const checkConfig = require('@ivuorinen/config-checker')
const foundConfig = checkConfig('eslint')
@@ -13,11 +14,21 @@ if (foundConfig.length > 0) {
process.exit(0)
}
const filePath = path.join(process.env.INIT_CWD, '.eslintrc.json')
const fileConfigObject = {
extends: ['@ivuorinen']
}
const filePath = path.join(process.env.INIT_CWD, 'eslint.config.mjs')
const fileConfig = `import ivuorinenConfig from '@ivuorinen/eslint-config';
export default [
...ivuorinenConfig,
// your modifications
{
rules: {
// "no-unused-vars": "warn"
}
}
];
`
if (!fs.existsSync(filePath)) {
fs.writeFileSync(filePath, JSON.stringify(fileConfigObject, undefined, 2))
fs.writeFileSync(filePath, fileConfig)
}