Skip to content

Commit

Permalink
chore: move to the new config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuditi committed May 20, 2024
1 parent 948aca1 commit 4b2012f
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 73 deletions.
24 changes: 0 additions & 24 deletions .eslintignore

This file was deleted.

138 changes: 89 additions & 49 deletions .eslintrc.js → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
const parserOptions = {
ecmaVersion: 6,
sourceType: 'module',
}
const globals = require('globals')
const jsEslint = require('@eslint/js')
const securityPlugin = require('eslint-plugin-security')
const sveltePlugin = require('eslint-plugin-svelte')
const babelParser = require('@babel/eslint-parser')
const tsEslint = require('typescript-eslint')
// const tsParser = require('@typescript-eslint/parser')
const svelteParser = require('svelte-eslint-parser')

const eslintRules = {
'arrow-body-style': 'off', // OFF b/c blocks style allows for readability and ensure scope
'arrow-spacing': 'error',
'eol-last': 'error',
'eqeqeq': 'error',
eqeqeq: 'error',
'func-call-spacing': 'error',
'indent': 'off', // OFF b/c causes problems between Prettier and ESLint
indent: 'off', // OFF b/c causes problems between Prettier and ESLint
'linebreak-style': 'off', // OFF b/c Windows (Git) puts CRLF line endings
'missing-declaration': 'off', // OFF b/c throws errors on imports / require statements
'multiline-ternary': 'off', // OFF b/c causes problems between Prettier and ESLint
Expand Down Expand Up @@ -39,14 +43,14 @@ const eslintRules = {
'prefer-arrow-callback': 'warn',
'prefer-const': 'warn',
'prefer-destructuring': 'off', // OFF b/c it's not really correct
'quotes': ['error', 'single'],
'semi': 'off', // OFF b/c we aren't using semicolons
quotes: ['error', 'single'],
semi: 'off', // OFF b/c we aren't using semicolons
'space-before-function-paren': 'off', // OFF b/c we aren't using spaces before function parameters / signatures
'spaced-comment': 'error',
}

const eslintRulesOnlyTypescript = {
'no-undef': 'off' // Typescript handles undefined variables better than eslint
'no-undef': 'off', // Typescript handles undefined variables better than eslint
}

const typescriptEslintRules = {
Expand Down Expand Up @@ -104,51 +108,87 @@ const svelteSettings = {
'svelte/ignore-warnings': () => false,
}

module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:svelte/recommended'],
overrides: [
{
files: ['**/*.ts', '**/*.svelte'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parser: '@typescript-eslint/parser',
const parserOptions = {
ecmaVersion: 2021,
sourceType: 'module',
}

module.exports = [
jsEslint.configs.recommended,
securityPlugin.configs.recommended,
...sveltePlugin.configs['flat/recommended'],
{
languageOptions: {
parserOptions: {
...parserOptions,
extraFileExtensions: ['.svelte'],
project: './tsconfig.lint.json',
tsconfigRootDir: './',
requireConfigFile: false,
},
parser: babelParser,
globals: {
...globals.browser,
...globals.node,
...globals.es2021,
},
plugins: ['@typescript-eslint'],
rules: linterRules,
settings: svelteSettings,
},
{
files: '**/*.svelte',
parser: 'svelte-eslint-parser',
settings: svelteSettings,
rules: {
...eslintRules,
},
},
...tsEslint.config({
files: ['**/*.ts'],
extends: [jsEslint.configs.recommended, ...tsEslint.configs.recommended],
languageOptions: {
// parser: svelteParser,
parserOptions: {
parser: '@typescript-eslint/parser'
...parserOptions,
// extraFileExtensions: ['.svelte'],
project: './tsconfig.lint.json',
tsconfigRootDir: './',
},
rules: {
...linterRules,
...svelteRules,
}
},
],
parser: '@babel/eslint-parser',
parserOptions: {
...parserOptions,
requireConfigFile: false,
},
rules: {
...eslintRules,
rules: linterRules,
// settings: svelteSettings,
}),
// {
// files: ['**/*.svelte'],
// settings: svelteSettings,
// // ...sveltePlugin.configs['flat/recommended'],
// languageOptions: {
// parser: svelteParser,
// parserOptions: {
// ...parserOptions,
// extraFileExtensions: ['.svelte'],
// project: './tsconfig.lint.json',
// tsconfigRootDir: './',
// },
// },
// rules: {
// // ...linterRules,
// ...svelteRules,
// },
// },
{
ignores: [
// Repository
'.vscode/',
'patches/',

// Desktop (packages/desktop)
'packages/desktop/electron-builder-config.js',
'packages/desktop/out/',
'packages/desktop/public/',
'packages/desktop/electron/lib/keychain.js',

// Shared (packages/shared)
'packages/shared/src/assets/',
'!packages/shared/src/lib/tests/',
'packages/shared/src/locales/',
'!packages/shared/src/locales/en.json',

// Common files and folders
'**/node_modules/',
'**/out/',
'**/tests/',
],
},
}
]

0 comments on commit 4b2012f

Please sign in to comment.