Skip to content

Commit

Permalink
Merge pull request #475 from marp-team/eslint-flat-config
Browse files Browse the repository at this point in the history
Migrate ESLint config to flat config
  • Loading branch information
yhatt authored Dec 30, 2024
2 parents ef97307 + 2d60627 commit 9e98433
Show file tree
Hide file tree
Showing 21 changed files with 550 additions and 80 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

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

This file was deleted.

3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

### Changed

- Upgrade dependent packages to the latest version ([#474](https://github.com/marp-team/marp-vscode/pull/474))
- Upgrade development Node.js and dependent packages to the latest version ([#474](https://github.com/marp-team/marp-vscode/pull/474))
- Migrate ESLint config to flat config ([#475](https://github.com/marp-team/marp-vscode/pull/475))

## v2.8.0 - 2023-10-28

Expand Down
86 changes: 86 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import js from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginImport from 'eslint-plugin-import'
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.ts',
'**/*.test.tsx',
'**/*.test.mts',
'**/*.test.cts',
'jest.setup.js',
]

const forFiles = (files, confs) => confs.map((conf) => ({ ...conf, files }))

export default tseslint.config(
js.configs.recommended,
eslintPluginImport.flatConfigs.recommended,
{
plugins: {
unicorn: eslintPluginUnicorn,
},
rules: {
'unicorn/prefer-node-protocol': 'error',
},
},
...forFiles(tsFiles, [
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
extends: [eslintPluginImport.flatConfigs.recommended],
},
{
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 } } },
]),
eslintConfigPrettier,
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
languageOptions: {
ecmaVersion: 'latest',
parserOptions: {
ecmaFeatures: { jsx: true },
},
globals: {
...globals.node,
...globals.browser,
},
},
rules: {
'import/order': ['error', { alphabetize: { order: 'asc' } }],
},
settings: {
'import/resolver': { typescript: { alwaysTryTypes: true } },
},
},
{
ignores: [
'.vscode-test-web/**/*',
'coverage/**/*',
'dist/**/*',
'lib/**/*',
'node_modules/**/*',
'preview/**/*',
],
},
)
2 changes: 1 addition & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextEncoder, TextDecoder } from 'util'
import { TextEncoder, TextDecoder } from 'node:util'

// TextEncoder and TextDecoder are exposed to global in Node.js and the browser.
// Jest VM for testing seems not to expose them to JSDOM.
Expand Down
Loading

0 comments on commit 9e98433

Please sign in to comment.