Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-oxlint

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-oxlint - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

.eslintignore

20

eslint.config.js

@@ -1,5 +0,6 @@

import oxlint from "./index.cjs"
import unicorn from "eslint-plugin-unicorn"
import { FlatCompat } from '@eslint/eslintrc'
import eslint from "@eslint/js"
import oxlint from "./index.cjs";
import unicorn from "eslint-plugin-unicorn";
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";

@@ -10,6 +11,7 @@ const __dirname = new URL(".", import.meta.url).pathname;

export default [
eslint.configs.recommended,
unicorn.configs["flat/recommended"],
...compat.extends("plugin:@typescript-eslint/recommended"),
oxlint,
]
eslint.configs.recommended,
unicorn.configs["flat/recommended"],
...compat.extends("plugin:@typescript-eslint/recommended"),
eslintConfigPrettier,
oxlint.configs["flat/recommended"],
];

@@ -1,9 +0,10 @@

import * as ruleMaps from './rules.js'
import * as ruleMaps from "./rules.js";
// merge objects into one array
const rules = Object.values(ruleMaps).reduce((accumulator, object) => ({ ...accumulator, ...object }))
const rules = Object.values(ruleMaps).reduce((accumulator, object) => ({
...accumulator,
...object,
}));
export default {
rules,
configs: {

@@ -14,3 +15,6 @@ recommended: {

},
"flat/recommended": {
rules,
},
},
};
};
{
"name": "eslint-plugin-oxlint",
"version": "0.2.3",
"version": "0.2.4",
"description": "Turn off all rules already supported by oxlint",

@@ -40,12 +40,21 @@ "type": "module",

"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-unicorn": "^50.0.1",
"oxlint": "^0.2.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"oxlint": "^0.2.8",
"prettier": "^3.2.4",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
},
"lint-staged": {
"*.{js,cjs,ts}": "eslint",
"*": "prettier --ignore-unknown --write"
},
"scripts": {
"generate": "tsx ./scripts/generate-rules.ts",
"lint": "npx oxlint && npx eslint",
"format": "npx prettier --write .",
"release": "bumpp package.json"
}
}
# eslint-plugin-oxlint
Turn off all rules already supported by `oxlint`. The rules extracted from [here](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules.rs)
Turn off all rules already supported by `oxlint`. The rules are extracted from [here](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules.rs)

@@ -26,3 +26,3 @@ ## What is oxlint?

...// other plugins
oxlint, // oxlint should be the last one
oxlint.configs["flat/recommended"], // oxlint should be the last one
];

