Skip to content

Commit

Permalink
fix: use existing local .eslintrc configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gioboa authored and wmertens committed Dec 12, 2023
1 parent d95300b commit a499803
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions packages/qwik/src/optimizer/src/plugins/eslint-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,37 @@ export async function createLinter(
tsconfigFileNames: string[]
): Promise<QwikLinter> {
const module: typeof import('eslint') = await sys.dynamicImport('eslint');
const options: ESLint.Options = {
cache: true,
useEslintrc: false,
overrideConfig: {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},

extends: ['plugin:qwik/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: rootDir,
project: tsconfigFileNames,
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
let eslint = new module.ESLint({ cache: true }) as ESLint;
const eslintConfig = await eslint.calculateConfigForFile('no-real-file.tsx');
const invalidEslintConfig = eslintConfig.parser === null;

if (invalidEslintConfig) {
const options: ESLint.Options = {
cache: true,
useEslintrc: false,
overrideConfig: {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['plugin:qwik/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: rootDir,
project: tsconfigFileNames,
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
},
},
};
const eslint = new module.ESLint(options) as ESLint;
};
eslint = new module.ESLint(options) as ESLint;
}

return {
async lint(ctx: Rollup.PluginContext, code: string, id: string) {
Expand Down

0 comments on commit a499803

Please sign in to comment.