Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ESLint config to flat config #606

Merged
merged 2 commits into from
Oct 5, 2024
Merged
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
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

47 changes: 0 additions & 47 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Support for CSS nesting
- Upgrade development Node.js LTS to v20.17.0 ([#591](https://github.com/marp-team/marp-cli/pull/591))
- Upgrade dependent packages to the latest versions ([#591](https://github.com/marp-team/marp-cli/pull/591), [#598](https://github.com/marp-team/marp-cli/pull/598))
- Migrate ESLint config to flat config ([#606](https://github.com/marp-team/marp-cli/pull/606))

### Fixed

Expand Down
88 changes: 88 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import js from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginImportX from 'eslint-plugin-import-x'
import eslintPluginJest from 'eslint-plugin-jest'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import globals from 'globals'
import tseslint from 'typescript-eslint'

const tsFiles = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts']
const testFiles = ['test/**', 'jest.setup.js']
const forFiles = (files, confs) => confs.map((conf) => ({ ...conf, files }))

export default tseslint.config(
js.configs.recommended,
eslintPluginImportX.flatConfigs.recommended,
{
plugins: {
unicorn: eslintPluginUnicorn,
},
rules: {
'unicorn/prefer-node-protocol': 'error',
},
},
...forFiles(tsFiles, [
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
eslintPluginImportX.flatConfigs.typescript,
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'as' },
],
},
},
]),
...forFiles(testFiles, [
eslintPluginJest.configs['flat/recommended'],
eslintPluginJest.configs['flat/style'],
{
languageOptions: {
globals: { ...globals.jest },
},
rules: {
'jest/no-standalone-expect': [
'error',
{ additionalTestBlockFunctions: ['itExceptWin', 'itOnlyWin'] },
],
},
},
]),
eslintConfigPrettier,
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
languageOptions: {
ecmaVersion: 'latest',
parserOptions: {
ecmaFeatures: { jsx: true },
},
globals: {
...globals.node,
...globals.browser,
},
},
rules: {
'import-x/order': ['error', { alphabetize: { order: 'asc' } }],
},
settings: {
'import-x/resolver': 'typescript',
},
},
{
ignores: [
'bin/**/*',
'coverage/**/*',
'dist/**/*',
'lib/**/*',
'node_modules/**/*',
'tmp/**/*',
'types/**/*',
],
}
)
1 change: 0 additions & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-env jest */
jest.mock('wrap-ansi')

require('css.escape') // Polyfill for CSS.escape
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"clean": "node -e \"fs.rmSync('lib',{recursive:true,force:true})\"",
"format": "prettier \"**/*.{css,js,jsx,json,md,mjs,scss,ts,tsx,yaml,yml}\"",
"format:write": "yarn -s format --write",
"lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint --ext .js,.mjs,.jsx,.ts,.tsx --report-unused-disable-directives --cache .",
"lint:js": "eslint --cache",
"lint:css": "stylelint \"src/**/*.{css,scss}\"",
"prepack": "npm-run-all --parallel check:* lint:* test:coverage --parallel build types",
"preversion": "run-p check:* lint:* test:coverage",
Expand Down Expand Up @@ -86,6 +86,7 @@
"@types/cheerio": "^0.22.35",
"@types/debug": "^4.1.12",
"@types/dom-view-transitions": "^1.0.5",
"@types/eslint__js": "^8.42.3",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.13",
"@types/markdown-it": "^14.1.2",
Expand All @@ -95,8 +96,6 @@
"@types/which": "^3.0.4",
"@types/ws": "^8.5.12",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"@yao-pkg/pkg": "^5.15.0",
"autoprefixer": "^10.4.20",
"bespoke": "bespokejs/bespoke",
Expand All @@ -108,14 +107,14 @@
"debug": "^4.3.7",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-exports": "^1.0.0-beta.5",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import-x": "^4.3.1",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-unicorn": "^56.0.0",
"express": "^4.21.0",
"fast-plist": "^0.1.3",
"get-stdin": "^9.0.0",
"globals": "^15.10.0",
"globby": "^14.0.2",
"image-size": "^1.1.1",
"import-from": "^4.0.0",
Expand Down Expand Up @@ -152,6 +151,7 @@
"tslib": "^2.7.0",
"typed-emitter": "^2.1.0",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"vhtml": "^2.2.0",
"which": "4.0.0",
"wrap-ansi": "^9.0.0",
Expand Down
10 changes: 0 additions & 10 deletions test/.eslintrc.js

This file was deleted.

39 changes: 28 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,21 @@
resolved "https://registry.yarnpkg.com/@types/dom-view-transitions/-/dom-view-transitions-1.0.5.tgz#06070954f1ebc2f94bbea5a64618574772eb4c1d"
integrity sha512-N2sILR7fxSMnaFaAPwGj4DtHCXjIyQTHt+xJyf9jATpzUsTkMNM0DWtqZB6W7f501B/Y0tq3uqat/VlbjuTpMA==

"@types/eslint@*":
version "9.6.1"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-9.6.1.tgz#d5795ad732ce81715f27f75da913004a56751584"
integrity sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==
dependencies:
"@types/estree" "*"
"@types/json-schema" "*"

"@types/eslint__js@^8.42.3":
version "8.42.3"
resolved "https://registry.yarnpkg.com/@types/eslint__js/-/eslint__js-8.42.3.tgz#d1fa13e5c1be63a10b4e3afe992779f81c1179a0"
integrity sha512-alfG737uhmPdnvkrLdZLcEKJ/B8s9Y4hrZ+YAdzUeoArBlSUERA2E87ROfOaS4jd/C45fzOoZzidLc1IPwLqOw==
dependencies:
"@types/eslint" "*"

"@types/estree@*", "@types/[email protected]", "@types/estree@^1.0.0", "@types/estree@^1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
Expand Down Expand Up @@ -1952,7 +1967,7 @@
"@types/tough-cookie" "*"
parse5 "^7.0.0"

"@types/json-schema@^7.0.15":
"@types/json-schema@*", "@types/json-schema@^7.0.15":
version "7.0.15"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
Expand Down Expand Up @@ -2105,7 +2120,7 @@
dependencies:
"@types/node" "*"

"@typescript-eslint/eslint-plugin@^8.8.0":
"@typescript-eslint/[email protected]":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz#b2b02a5447cdc885950eb256b3b8a97b92031bd3"
integrity sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==
Expand All @@ -2120,7 +2135,7 @@
natural-compare "^1.4.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/parser@^8.8.0":
"@typescript-eslint/[email protected]":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.8.0.tgz#ee4397c70230c4eee030456924c0fba480072f5e"
integrity sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==
Expand Down Expand Up @@ -3701,13 +3716,6 @@ eslint-config-prettier@^9.1.0:
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f"
integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==

eslint-import-resolver-exports@^1.0.0-beta.5:
version "1.0.0-beta.5"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-exports/-/eslint-import-resolver-exports-1.0.0-beta.5.tgz#d603056ee168b3e84848cceef12824e470f47b31"
integrity sha512-o6t0w7muUpXr7MkUVzD5igQoDfAQvTmcPp8HEAJdNF8eOuAO+yn6I/TTyMxz9ecCwzX7e02vzlkHURoScUuidg==
dependencies:
resolve.exports "^2.0.0"

eslint-import-resolver-node@^0.3.9:
version "0.3.9"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac"
Expand Down Expand Up @@ -4410,7 +4418,7 @@ globals@^14.0.0:
resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e"
integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==

globals@^15.9.0:
globals@^15.10.0, globals@^15.9.0:
version "15.10.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-15.10.0.tgz#a7eab3886802da248ad8b6a9ccca6573ff899c9b"
integrity sha512-tqFIbz83w4Y5TCbtgjZjApohbuh7K9BxGYFm7ifwDR240tvdb7P9x+/9VvUKlmkPoiknoJtanI8UOrqxS3a7lQ==
Expand Down Expand Up @@ -8538,6 +8546,15 @@ typed-query-selector@^2.12.0:
resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.12.0.tgz#92b65dbc0a42655fccf4aeb1a08b1dddce8af5f2"
integrity sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==

typescript-eslint@^8.8.0:
version "8.8.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.8.0.tgz#93762a4cbd9d586dec0d9ab18e07dea13f497a27"
integrity sha512-BjIT/VwJ8+0rVO01ZQ2ZVnjE1svFBiRczcpr1t1Yxt7sT25VSbPfrJtDsQ8uQTy2pilX5nI9gwxhUyLULNentw==
dependencies:
"@typescript-eslint/eslint-plugin" "8.8.0"
"@typescript-eslint/parser" "8.8.0"
"@typescript-eslint/utils" "8.8.0"

typescript@^5.6.2:
version "5.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.2.tgz#d1de67b6bef77c41823f822df8f0b3bcff60a5a0"
Expand Down