Skip to content

Upgrade to eslint9 #17

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

Merged
merged 5 commits into from
Sep 22, 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
12 changes: 0 additions & 12 deletions .eslintignore

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ coverage/
report/
!*.js
!*.ts
!*.mjs
!*.cjs
!*.mts
!*.cts
!.vscode/*.json
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"visualstudioexptteam.vscodeintellicode",
"pmneo.tsimporter",
"orta.vscode-jest",
"meganrogge.template-string-converter",
"simonsiefke.svg-preview",
"yoavbls.pretty-ts-errors",
"csstools.postcss",
],
}
70 changes: 47 additions & 23 deletions eslint.config.js → eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const js = require('@eslint/js');
const tseslint = require('typescript-eslint');
const eslintConfigPrettier = require('eslint-config-prettier');
const tsParser = require('@typescript-eslint/parser');
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import tsParser from '@typescript-eslint/parser';
// When it works again do `npm install --save-dev eslint-plugin-import`
// const imprt = require('eslint-plugin-import');
// import imprt from 'eslint-plugin-import';
// https://github.com/eslint/eslint/issues/18087
// https://github.com/import-js/eslint-plugin-import/pull/2829
const globals = require('globals');
const jest = require('eslint-plugin-jest');
import globals from 'globals';
import jest from 'eslint-plugin-jest';

const off = 'off';
const warn = 'warn';
Expand All @@ -32,8 +32,33 @@ const any_rules = (level) => {
'@typescript-eslint/no-explicit-any': level,
};
};

module.exports = [
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
export default [
{
ignores: [
'lib/',
'build/',
'build-*/',
'dist/',
'.vscode/',
'node_modules/',
'coverage/',
'report/',
'!*.js',
'!*.mjs',
'!*.cjs',
'!*.ts',
'!.vscode/*.json',
'package-lock.json',
'**/node_modules',
'**/dist',
'**/build',
'**/__snapshots__',
'**/mocks',
'**/coverage',
'**/report',
],
},
js.configs.recommended,
tseslint.configs.eslintRecommended,
...tseslint.configs.recommended,
Expand All @@ -45,26 +70,15 @@ module.exports = [
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
tsconfigRootDir: __dirname,
tsconfigRootDir: import.meta.dirname,
project: [
'./tsconfig.eslint.json',
'./tsconfig.json',
'/tsconfig.prod.json',
'./tsconfig.prod.json',
],
},
},
},
{
ignores: [
'**/node_modules',
'**/dist',
'**/build',
'**/__snapshots__',
'**/mocks',
'**/coverage',
'**/report',
],
},
// Disables all styling from eslint
eslintConfigPrettier,
{
Expand Down Expand Up @@ -119,14 +133,24 @@ module.exports = [
},
},
{
files: ['.*.js', '.*.cjs', '*.config.cjs', '*.config.js', '*.config.ts'],
name: 'linting for configuration files',
files: [
'.*.js',
'.*.mjs',
'.*.cjs',
'*.config.mjs',
'*.config.cjs',
'*.config.js',
'*.config.ts',
],
rules: {
'no-restricted-imports': off,
// Consider if this is too leanient for tests
...any_rules('off'),
},
},
{
name: 'Rules for tests with jest',
files: [
'**/*.test.js',
'**/*.spec.js',
Expand Down
Loading
Loading