mirror of
https://github.com/ivuorinen/base-configs.git
synced 2026-02-23 04:50:58 +00:00
feat!: ESLint 9 Fixes (#307)
* chore: update postinstall scripts * chore(lint): eslint automated fixes * feat!: drop standard, sonarjs to work with eslint9 - This config allows arrow functions. BREAKING CHANGES: - Switches to eslint-config-eslint from eslint-config-standard. - Also drops eslint-plugins-sonarjs because it doesn't work well with eslint9, and wants eslint8 and related plugins. - Switches from eslint-plugin-prettier to eslint-config-prettier.
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
// noinspection NpmUsedModulesInstalled
|
const fs = require('node:fs')
|
||||||
const process = require('process')
|
const path = require('node:path')
|
||||||
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('browserslist')
|
const foundConfig = checkConfig('browserslist')
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off", no-undefined: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
|
const fs = require('node:fs')
|
||||||
|
const path = require('node:path')
|
||||||
// noinspection NpmUsedModulesInstalled
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('commitlint')
|
const foundConfig = checkConfig('commitlint')
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
'use strict'
|
/* eslint no-console: "off" -- CLI app that gives users feedback */
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('node:path')
|
||||||
const configChecker = require('..')
|
const configChecker = require('..')
|
||||||
const assert = require('assert').strict
|
const assert = require('node:assert').strict
|
||||||
|
|
||||||
const configs = configChecker('test', path.join(__dirname, 'fixtures'))
|
const configs = configChecker('test', path.join(__dirname, 'fixtures'))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an array contains a file.
|
* Checks if an array contains a file.
|
||||||
*
|
* @param {string[]} c The array of configs to check.
|
||||||
* @param {string[]} configs - The array of configs to check.
|
* @param {string} file The file to check for.
|
||||||
* @param {string} file - The file to check for.
|
|
||||||
* @returns {boolean} - True if the array contains the file.
|
* @returns {boolean} - True if the array contains the file.
|
||||||
*/
|
*/
|
||||||
const arrayContains = (configs = [], file = '') => configs.some(config => config === file)
|
const arrayContains = (c = [], file = '') => c.includes(file)
|
||||||
|
|
||||||
assert.ok(arrayContains(configs, '.testrc'))
|
assert.ok(arrayContains(configs, '.testrc'))
|
||||||
assert.ok(arrayContains(configs, '.config/testrc.ts'))
|
assert.ok(arrayContains(configs, '.config/testrc.ts'))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict'
|
/* eslint no-console: "off" -- This is a cli app that generates cli output */
|
||||||
|
|
||||||
const configurationPaths = require('../lib/configuration-paths')
|
const configurationPaths = require('../lib/configuration-paths')
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ const mdTable = configItems.map(file => {
|
|||||||
console.log('# Configuration files\n')
|
console.log('# Configuration files\n')
|
||||||
|
|
||||||
const header = 'Searched configuration files'
|
const header = 'Searched configuration files'
|
||||||
console.log('| ' + header + ' '.repeat(longestLine - header.length) + ' |')
|
console.log(`| ${header}${' '.repeat(longestLine - header.length)} |`)
|
||||||
console.log('| ' + '-'.repeat(longestLine) + ' |')
|
console.log(`| ${'-'.repeat(longestLine)} |`)
|
||||||
|
|
||||||
mdTable.forEach(line => console.log(line))
|
mdTable.forEach(line => console.log(line))
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
'use strict'
|
/* eslint no-console: "off", n/no-process-exit: "off" -- CLI app that gives users feedback */
|
||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('node:fs')
|
||||||
const path = require('path')
|
const path = require('node:path')
|
||||||
// noinspection NpmUsedModulesInstalled
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('node:process')
|
||||||
const configurationPaths = require('./configuration-paths')
|
const configurationPaths = require('./configuration-paths')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for the existence of a configuration file.
|
* Checks for the existence of a configuration file.
|
||||||
* @param {string} moduleName - The name of the module to check for.
|
* @param {string} moduleName The name of the module to check for.
|
||||||
* @param {string} pathPrefix - The prefix to add to the path.
|
* @param {string} pathPrefix The prefix to add to the path.
|
||||||
* @returns {string[]} - The paths to the configuration files.
|
* @returns {string[]} - The paths to the configuration files.
|
||||||
*/
|
*/
|
||||||
const configChecker = (moduleName, pathPrefix = '') => {
|
const configChecker = (moduleName, pathPrefix = '') => {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
'use strict'
|
const path = require('node:path')
|
||||||
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of configuration paths.
|
* Returns an array of configuration paths.
|
||||||
* @param {string} moduleName - The name of the module to check for.
|
* @param {string} moduleName The name of the module to check for.
|
||||||
* @returns {string[]} - The paths to the configuration files.
|
* @returns {string[]} - The paths to the configuration files.
|
||||||
*/
|
*/
|
||||||
const configurationPaths = moduleName => {
|
const configurationPaths = moduleName => {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ npm install @ivuorinen/eslint-config --save-dev
|
|||||||
yarn add @ivuorinen/eslint-config --dev
|
yarn add @ivuorinen/eslint-config --dev
|
||||||
```
|
```
|
||||||
|
|
||||||
After installing it, a _`.eslintrc.json`_ file will be created automatically in the project's root folder with the following configuration:
|
After installing it, a _`eslint.config.mjs`_ file will be created automatically in the project's root folder with the following configuration:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,32 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
const globals = require('globals')
|
const globals = require('globals')
|
||||||
|
const configEslint = require('eslint-config-eslint')
|
||||||
|
const configPrettier = require('eslint-config-prettier')
|
||||||
|
const pluginImport = require('eslint-plugin-import')
|
||||||
const pluginJs = require('@eslint/js')
|
const pluginJs = require('@eslint/js')
|
||||||
const standard = require('eslint-config-standard')
|
|
||||||
const pluginN = require('eslint-plugin-n')
|
const pluginN = require('eslint-plugin-n')
|
||||||
const pluginPromise = require('eslint-plugin-promise')
|
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.
|
* @type { import("eslint").Linter.Config[] } config eslint configuration.
|
||||||
*/
|
*/
|
||||||
module.exports = [
|
module.exports = [
|
||||||
|
...configEslint,
|
||||||
|
{
|
||||||
|
linterOptions: {
|
||||||
|
reportUnusedDisableDirectives: 'warn'
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'func-style': [
|
||||||
|
'error',
|
||||||
|
'declaration',
|
||||||
|
{
|
||||||
|
allowArrowFunctions: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
files: ['**/*.{js,mjs,cjs}'],
|
files: ['**/*.{js,mjs,cjs}'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
@@ -30,12 +46,10 @@ module.exports = [
|
|||||||
plugins: {
|
plugins: {
|
||||||
n: pluginN,
|
n: pluginN,
|
||||||
import: pluginImport,
|
import: pluginImport,
|
||||||
promise: pluginPromise,
|
promise: pluginPromise
|
||||||
prettier: pluginPrettier,
|
}
|
||||||
sonarjs: pluginSonarJS
|
|
||||||
},
|
|
||||||
rules: standard.rules
|
|
||||||
},
|
},
|
||||||
|
configPrettier,
|
||||||
{
|
{
|
||||||
ignores: ['coverage/', 'dist/', 'lib/', 'node_modules/']
|
ignores: ['coverage/', 'dist/', 'lib/', 'node_modules/']
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
const jest = require('eslint-plugin-jest')
|
const jest = require('eslint-plugin-jest')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -53,15 +53,15 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/js": "^9",
|
"@eslint/js": "^9",
|
||||||
"@ivuorinen/config-checker": "^1.1.8",
|
"@ivuorinen/config-checker": "^1.1.8",
|
||||||
"eslint": "^9",
|
"eslint": "^9.15.0",
|
||||||
|
"eslint-config-eslint": "^11",
|
||||||
"eslint-config-prettier": "^9",
|
"eslint-config-prettier": "^9",
|
||||||
"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",
|
"eslint-plugin-promise": "^7",
|
||||||
"eslint-plugin-sonarjs": "^2",
|
"globals": "^15",
|
||||||
"globals": "^15"
|
"typescript": ">=4.2.0"
|
||||||
},
|
},
|
||||||
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
|
"gitHead": "23d15f15743fb59c1dbe658615ef2ed51c54d230"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
// noinspection NpmUsedModulesInstalled
|
const fs = require('node:fs')
|
||||||
const process = require('process')
|
const path = require('node:path')
|
||||||
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('eslint')
|
const foundConfig = checkConfig('eslint')
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off", no-undefined: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
|
const fs = require('node:fs')
|
||||||
|
const path = require('node:path')
|
||||||
// noinspection NpmUsedModulesInstalled
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('markdownlint')
|
const foundConfig = checkConfig('markdownlint')
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off", no-undefined: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
|
const fs = require('node:fs')
|
||||||
|
const path = require('node:path')
|
||||||
// noinspection NpmUsedModulesInstalled
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('prettier')
|
const foundConfig = checkConfig('prettier')
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off", no-undefined: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
|
const fs = require('node:fs')
|
||||||
|
const path = require('node:path')
|
||||||
// noinspection NpmUsedModulesInstalled
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('release')
|
const foundConfig = checkConfig('release')
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const fs = require('fs')
|
/* eslint no-console: "off", n/no-process-exit: "off", no-undefined: "off" -- CLI app that gives users feedback */
|
||||||
const path = require('path')
|
|
||||||
|
const fs = require('node:fs')
|
||||||
|
const path = require('node:path')
|
||||||
// noinspection NpmUsedModulesInstalled
|
// noinspection NpmUsedModulesInstalled
|
||||||
const process = require('process')
|
const process = require('node:process')
|
||||||
const checkConfig = require('@ivuorinen/config-checker')
|
const checkConfig = require('@ivuorinen/config-checker')
|
||||||
const foundConfig = checkConfig('stylelint')
|
const foundConfig = checkConfig('stylelint')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user