@@ -39,3 +39,3 @@ ```

... // other config
presets: [
extends: [
... // other presets

@@ -42,0 +42,0 @@ "plugin:oxlint/recommended",

@@ -11,2 +11,3 @@ // These rules are automatically generated by scripts/generate-rules.ts

"getter-return": "off",
"no-this-before-super": "off",
"no-array-constructor": "off",

@@ -47,2 +48,4 @@ "no-async-promise-executor": "off",

"no-new-symbol": "off",
"no-new-wrappers": "off",
"no-nonoctal-decimal-escape": "off",
"no-obj-calls": "off",

@@ -67,2 +70,3 @@ "no-prototype-builtins": "off",

"no-var": "off",
"no-void": "off",
"require-yield": "off",

@@ -76,5 +80,6 @@ "use-isnan": "off",

"@typescript-eslint/adjacent-overload-signatures": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-tslint-comment": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/consistent-type-exports": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",

@@ -92,2 +97,4 @@ "@typescript-eslint/no-empty-interface": "off",

"@typescript-eslint/prefer-as-const": "off",
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/prefer-ts-expect-error": "off",
"@typescript-eslint/triple-slash-reference": "off"

@@ -114,6 +121,11 @@ }

"jest/no-mocks-import": "off",
"jest/no-restricted-jest-methods": "off",
"jest/no-restricted-matchers": "off",
"jest/no-standalone-expect": "off",
"jest/no-test-prefixes": "off",
"jest/no-test-return-statement": "off",
"jest/prefer-called-with": "off",
"jest/prefer-equality-matcher": "off",
"jest/prefer-todo": "off",
"jest/require-to-throw-message": "off",
"jest/valid-describe-callback": "off",

@@ -151,2 +163,3 @@ "jest/valid-expect": "off",

"unicorn/no-object-as-default-parameter": "off",
"unicorn/no-process-exit": "off",
"unicorn/no-static-only-class": "off",

@@ -208,4 +221,5 @@ "unicorn/no-thenable": "off",

"react/button-has-type": "off",
"react/jsx-no-target-blank": "off",
"react/jsx-key": "off",
"react/jsx-no-comment-text-nodes": "off",
"react/jsx-no-comment-textnodes": "off",
"react/jsx-no-duplicate-props": "off",

@@ -216,3 +230,3 @@ "react/jsx-no-useless-fragment": "off",

"react/no-children-prop": "off",
"react/no-dangerously-set-inner-html": "off",
"react/no-danger": "off",
"react/no-direct-mutation-state": "off",

@@ -225,14 +239,29 @@ "react/no-find-dom-node": "off",

"react/no-unknown-property": "off",
"react/require-render-return": "off"
"react/require-render-return": "off",
"react/void-dom-elements-no-children": "off"
}
const reactPerfRules = {
"react-perf/jsx-no-jsx-as-prop": "off",
"react-perf/jsx-no-new-array-as-prop": "off",
"react-perf/jsx-no-new-function-as-prop": "off",
"react-perf/jsx-no-new-object-as-prop": "off"
}
const importRules = {
"import/default": "off",
"import/no-named-as-default-member": "off",
"import/export": "off",
"import/named": "off",
"import/namespace": "off",
"import/no-amd": "off",
"import/no-cycle": "off",
"import/no-deprecated": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/no-self-import": "off",
"import/no-amd": "off",
"import/export": "off"
"import/no-unresolved": "off",
"import/no-unused-modules": "off",
"import/no-duplicates": "off"
}

@@ -263,6 +292,6 @@

"jsx-a11y/scope": "off",
"jsx-a11y/tab-index-no-positive": "off",
"jsx-a11y/tabindex-no-positive": "off",
"jsx-a11y/aria-role": "off",
"jsx-a11y/no-distracting-elements": "off",
"jsx-a11y/role-support-aria-props": "off",
"jsx-a11y/role-supports-aria-props": "off",
"jsx-a11y/autocomplete-valid": "off"

@@ -287,3 +316,5 @@ }

"nextjs/no-typos": "off",
"nextjs/no-document-import-in-page": "off"
"nextjs/no-document-import-in-page": "off",
"nextjs/no-unwanted-polyfillio": "off",
"nextjs/no-before-interactive-script-outside-document": "off"
}

@@ -297,2 +328,3 @@

reactRules,
reactPerfRules,
importRules,

@@ -299,0 +331,0 @@ jsxA11yRules,

@@ -1,64 +0,76 @@

import axios from 'axios'
import { writeFileSync } from 'node:fs'
import path from 'node:path'
import { getLatestOxlintVersion } from './oxlint-version.js';
import axios from "axios";
import { writeFileSync } from "node:fs";
import path from "node:path";
import { getLatestOxlintVersion } from "./oxlint-version.js";
const __dirname = new URL(".", import.meta.url).pathname;
const __dirname = new URL('.', import.meta.url).pathname
const oxlintVersion = await getLatestOxlintVersion();
console.log("Generating rules for " + oxlintVersion)
console.log("Generating rules for " + oxlintVersion);
const oxlintRulesUrl = `https://raw.githubusercontent.com/oxc-project/oxc/${oxlintVersion}/crates/oxc_linter/src/rules.rs`;
const RulesRe = /oxc_macros::declare_all_lint_rules.*{([^*]*),\s*}/gm
const rulesMap = new Map<string, Array<string>>()
const ignoreScope = new Set(["oxc", "deepscan"])
const RulesRe = /oxc_macros::declare_all_lint_rules.*{([^*]*),\s*}/gm;
const rulesMap = new Map<string, Array<string>>();
const ignoreScope = new Set(["oxc", "deepscan"]);
const scopeMaps = {
'eslint': '',
'typescript': '@typescript-eslint',
}
eslint: "",
typescript: "@typescript-eslint",
};
async function generateRules(isCjs = false) {
await axios.get(oxlintRulesUrl).then((response) => {
const rules = RulesRe.exec(response.data || '')?.[1]
const rules = RulesRe.exec(response.data || "")?.[1];
if (rules) {
for (const rule of rules.trim().split(",")) {
const [scope, name] = rule.trim().split("::")
rulesMap.has(scope) ? rulesMap.get(scope)?.push(name) : rulesMap.set(scope, [name])
const [scope, name] = rule.trim().split("::");
rulesMap.has(scope)
? rulesMap.get(scope)?.push(name)
: rulesMap.set(scope, [name]);
}
}
})
const exportScopes: string[] = []
let code = '// These rules are automatically generated by scripts/generate-rules.ts\n\n';
});
const exportScopes: string[] = [];
let code =
"// These rules are automatically generated by scripts/generate-rules.ts\n\n";
for (const scope of rulesMap.keys()) {
if (ignoreScope.has(scope)) {
continue
continue;
}
exportScopes.push(scope)
const rules = rulesMap.get(scope)
code += `\nconst ` + scope.replaceAll(/_(\w)/g, (_, c) => c.toUpperCase()) + 'Rules' + ' = {\n'
const ruleScope = Reflect.has(scopeMaps, scope) ? scopeMaps[scope as 'eslint'] : scope.replace('_', '-')
code += rules?.map((rule) => {
return ` "${ruleScope ? ruleScope + '/' : ''}${rule.replaceAll('_', "-")}": "off"`
}).join(",\n")
code += "\n}\n\n"
exportScopes.push(scope);
const rules = rulesMap.get(scope);
code +=
`\nconst ` +
scope.replaceAll(/_(\w)/g, (_, c) => c.toUpperCase()) +
"Rules" +
" = {\n";
const ruleScope = Reflect.has(scopeMaps, scope)
? scopeMaps[scope as "eslint"]
: scope.replace("_", "-");
code += rules
?.map((rule) => {
return ` "${ruleScope ? ruleScope + "/" : ""}${rule.replaceAll("_", "-")}": "off"`;
})
.join(",\n");
code += "\n}\n\n";
}
code += (isCjs ? 'module.exports = {\n' : 'export {\n')
code += exportScopes.map((scope) => {
return ` ${scope.replaceAll(/_(\w)/g, (_, c) => c.toUpperCase())}Rules`
}).join(",\n")
code += ('\n}')
code += isCjs ? "module.exports = {\n" : "export {\n";
code += exportScopes
.map((scope) => {
return ` ${scope.replaceAll(/_(\w)/g, (_, c) => c.toUpperCase())}Rules`;
})
.join(",\n");
code += "\n}";
writeFileSync(path.resolve(__dirname, `../rules.${isCjs ? 'cjs' : 'js'}`), code);
writeFileSync(
path.resolve(__dirname, `../rules.${isCjs ? "cjs" : "js"}`),
code,
);
}
await generateRules()
await generateRules(true)
await generateRules();
await generateRules(true);
import axios from "axios";
export async function getLatestOxlintVersion() {
const tagsUrl = 'https://api.github.com/repos/oxc-project/oxc/tags';
const tagsUrl = "https://api.github.com/repos/oxc-project/oxc/tags";
const response = await axios.get(tagsUrl);
const tags = response.data.map((tag: any) => tag.name);
const oxlintTags: string[] = tags.filter((tag: string) => tag.startsWith('oxlint_v'));
const latestVersion = oxlintTags.slice(1).reduce((latest: string, current: string) => {
const latestNumber = parseInt(latest.replace('oxlint_v', ''));
const currentNumber = parseInt(current.replace('oxlint_v', ''));
return currentNumber > latestNumber ? current : latest;
}, oxlintTags[0]);
const oxlintTags: string[] = tags.filter((tag: string) =>
tag.startsWith("oxlint_v"),
);
const latestVersion = oxlintTags
.slice(1)
.reduce((latest: string, current: string) => {
const latestNumber = parseInt(latest.replace("oxlint_v", ""));
const currentNumber = parseInt(current.replace("oxlint_v", ""));
return currentNumber > latestNumber ? current : latest;
}, oxlintTags[0]);
return latestVersion;
}

@@ -14,3 +14,3 @@ {

/* Language and Environment */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */

@@ -29,5 +29,5 @@ // "jsx": "preserve", /* Specify what JSX code is generated. */

/* Modules */
"module": "NodeNext", /* Specify what module code is generated. */
"module": "NodeNext" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */

@@ -82,8 +82,8 @@ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */

// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */

@@ -110,4 +110,4 @@ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */

// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
},
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc