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

Support oxlint disable directives #2999

Closed
steelbrain opened this issue Apr 16, 2024 · 7 comments · Fixed by #3024
Closed

Support oxlint disable directives #2999

steelbrain opened this issue Apr 16, 2024 · 7 comments · Fixed by #3024
Assignees
Labels
A-linter Area - Linter C-enhancement Category - New feature or request good first issue Experience Level - Good for newcomers

Comments

@steelbrain
Copy link

Currently oxc supports eslint-disable(-next-line) and eslint-enable(-next-line) etc in comments. This is not always desirable for a project. For example, if the project does not use the same plugins in ESLint as the ones turned on in oxc, ESLint complains about the rules being unknown.

I propose we support oxlint-* in addition to the eslint directives so that we can add these comments without getting ESLint mad

Screenshot Screenshot
@steelbrain steelbrain added the C-enhancement Category - New feature or request label Apr 16, 2024
@Boshen
Copy link
Member

Boshen commented Apr 16, 2024

I didn't know eslint does this ...

We can easily support this by changing the check here

if let Some(text) = text.strip_prefix("eslint-disable") {

if let Some(text) = text.strip_prefix("eslint-enable") {

PR is welcomed.

@Boshen Boshen added the good first issue Experience Level - Good for newcomers label Apr 16, 2024
@Boshen Boshen removed their assignment Apr 16, 2024
@Boshen Boshen added the A-linter Area - Linter label Apr 16, 2024
@crsche
Copy link

crsche commented Apr 18, 2024

@Boshen could I give this a shot?

@Boshen
Copy link
Member

Boshen commented Apr 18, 2024

@Boshen could I give this a shot?

Sure

@Boshen
Copy link
Member

Boshen commented Apr 19, 2024

I wanted to ship this asap 😅

@crsche
Copy link

crsche commented Apr 19, 2024

My bad for not getting to it in time.

@dalisoft
Copy link

dalisoft commented Jul 7, 2024

@Boshen it is does not work. Example command is here

time bunx oxlint --config ./packages/eslint-config-node/oxlintrc.json

  × eslint(max-lines): File has too many lines (385).
   ╭─[packages/eslint-config-base/airbnb-rules.cjs:1:1]
 1 │ // eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
   · ▲
 2 │ /* eslint-disable max-lines */
   ╰────
  help: Maximum allowed is 160.

Finished in 6ms on 36 files with 96 rules using 8 threads.
Found 0 warnings and 1 error.

________________________________________________________
Executed in  100.39 millis    fish           external
   usr time   70.47 millis   78.00 micros   70.39 millis
   sys time   22.72 millis  353.00 micros   22.37 millis

airlight on  master via ⬢ v22.4.0 
❯ 

@dalisoft
Copy link

@Boshen issue still persists

Screenshot 2024-08-14 at 04 19 44
oxlintrc.json
{
  "env": {
    "es2015": true,
    "es2020": true,
    "node": true,
    "browser": false,
    "jest": true
  },
  "globals": {},
  "rules": {
    "brace-style": "off",
    "@stylistic/brace-style": [
      "error",
      "1tbs",
      {
        "allowSingleLine": true
      }
    ],
    "camelcase": "off",
    "@typescript-eslint/naming-convention": [
      "error",
      {
        "selector": [
          "function",
          "method"
        ],
        "format": [
          "strictCamelCase"
        ],
        "leadingUnderscore": "forbid"
      },
      {
        "selector": "property",
        "format": [
          "snake_case",
          "strictCamelCase"
        ],
        "leadingUnderscore": "forbid"
      },
      {
        "selector": "objectLiteralProperty",
        "format": [],
        "leadingUnderscore": "forbid"
      },
      {
        "selector": "variable",
        "modifiers": [
          "const"
        ],
        "types": [
          "boolean",
          "number"
        ],
        "format": [
          "UPPER_CASE"
        ],
        "leadingUnderscore": "forbid"
      },
      {
        "selector": "typeLike",
        "format": [
          "StrictPascalCase"
        ],
        "leadingUnderscore": "forbid"
      },
      {
        "selector": "interface",
        "format": [
          "PascalCase"
        ],
        "leadingUnderscore": "forbid",
        "custom": {
          "regex": "^I[A-Z]",
          "match": true
        }
      }
    ],
    "comma-dangle": "off",
    "@stylistic/comma-dangle": [
      "error",
      "never"
    ],
    "comma-spacing": "off",
    "@stylistic/comma-spacing": [
      "error",
      {
        "before": false,
        "after": true
      }
    ],
    "default-param-last": "off",
    "@typescript-eslint/default-param-last": "error",
    "dot-notation": "off",
    "@typescript-eslint/dot-notation": "error",
    "func-call-spacing": "off",
    "@stylistic/function-call-spacing": [
      "error",
      "never"
    ],
    "indent": [
      "error",
      2,
      {
        "SwitchCase": 1,
        "flatTernaryExpressions": false,
        "offsetTernaryExpressions": true
      }
    ],
    "@typescript-eslint/indent": [
      "off"
    ],
    "keyword-spacing": "off",
    "@stylistic/keyword-spacing": [
      "error",
      {
        "before": true,
        "after": true,
        "overrides": {
          "return": {
            "after": true
          },
          "throw": {
            "after": true
          },
          "case": {
            "after": true
          }
        }
      }
    ],
    "lines-between-class-members": "off",
    "@stylistic/lines-between-class-members": [
      "error",
      "always",
      {
        "exceptAfterSingleLine": false
      }
    ],
    "no-array-constructor": "off",
    "@typescript-eslint/no-array-constructor": "error",
    "no-dupe-class-members": "off",
    "@typescript-eslint/no-dupe-class-members": "error",
    "no-empty-function": [
      "error"
    ],
    "@typescript-eslint/no-empty-function": "off",
    "no-extra-parens": "off",
    "@typescript-eslint/no-extra-parens": [
      "off",
      "all",
      {
        "conditionalAssign": true,
        "nestedBinaryExpressions": false,
        "returnAssign": false,
        "ignoreJSX": "all",
        "enforceForArrowConditionals": false
      }
    ],
    "no-extra-semi": "off",
    "@stylistic/no-extra-semi": "error",
    "no-implied-eval": "off",
    "no-new-func": "off",
    "@typescript-eslint/no-implied-eval": "error",
    "no-loss-of-precision": "off",
    "@typescript-eslint/no-loss-of-precision": "error",
    "no-loop-func": "off",
    "@typescript-eslint/no-loop-func": "error",
    "no-magic-numbers": "off",
    "@typescript-eslint/no-magic-numbers": [
      "off",
      {
        "ignore": [],
        "ignoreArrayIndexes": true,
        "enforceConst": true,
        "detectObjects": false
      }
    ],
    "no-redeclare": "off",
    "@typescript-eslint/no-redeclare": "error",
    "no-shadow": [
      "error",
      {
        "hoist": "functions"
      }
    ],
    "@typescript-eslint/no-shadow": "off",
    "space-before-blocks": "off",
    "@stylistic/space-before-blocks": "error",
    "no-throw-literal": "off",
    "@typescript-eslint/only-throw-error": "error",
    "no-unused-expressions": "off",
    "@typescript-eslint/no-unused-expressions": [
      "error",
      {
        "allowShortCircuit": false,
        "allowTernary": false,
        "allowTaggedTemplates": false
      }
    ],
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": [
      "error",
      {
        "vars": "all",
        "args": "all",
        "argsIgnorePattern": "^_",
        "caughtErrors": "all",
        "caughtErrorsIgnorePattern": "^_",
        "destructuredArrayIgnorePattern": "^_",
        "varsIgnorePattern": "^_",
        "ignoreRestSiblings": false
      }
    ],
    "no-use-before-define": "off",
    "@typescript-eslint/no-use-before-define": [
      "error",
      {
        "functions": true,
        "classes": true,
        "variables": true
      }
    ],
    "no-useless-constructor": "off",
    "@typescript-eslint/no-useless-constructor": "error",
    "quotes": [
      "error",
      "single",
      {
        "avoidEscape": true
      }
    ],
    "@stylistic/quotes": [
      "error",
      "single",
      {
        "avoidEscape": true
      }
    ],
    "semi": "off",
    "@stylistic/semi": [
      "error",
      "always"
    ],
    "space-before-function-paren": "off",
    "@stylistic/space-before-function-paren": [
      "error",
      {
        "anonymous": "always",
        "named": "never",
        "asyncArrow": "always"
      }
    ],
    "require-await": "off",
    "@typescript-eslint/require-await": "off",
    "no-return-await": "off",
    "@typescript-eslint/return-await": [
      "error",
      "in-try-catch"
    ],
    "space-infix-ops": "off",
    "@stylistic/space-infix-ops": "error",
    "object-curly-spacing": "off",
    "@stylistic/object-curly-spacing": [
      "error",
      "always"
    ],
    "@typescript-eslint/ban-ts-comment": "error",
    "import-x/extensions": [
      "error",
      "ignorePackages",
      {
        "js": "always",
        "cjs": "never",
        "mjs": "always",
        "jsx": "never",
        "ts": "never",
        "tsx": "never",
        "json": "always",
        "node": "always",
        "wasm": "always"
      }
    ],
    "import-x/no-extraneous-dependencies": [
      "error",
      {
        "optionalDependencies": false,
        "devDependencies": [
          "test/**",
          "tests/**",
          "spec/**",
          "**/__tests__/**",
          "**/__mocks__/**",
          "test.{js,jsx}",
          "test.{ts,tsx}",
          "test-*.{js,jsx}",
          "test-*.{ts,tsx}",
          "**/*{.,_}{test,spec}.{js,jsx}",
          "**/*{.,_}{test,spec}.{ts,tsx}",
          "**/jest.config.js",
          "**/jest.config.ts",
          "**/jest.setup.js",
          "**/jest.setup.ts",
          "**/vue.config.js",
          "**/vue.config.ts",
          "**/webpack.config.js",
          "**/webpack.config.ts",
          "**/webpack.config.*.js",
          "**/webpack.config.*.ts",
          "**/rollup.config.js",
          "**/rollup.config.ts",
          "**/rollup.config.*.js",
          "**/rollup.config.*.ts",
          "**/gulpfile.js",
          "**/gulpfile.ts",
          "**/gulpfile.*.js",
          "**/gulpfile.*.ts",
          "**/Gruntfile{,.js}",
          "**/Gruntfile{,.ts}",
          "**/protractor.conf.js",
          "**/protractor.conf.ts",
          "**/protractor.conf.*.js",
          "**/protractor.conf.*.ts",
          "**/karma.conf.js",
          "**/karma.conf.ts",
          "**/.eslintrc.js",
          "**/.eslintrc.ts",
          "**/eslint.config.js",
          "**/eslint.config.ts",
          "**/eslint.config.cjs",
          "**/eslint.config.mjs"
        ]
      }
    ],
    "@eslint-community/eslint-comments/no-unused-disable": "error",
    "@eslint-community/eslint-comments/disable-enable-pair": "warn",
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/explicit-module-boundary-types": "off",
    "@typescript-eslint/class-literal-property-style": [
      "error"
    ],
    "@typescript-eslint/no-non-null-asserted-optional-chain": [
      "error"
    ],
    "@typescript-eslint/restrict-plus-operands": [
      "error"
    ],
    "operator-linebreak": [
      "off",
      "after"
    ],
    "prefer-template": "error",
    "complexity": [
      "error",
      {
        "max": 7
      }
    ],
    "max-depth": [
      "error",
      {
        "max": 3
      }
    ],
    "max-nested-callbacks": [
      "error",
      {
        "max": 3
      }
    ],
    "max-lines-per-function": [
      "error",
      {
        "max": 60,
        "skipBlankLines": true,
        "skipComments": true,
        "IIFEs": true
      }
    ],
    "max-lines": [
      "error",
      {
        "max": 160,
        "skipBlankLines": true,
        "skipComments": true
      }
    ],
    "no-useless-concat": "error",
    "no-console": "warn",
    "no-template-curly-in-string": "error",
    "no-underscore-dangle": "off",
    "import-x/prefer-default-export": "warn",
    "import-x/no-mutable-exports": "error",
    "n/no-unsupported-features/es-syntax": [
      "error",
      {
        "ignores": [
          "modules"
        ]
      }
    ]
  },
  "settings": {
    "node": {
      "tryExtensions": [
        ".ts",
        ".js",
        ".d.ts",
        ".html",
        ".md",
        ".json",
        ".wasm",
        ".node"
      ]
    },
    "import-x/resolver": {
      "node": {
        "extensions": [
          ".ts",
          ".mjs",
          ".js",
          ".d.ts",
          ".html",
          ".md",
          ".json",
          ".wasm",
          ".node"
        ]
      },
      "typescript": {
        "alwaysTryTypes": true,
        "project": [
          "packages/*/tsconfig.json",
          "tsconfig.json"
        ]
      }
    },
    "import-x/extensions": [
      ".ts",
      ".mjs",
      ".js",
      ".d.ts",
      ".html",
      ".md",
      ".json",
      ".wasm",
      ".node"
    ],
    "import-x/external-module-folders": [
      "node_modules",
      "node_modules/@types"
    ],
    "import-x/parsers": {
      "@typescript-eslint/parser": [
        ".ts",
        ".tsx",
        ".d.ts"
      ]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-enhancement Category - New feature or request good first issue Experience Level - Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants