mirror of
https://github.com/ivuorinen/base-configs.git
synced 2026-01-26 11:14:00 +00:00
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:
@@ -1 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["./packages/eslint-config"]
|
|
||||||
}
|
|
||||||
2
eslint.config.mjs
Normal file
2
eslint.config.mjs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import config from './packages/eslint-config/wrapper.mjs'
|
||||||
|
export default config
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"@ivuorinen"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
9
packages/eslint-config/LICENSE.md
Normal file
9
packages/eslint-config/LICENSE.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 Ismo Vuorinen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -68,7 +68,7 @@ Distributed under the MIT License. See [LICENSE][license-link] for more informat
|
|||||||
[contributing-link]: https://github.com/ivuorinen/.github/blob/main/CONTRIBUTING.md
|
[contributing-link]: https://github.com/ivuorinen/.github/blob/main/CONTRIBUTING.md
|
||||||
[issue-link]: https://github.com/ivuorinen/base-configs/issues
|
[issue-link]: https://github.com/ivuorinen/base-configs/issues
|
||||||
[license-badge]: https://img.shields.io/github/license/ivuorinen/base-configs?style=flat-square&labelColor=292a44&color=663399
|
[license-badge]: https://img.shields.io/github/license/ivuorinen/base-configs?style=flat-square&labelColor=292a44&color=663399
|
||||||
[license-link]: ./LICENSE
|
[license-link]: ./LICENSE.md
|
||||||
[npm-badge]: https://img.shields.io/npm/v/@ivuorinen/eslint-config?style=flat-square&labelColor=292a44&color=663399
|
[npm-badge]: https://img.shields.io/npm/v/@ivuorinen/eslint-config?style=flat-square&labelColor=292a44&color=663399
|
||||||
[npm-link]: https://www.npmjs.com/package/@ivuorinen/eslint-config
|
[npm-link]: https://www.npmjs.com/package/@ivuorinen/eslint-config
|
||||||
[pull-request-link]: https://github.com/ivuorinen/base-configs/pulls
|
[pull-request-link]: https://github.com/ivuorinen/base-configs/pulls
|
||||||
|
|||||||
2
packages/eslint-config/eslint.config.mjs
Normal file
2
packages/eslint-config/eslint.config.mjs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import config from './wrapper.mjs'
|
||||||
|
export default config
|
||||||
42
packages/eslint-config/index.cjs
Normal file
42
packages/eslint-config/index.cjs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const globals = require('globals')
|
||||||
|
const pluginJs = require('@eslint/js')
|
||||||
|
const standard = require('eslint-config-standard')
|
||||||
|
const pluginN = require('eslint-plugin-n')
|
||||||
|
const pluginPromise = require('eslint-plugin-promise')
|
||||||
|
const pluginImport = require('eslint-plugin-import')
|
||||||
|
const pluginPrettier = require('eslint-plugin-prettier')
|
||||||
|
const pluginSonarJS = require('eslint-plugin-sonarjs')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type { import("eslint").Linter.Config[] } config eslint configuration.
|
||||||
|
*/
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
files: ['**/*.{js,mjs,cjs}'],
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.commonjs,
|
||||||
|
...globals.es2021,
|
||||||
|
...globals.node
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pluginJs.configs.recommended,
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
n: pluginN,
|
||||||
|
import: pluginImport,
|
||||||
|
promise: pluginPromise,
|
||||||
|
prettier: pluginPrettier,
|
||||||
|
sonarjs: pluginSonarJS
|
||||||
|
},
|
||||||
|
rules: standard.rules
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ignores: ['coverage/', 'dist/', 'lib/', 'node_modules/']
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
commonjs: true,
|
|
||||||
es2021: true,
|
|
||||||
node: true
|
|
||||||
},
|
|
||||||
extends: ['plugin:promise/recommended', 'plugin:sonarjs/recommended', 'standard', 'prettier'],
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 12
|
|
||||||
}
|
|
||||||
}
|
|
||||||
26
packages/eslint-config/jest.cjs
Normal file
26
packages/eslint-config/jest.cjs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const jest = require('eslint-plugin-jest')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eslint configuration for jest.
|
||||||
|
* @type { import('eslint').Linter.Config[] } config
|
||||||
|
*/
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
files: ['**/*.{js,mjs,cjs}'],
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...jest.globals
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
jest.configs['flat/recommended'],
|
||||||
|
jest.configs['flat/style'],
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
...jest.rules['flat/recommended'].rules
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
jest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
'jest/globals': true
|
|
||||||
},
|
|
||||||
extends: ['plugin:jest/recommended', 'plugin:jest/style', 'prettier'],
|
|
||||||
plugins: ['jest']
|
|
||||||
}
|
|
||||||
@@ -12,8 +12,24 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.cjs",
|
||||||
|
"module": "wrapper.mjs",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./wrapper.mjs",
|
||||||
|
"require": "./index.cjs"
|
||||||
|
},
|
||||||
|
"./jest": {
|
||||||
|
"import": "./wrapper-jest.mjs",
|
||||||
|
"require": "./jest.cjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.cjs",
|
||||||
|
"jest.cjs",
|
||||||
|
"wrapper.mjs",
|
||||||
|
"wrapper-jest.mjs",
|
||||||
"scripts/*"
|
"scripts/*"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/ivuorinen/base-configs/tree/main/packages/eslint-config#readme",
|
"homepage": "https://github.com/ivuorinen/base-configs/tree/main/packages/eslint-config#readme",
|
||||||
@@ -24,7 +40,6 @@
|
|||||||
"ivuorinen"
|
"ivuorinen"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -33,18 +48,20 @@
|
|||||||
"url": "https://github.com/ivuorinen/base-configs.git"
|
"url": "https://github.com/ivuorinen/base-configs.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "node scripts/postinstall.js"
|
"postinstall": "node scripts/postinstall.cjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@eslint/js": "^9.9.0",
|
||||||
"@ivuorinen/config-checker": "^1.1.4",
|
"@ivuorinen/config-checker": "^1.1.4",
|
||||||
"eslint": "9.9.0",
|
"eslint": "^9",
|
||||||
"eslint-config-prettier": "^9",
|
"eslint-config-prettier": "^9",
|
||||||
"eslint-config-standard": "^17",
|
"eslint-config-standard": "^17",
|
||||||
"eslint-plugin-import": "^2",
|
"eslint-plugin-import": "^2",
|
||||||
"eslint-plugin-jest": "^28",
|
"eslint-plugin-jest": "^28",
|
||||||
"eslint-plugin-n": "^17",
|
"eslint-plugin-n": "^17",
|
||||||
"eslint-plugin-promise": "^7.0.0",
|
"eslint-plugin-promise": "^7",
|
||||||
"eslint-plugin-sonarjs": "^1"
|
"eslint-plugin-sonarjs": "^1",
|
||||||
|
"globals": "^15.9.0"
|
||||||
},
|
},
|
||||||
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
|
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('eslint')
|
const foundConfig = checkConfig('eslint')
|
||||||
@@ -13,11 +14,21 @@ if (foundConfig.length > 0) {
|
|||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = path.join(process.env.INIT_CWD, '.eslintrc.json')
|
const filePath = path.join(process.env.INIT_CWD, 'eslint.config.mjs')
|
||||||
const fileConfigObject = {
|
const fileConfig = `import ivuorinenConfig from '@ivuorinen/eslint-config';
|
||||||
extends: ['@ivuorinen']
|
|
||||||
}
|
export default [
|
||||||
|
...ivuorinenConfig,
|
||||||
|
|
||||||
|
// your modifications
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// "no-unused-vars": "warn"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
`
|
||||||
|
|
||||||
if (!fs.existsSync(filePath)) {
|
if (!fs.existsSync(filePath)) {
|
||||||
fs.writeFileSync(filePath, JSON.stringify(fileConfigObject, undefined, 2))
|
fs.writeFileSync(filePath, fileConfig)
|
||||||
}
|
}
|
||||||
2
packages/eslint-config/wrapper-jest.mjs
Normal file
2
packages/eslint-config/wrapper-jest.mjs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import config from './jest.cjs'
|
||||||
|
export default config
|
||||||
2
packages/eslint-config/wrapper.mjs
Normal file
2
packages/eslint-config/wrapper.mjs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import config from './index.cjs'
|
||||||
|
export default config
|
||||||
Reference in New Issue
Block a user