@praha/oxlint-config-internal 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) PrAha, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @praha/oxlint-config-internal
2
+
3
+ Oxlint config for PrAha.
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ convertGlobals: ()=>convertGlobals
28
+ });
29
+ const convertGlobals = (globals)=>Object.fromEntries(Object.entries(globals).map(([key, value])=>[
30
+ key,
31
+ value ? 'writable' : 'readonly'
32
+ ]));
33
+ exports.convertGlobals = __webpack_exports__.convertGlobals;
34
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
35
+ "convertGlobals"
36
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
37
+ Object.defineProperty(exports, '__esModule', {
38
+ value: true
39
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Convert globals from Record<string, boolean> to Record<string, 'readonly' | 'writable'>
3
+ * @param globals - Globals object with boolean values (true = writable, false = readonly)
4
+ * @returns Converted globals object with 'readonly' | 'writable' values
5
+ */
6
+ export declare const convertGlobals: (globals: Record<string, boolean>) => Record<string, "readonly" | "writable">;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ fetchRules: ()=>fetchRules
37
+ });
38
+ const external_package_json_namespaceObject = require("../../package.json");
39
+ var external_package_json_default = /*#__PURE__*/ __webpack_require__.n(external_package_json_namespaceObject);
40
+ const version = external_package_json_default().dependencies.oxlint.replace('^', '');
41
+ const fetchVitestCompatibleJestRules = async ()=>{
42
+ const response = await fetch(`https://api.github.com/repos/oxc-project/oxc/contents/crates/oxc_linter/data/vitest_compatible_jest_rules.json?ref=oxlint_v${version}`);
43
+ const { content } = await response.json();
44
+ const rules = JSON.parse(atob(content));
45
+ return rules.map((rule)=>`vitest/${rule}`);
46
+ };
47
+ const fetchRules = async (plugin)=>{
48
+ const response = await fetch(`https://api.github.com/repos/oxc-project/oxc/contents/crates/oxc_linter/src/rules/${plugin}?ref=oxlint_v${version}`);
49
+ const directories = await response.json();
50
+ const rules = directories.map((directory)=>`${plugin}/${directory.name.replace('.rs', '').replaceAll('_', '-')}`);
51
+ if ('vitest' === plugin) return [
52
+ ...new Set([
53
+ ...rules,
54
+ ...await fetchVitestCompatibleJestRules()
55
+ ])
56
+ ].toSorted();
57
+ return rules;
58
+ };
59
+ exports.fetchRules = __webpack_exports__.fetchRules;
60
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
61
+ "fetchRules"
62
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
63
+ Object.defineProperty(exports, '__esModule', {
64
+ value: true
65
+ });
@@ -0,0 +1,12 @@
1
+ import type { OxlintConfig } from 'oxlint';
2
+ type Plugin = Exclude<OxlintConfig['plugins'], null | undefined>[number];
3
+ /**
4
+ * Fetches all available rules for a specified oxlint plugin from the oxc repository.
5
+ * For the vitest plugin, this function also includes vitest-compatible Jest rules.
6
+ *
7
+ * @param plugin - The name of the plugin to fetch rules for.
8
+ * @returns A promise that resolves to an array of rule names in the format "plugin/rule-name".
9
+ * @throws Will throw an error if the fetch request fails or if the response cannot be parsed.
10
+ */
11
+ export declare const fetchRules: (plugin: Plugin) => Promise<string[]>;
12
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Convert globals from Record<string, boolean> to Record<string, 'readonly' | 'writable'>
3
+ * @param globals - Globals object with boolean values (true = writable, false = readonly)
4
+ * @returns Converted globals object with 'readonly' | 'writable' values
5
+ */
6
+ export declare const convertGlobals: (globals: Record<string, boolean>) => Record<string, "readonly" | "writable">;
@@ -0,0 +1,5 @@
1
+ const convertGlobals = (globals)=>Object.fromEntries(Object.entries(globals).map(([key, value])=>[
2
+ key,
3
+ value ? 'writable' : 'readonly'
4
+ ]));
5
+ export { convertGlobals };
@@ -0,0 +1,12 @@
1
+ import type { OxlintConfig } from 'oxlint';
2
+ type Plugin = Exclude<OxlintConfig['plugins'], null | undefined>[number];
3
+ /**
4
+ * Fetches all available rules for a specified oxlint plugin from the oxc repository.
5
+ * For the vitest plugin, this function also includes vitest-compatible Jest rules.
6
+ *
7
+ * @param plugin - The name of the plugin to fetch rules for.
8
+ * @returns A promise that resolves to an array of rule names in the format "plugin/rule-name".
9
+ * @throws Will throw an error if the fetch request fails or if the response cannot be parsed.
10
+ */
11
+ export declare const fetchRules: (plugin: Plugin) => Promise<string[]>;
12
+ export {};
@@ -0,0 +1,21 @@
1
+ import package_0 from "../../package.json";
2
+ const version = package_0.dependencies.oxlint.replace('^', '');
3
+ const fetchVitestCompatibleJestRules = async ()=>{
4
+ const response = await fetch(`https://api.github.com/repos/oxc-project/oxc/contents/crates/oxc_linter/data/vitest_compatible_jest_rules.json?ref=oxlint_v${version}`);
5
+ const { content } = await response.json();
6
+ const rules = JSON.parse(atob(content));
7
+ return rules.map((rule)=>`vitest/${rule}`);
8
+ };
9
+ const fetchRules = async (plugin)=>{
10
+ const response = await fetch(`https://api.github.com/repos/oxc-project/oxc/contents/crates/oxc_linter/src/rules/${plugin}?ref=oxlint_v${version}`);
11
+ const directories = await response.json();
12
+ const rules = directories.map((directory)=>`${plugin}/${directory.name.replace('.rs', '').replaceAll('_', '-')}`);
13
+ if ('vitest' === plugin) return [
14
+ ...new Set([
15
+ ...rules,
16
+ ...await fetchVitestCompatibleJestRules()
17
+ ])
18
+ ].toSorted();
19
+ return rules;
20
+ };
21
+ export { fetchRules };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@praha/oxlint-config-internal",
3
+ "version": "1.0.0-beta.0",
4
+ "description": "Oxlint config for PrAha.",
5
+ "keywords": [
6
+ "javascript",
7
+ "typescript",
8
+ "oxlint"
9
+ ],
10
+ "homepage": "https://github.com/praha-inc/oxlint-config/blob/main/packages/internal/README.md",
11
+ "bugs": {
12
+ "url": "https://github.com/praha-inc/oxlint-config/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/praha-inc/oxlint-config.git",
17
+ "directory": "packages/internal"
18
+ },
19
+ "license": "MIT",
20
+ "author": "PrAha, Inc.",
21
+ "sideEffects": false,
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "require": {
26
+ "types": "./dist/cjs/index.d.ts",
27
+ "default": "./dist/cjs/index.cjs"
28
+ },
29
+ "import": {
30
+ "types": "./dist/esm/index.d.ts",
31
+ "default": "./dist/esm/index.js"
32
+ }
33
+ },
34
+ "./test": {
35
+ "require": {
36
+ "types": "./dist/cjs/test/index.d.ts",
37
+ "default": "./dist/cjs/test/index.cjs"
38
+ },
39
+ "import": {
40
+ "types": "./dist/esm/test/index.d.ts",
41
+ "default": "./dist/esm/test/index.js"
42
+ }
43
+ }
44
+ },
45
+ "main": "./dist/cjs/index.cjs",
46
+ "module": "./dist/esm/index.js",
47
+ "types": "./dist/cjs/index.d.ts",
48
+ "files": [
49
+ "dist",
50
+ "LICENSE",
51
+ "README.md"
52
+ ],
53
+ "scripts": {
54
+ "build": "rslib build",
55
+ "test": "vitest run",
56
+ "test:watch": "vitest watch",
57
+ "lint:code": "oxlint",
58
+ "lint:type": "tsc --noEmit"
59
+ },
60
+ "dependencies": {
61
+ "oxlint": "^1.52.0",
62
+ "oxlint-tsgolint": "^0.17.0"
63
+ },
64
+ "devDependencies": {
65
+ "@rslib/core": "0.19.6",
66
+ "typescript": "5.9.3",
67
+ "vitest": "4.0.18"
68
+ }
69
+ }