Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions documentation/eslint/migration.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Migrating to flat config (ESLint v9 or >=8.56.0)

🚨 As of now (February 2024) some plugins used in these rulesets are not yet compatible with ESLint v9. While it is recommended that you upgrade your projects to the flat config format it also means that if you do, you will need to stay on ESLint v8 until all plugins are updated.
These rulesets support ESLint v9 and v10 using flat config. ESLint v10 requires Node.js 20.19.0+, 22.13.0+, or 24+. The React ruleset requires Node.js 22.18.0+ because it uses Babel 8.

ESLint v10 also starts config lookup from the directory of each linted file, rather than from the current working directory.

---

As of ESLint v9 the way ESLint is configured is going to change dramatically. Support for this new "flat" config format has been introduced to ESLint v8.56 behind a feature flag (`ESLINT_USE_FLAT_CONFIG=true` env var). This guide will help you rewrite your config to the new format.

## Documentation

ESLint: https://eslint.org/docs/latest/use/configure/configuration-files-new
ESLint: https://eslint.org/docs/latest/use/configure/configuration-files

## Old way

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "8.1.2",
"lerna": "10.1.1",
"version": "independent",
"loglevel": "success",
"packages": [
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NPM_I := $(if $(CI), ci, install)

# Modify these variables in local.mk to add flags to the commands, ie.
# NPM_FLAGS += --prefer-offline
NPM_FLAGS :=
NPM_FLAGS := --legacy-peer-deps
ESLINT_FLAGS :=
REMARK_FLAGS :=

Expand Down
26,085 changes: 10,167 additions & 15,918 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"Korneliusz Dubieniecki <lekterable@gmail.com>"
],
"devDependencies": {
"@commitlint/cli": "^19",
"eslint": "^9",
"lerna": "^8.1.2",
"@commitlint/cli": "^21.2.4",
"@strv/eslint-config-node": "^5.0.0",
"eslint": "^10.13.0",
"lerna": "^10.1.1",
"remark-cli": "^12.0.0",
"remark-preset-lint-consistent": "^6",
"remark-preset-lint-markdown-style-guide": "^6",
Expand Down
4 changes: 2 additions & 2 deletions packages/commitlint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"Danny Kijkov <daniel.kijkov@strv.com>"
],
"dependencies": {
"@commitlint/config-conventional": "^19.6.0",
"@commitlint/config-lerna-scopes": "^19.7.0"
"@commitlint/config-conventional": "^21.2.4",
"@commitlint/config-lerna-scopes": "^21.2.0"
},
"engines": {
"node": ">=22"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-base/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'eslint/config'
import imports from 'eslint-plugin-import'
import imports from 'eslint-plugin-import-x'
import stylistic from '@stylistic/eslint-plugin'

/** @returns {ReturnType<typeof defineConfig>} */
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"Danny Kijkov <daniel.kijkov@strv.com>"
],
"dependencies": {
"@stylistic/eslint-plugin": "^4.2.0",
"eslint-plugin-import": "^2.31.0"
"@stylistic/eslint-plugin": "^5.10.0",
"eslint-plugin-import-x": "^4.17.1"
},
"engines": {
"node": ">=22"
Expand All @@ -30,7 +30,7 @@
"./style": "./style.mjs"
},
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config-base/style.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default defineConfig({
// Require file to end with single newline
// Benefits of trailing newlines include the ability to concatenate or append to files as well
// as output files to the terminal without interfering with shell prompts.
'@stylistic/eol-last': ['warn', 'unix'],
'@stylistic/eol-last': ['warn', 'always'],

// Enforce consistent line breaks inside function parentheses
// Requires linebreaks inside function parentheses if any of the parameters/arguments have a
Expand All @@ -120,7 +120,7 @@ export default defineConfig({
// Require or disallow spacing between function identifiers and their invocations
// This rule disallows spaces between the function name and the opening parenthesis that calls
// it.
'@stylistic/func-call-spacing': 'warn',
'@stylistic/function-call-spacing': 'warn',

// Enforce Function Style
// Due to these different behaviors, it is common to have guidelines as to which style of
Expand Down Expand Up @@ -488,7 +488,7 @@ export default defineConfig({

// Enforce Quote Style
// This rule is aimed at ensuring consistency of string quotes.
'@stylistic/quotes': ['warn', 'single', 'avoid-escape'],
'@stylistic/quotes': ['warn', 'single', { avoidEscape: true }],

// Enforce spacing between rest and spread operators and their expressions
// This rule aims to enforce consistent spacing between rest and spread operators and their
Expand Down Expand Up @@ -573,7 +573,7 @@ export default defineConfig({
yoda: 'warn',


// PLUGIN: eslint-plugin-import
// PLUGIN: eslint-plugin-import-x


// This rule either enforces or bans the use of inline type-only markers for named imports
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-config-graphql/index.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { defineConfig } from 'eslint/config'
// TODO: Deprecated. Move to https://github.com/dimaMachina/graphql-eslint
import { fixupPluginRules } from '@eslint/compat'
import graphql from 'eslint-plugin-graphql'

/** @returns {ReturnType<typeof defineConfig>} */
export default defineConfig({
name: '@strv/eslint-config-graphql',
plugins: {
graphql,
// The latest GraphQL plugin still uses removed ESLint APIs, so keep it wrapped until they migrate.
graphql: fixupPluginRules(graphql),
},
rules: {
'graphql/template-strings': ['error', {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"url": "https://github.com/strvcom/code-quality-tools/issues"
},
"dependencies": {
"@eslint/compat": "^2.1.1",
"eslint-plugin-graphql": "^4"
},
"engines": {
Expand All @@ -25,7 +26,8 @@
],
"license": "BSD-3-Clause",
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0",
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-graphql/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import graphql from '@strv/eslint-config-graphql'

/** @type {Array<import("eslint").Linter.Config>} */
const config = [{
// Perhaps also apply other configs?
{ files: ['**/*.js'], ...graphql },
files: ['**/*.js'],
extends: [graphql],
}]

export default config
Expand Down
12 changes: 4 additions & 8 deletions packages/eslint-config-mocha/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'eslint/config'
import mocha from 'eslint-plugin-mocha'
import imports from 'eslint-plugin-import'
import imports from 'eslint-plugin-import-x'

/** @returns {ReturnType<typeof defineConfig>} */
export default defineConfig({
Expand Down Expand Up @@ -37,18 +37,14 @@ export default defineConfig({
// in before or beforeEach.
'mocha/no-async-suite': 'warn',

// Disallow empty test descriptions
// This rule enforces you to specify the suite/test descriptions for each test.
'mocha/no-empty-description': 'warn',

// Disallow exclusive tests
// This rule reminds you to remove .only from your tests by raising a warning whenever you are
// using the exclusivity feature.
'mocha/no-exclusive-tests': 'warn',

// Disallow global tests
// This rule checks each mocha test function to not be located directly in the global scope.
'mocha/no-global-tests': 'warn',
'mocha/no-top-level-tests': 'warn',

// Disallow identical titles
// This rule looks at the title of every test and test suites. It will report when two test
Expand All @@ -65,7 +61,7 @@ export default defineConfig({
// specifying a callback parameter for the function. It can be confusing to have both methods
// used in a test or hook, and from Mocha v3 on, causes the test to fail in order to force
// developers to remove this source of confusion.
'mocha/no-return-and-callback': 'error',
'mocha/no-return-and-done': 'error',

// Disallow returning from an async test or hook
// Mocha's tests or hooks (like before) may be asynchronous by returning a Promise. When such
Expand All @@ -77,7 +73,7 @@ export default defineConfig({
// Any setup directly in a describe is run before all tests execute. This rule reports all
// function calls and use of the dot operator (due to getters and setters) directly in
// describe blocks.
'mocha/no-setup-in-describe': 'warn',
'mocha/no-setup-in-suite': 'warn',

// Do not require test files to have exports or to be imported from somewhere inside the
// project. Test files are usually sourced by Mocha directly.
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config-mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
],
"dependencies": {
"@strv/eslint-config-base": "^5.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-mocha": "^11.0.0"
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-mocha": "^12.0.2"
},
"engines": {
"node": ">=22"
Expand All @@ -30,7 +30,7 @@
],
"license": "BSD-3-Clause",
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"dependencies": {
"@strv/eslint-config-base": "^5.0.0",
"eslint-plugin-n": "^17.18.0"
"eslint-plugin-n": "^18.5.0"
},
"engines": {
"node": ">=22"
Expand All @@ -32,7 +32,7 @@
"./style": "./style.mjs"
},
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
17 changes: 16 additions & 1 deletion packages/eslint-config-react-native/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import typeScriptConfig from '@strv/eslint-config-typescript'
import expoConfig from 'eslint-config-expo/flat.js'
import { fixupPluginRules } from '@eslint/compat'
import { defineConfig, globalIgnores } from 'eslint/config'

const compatibleExpoConfig = expoConfig.map(config => {
if (!config.plugins?.react) {
return config
}

return {
...config,
plugins: {
...config.plugins,
react: fixupPluginRules(config.plugins.react),
},
}
})

/** Globally ignored */
const ignores = globalIgnores(['.expo/', 'expo-env.d.ts'])

Expand Down Expand Up @@ -91,4 +106,4 @@ const typescript = defineConfig([
},
])

export default defineConfig([expoConfig, ignores, common, typescript, react])
export default defineConfig([compatibleExpoConfig, ignores, common, typescript, react])
5 changes: 3 additions & 2 deletions packages/eslint-config-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
"main": "index.mjs",
"type": "module",
"dependencies": {
"@eslint/compat": "^2.1.1",
"@strv/eslint-config-typescript": "^6.0.0",
"eslint-config-expo": "^10.0.0"
"eslint-config-expo": "^58.0.4"
},
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-config-react/index.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fixupPluginRules } from '@eslint/compat'
import { defineConfig } from 'eslint/config'
import parser from '@babel/eslint-parser'
import base from '@strv/eslint-config-base'
Expand All @@ -12,8 +13,8 @@ export default defineConfig({
base,
],
plugins: {
react,
'jsx-a11y': a11y,
react: fixupPluginRules(react),
'jsx-a11y': fixupPluginRules(a11y),
'react-hooks': hooks,
},
languageOptions: {
Expand Down
15 changes: 8 additions & 7 deletions packages/eslint-config-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"Danny Kijkov <daniel.kijkov@strv.com>"
],
"dependencies": {
"@babel/core": "^7.23.9",
"@babel/eslint-parser": "^7.23.10",
"@eslint/compat": "^2.1.1",
"@babel/core": "^8.0.7",
"@babel/eslint-parser": "^8.0.7",
"@strv/eslint-config-base": "^5.0.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.23.0",
"eslint-plugin-react-hooks": "^5.0.0"
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.1.1"
},
"engines": {
"node": ">=22"
"node": ">=22.18.0"
},
"exports": {
".": "./index.mjs",
Expand All @@ -35,7 +36,7 @@
],
"license": "BSD-3-Clause",
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config-react/style.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fixupPluginRules } from '@eslint/compat'
import { defineConfig } from 'eslint/config'
import style from '@strv/eslint-config-base/style'
import react from 'eslint-plugin-react'
Expand All @@ -9,7 +10,7 @@ export default defineConfig({
style,
],
plugins: {
react,
react: fixupPluginRules(react),
},
rules: {
// Enforce consistent usage of destructuring assignment of props, state, and context
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
],
"dependencies": {
"@strv/eslint-config-base": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint-import-resolver-typescript": "^4.3.5"
"@typescript-eslint/eslint-plugin": "^8.72.0",
"@typescript-eslint/parser": "^8.72.0",
"eslint-import-resolver-typescript": "^4.4.5"
},
"engines": {
"node": ">=22"
Expand All @@ -34,7 +34,7 @@
],
"license": "BSD-3-Clause",
"peerDependencies": {
"eslint": "^9"
"eslint": "^9.0.0 || ^10.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/remark-config/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
'preset-lint-consistent',
'preset-lint-markdown-style-guide',

['lint-list-item-indent', 'space'],
['lint-list-item-indent', 'one'],
['lint-maximum-line-length', Infinity],
['lint-emphasis-marker', '_'],
['lint-table-pipe-alignment', false],
Expand Down
Loading
Loading