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

linter: support .eslintrc config files #636

Closed
DonIsaac opened this issue Jul 26, 2023 · 8 comments
Closed

linter: support .eslintrc config files #636

DonIsaac opened this issue Jul 26, 2023 · 8 comments
Assignees
Labels
A-linter Area - Linter E-Help Wanted Experience level - For the experienced collaborators good first issue Experience Level - Good for newcomers

Comments

@DonIsaac
Copy link
Collaborator

Most users are migrating from ESLint and have configs they like for their projects. oxlint should be able to parse.eslintrc and .eslintrc.json files into LinterOptions.

@DonIsaac DonIsaac added the A-linter Area - Linter label Jul 26, 2023
@Boshen Boshen added the E-Help Wanted Experience level - For the experienced collaborators label Jul 27, 2023
@Boshen
Copy link
Member

Boshen commented Jul 27, 2023

This is open for contributions, we need to port eslint configurations. The only downside is that we can only read json files when running the Rust binary.

I'm not sure about the new flat config system or nested eslint configurations, but we can start simple by only reading the config file from the current working directory or use a --config option to get the file.

Reading other file formats can be figured out later, for example "run" the js file and get its exported configuration in a js wrapper, and then pass it to our Rust binary.

@Boshen Boshen added the good first issue Experience Level - Good for newcomers label Oct 26, 2023
@Boshen
Copy link
Member

Boshen commented Oct 26, 2023

@camc314 If you want something challenging other than implementing lint rules.

This is something we need to be closer to v1.0.0. I've also granted you write access to this repo so you can push branches into this repo.

@Boshen
Copy link
Member

Boshen commented Oct 26, 2023

There is a little hint on how this can be achieved:

https://github.com/web-infra-dev/oxc/blob/94d3e28aac2ef09457e3295432f472d4d7b67f6d/crates/oxc_linter/src/lib.rs#L112-L119

But you are free to architect this differently.

@camc314 camc314 self-assigned this Oct 26, 2023
@camc314
Copy link
Collaborator

camc314 commented Oct 26, 2023

👍 Thanks! i'll take a look and have a think 🙂

@Boshen
Copy link
Member

Boshen commented Nov 5, 2023

#1146

@Boshen Boshen closed this as completed Dec 16, 2023
@webfanzc
Copy link

Did that support ESLint flat config? The newest ESLint version only support eslint.config.js

@Boshen
Copy link
Member

Boshen commented Jan 18, 2024

Did that support ESLint flat config? The newest ESLint version only support eslint.config.js

@webfanzc Are you already using eslint flat config? Can you show me how you are using it?

@webfanzc
Copy link

Did that support ESLint flat config? The newest ESLint version only support eslint.config.js

@webfanzc Are you already using eslint flat config? Can you show me how you are using it?

It's my config

const antfu = require('@antfu/eslint-config').default

module.exports = antfu(
  {
    unocss: true,
    ignores: [
      '.DS_Store',
      '**/.DS_Store/**',
      '.vscode',
      '**/.vscode/**',
      '.vite-ssg-dist',
      '**/.vite-ssg-dist/**',
      '.vite-ssg-temp',
      '**/.vite-ssg-temp/**',
      '*.local',
      '**/*.local/**',
      'dist',
      '**/dist/**',
      'dist-ssr',
      '**/dist-ssr/**',
      'build',
      '**/build/**',
      'public',
      '**/public/**',
      'node_modules',
      '**/node_modules/**',
      '.idea/',
      '**/.idea/**/',
      '*.log',
      '**/*.log/**',
      'sourcemaps',
      '**/sourcemaps/**',
      'coverage',
      '**/coverage/**'
    ]
  },
  {
    rules: {
      'vue/component-name-in-template-casing': ['error', 'kebab-case', {
        registeredComponentsOnly: true
      }],
      'vue/max-attributes-per-line': ['error', {
        singleline: {
          max: 3
        },
        multiline: {
          max: 2
        }
      }],
      'ts/ban-ts-ignore': 'off',
      'ts/explicit-function-return-type': 'off',
      'ts/no-explicit-any': 'off',
      'ts/no-namespace': 'off',
      'ts/no-var-requires': 'off',
      'ts/no-empty-function': 'off',
      'ts/prefer-ts-expect-error': 'off',
      'vue/custom-event-name-casing': 'off',
      'eslint-comments/no-unlimited-disable': 'off',
      'no-use-before-define': 'off',
      // 'no-use-before-define': [
      //   'error',
      //   {
      //     functions: false,
      //     classes: true,
      //   },
      // ],
      'ts/no-use-before-define': 'off',
      // 'ts/no-use-before-define': [
      //   'error',
      //   {
      //     functions: false,
      //     classes: true,
      //   },
      // ],
      'ts/ban-ts-comment': 'off',
      'ts/ban-types': 'off',
      'ts/no-non-null-assertion': 'off',
      'ts/explicit-module-boundary-types': 'off',
      'ts/comma-dangle': ['error', 'never'],
      // 'ts/indent': 0,
      'ts/no-unused-vars': [
        'off',
        {
          argsIgnorePattern: '^h$',
          varsIgnorePattern: '^h$'
        }
      ],
      'no-unused-vars': [
        'off',
        {
          argsIgnorePattern: '^h$',
          varsIgnorePattern: '^h$'
        }
      ],
      'space-before-function-paren': 0,
      'quotes': ['error', 'single'],
      'style/comma-dangle': ['error', 'never'],
      'no-tabs': ['error', { allowIndentationTabs: true }]
    }
  }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter E-Help Wanted Experience level - For the experienced collaborators good first issue Experience Level - Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants