@mouse_484/oxc-config 0.0.1 → 0.1.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/jsconfig.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../jsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "es2022"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mouse_484/oxc-config",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.1.0",
5
5
  "author": "mouse_484",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/mouse484/config/tree/main/packages/oxc",
@@ -14,7 +14,9 @@
14
14
  },
15
15
  "main": "src/index.js",
16
16
  "dependencies": {
17
- "oxlint": "^1.76.0"
17
+ "eslint-plugin-perfectionist": "^5.10.0",
18
+ "oxlint": "^1.76.0",
19
+ "oxlint-tsgolint": "^7.0.2001"
18
20
  },
19
21
  "publishConfig": {
20
22
  "access": "public"
@@ -0,0 +1,19 @@
1
+ import { defineConfig } from 'oxlint'
2
+
3
+ export default defineConfig({
4
+ rules: {
5
+ 'eslint/id-length': ['off'],
6
+ 'eslint/func-style': ['error', 'declaration', { allowArrowFunctions: true }],
7
+ 'eslint/no-magic-numbers': ['error', { ignore: [0, 1, -1] }],
8
+ 'eslint/no-undefined': ['off'],
9
+ 'eslint/no-ternary': ['off'],
10
+ 'eslint/no-nested-ternary': ['error'],
11
+ 'eslint/no-unneeded-ternary': ['error'],
12
+ 'eslint/no-void': ['error', { allowAsStatement: true }],
13
+ /**
14
+ * Prefer `perfectionist` plugin for sorting
15
+ */
16
+ 'eslint/sort-imports': ['off'],
17
+ 'eslint/sort-keys': ['off'],
18
+ },
19
+ })
@@ -0,0 +1,27 @@
1
+ import eslint from './eslint.js'
2
+ import oxc from './oxc.js'
3
+ import perfectionist from './perfectionist.js'
4
+ import tanstackRouter from './tanstack-router.js'
5
+ import typeAware from './type-aware.js'
6
+ import typescript from './typescript.js'
7
+
8
+ /**
9
+ * @satisfies {Record<string, [boolean, import('oxlint').OxlintConfig ]>}
10
+ */
11
+ const _configs = {
12
+ eslint: [true, eslint],
13
+ oxc: [true, oxc],
14
+ perfectionist: [true, perfectionist],
15
+ tanstackRouter: [false, tanstackRouter],
16
+ typeAware: [true, typeAware],
17
+ typescript: [true, typescript],
18
+ }
19
+
20
+ /** @typedef {Partial<Record<keyof typeof _configs, boolean>>} ConfigOptions */
21
+
22
+ /** @param {ConfigOptions} [options] */
23
+ export default function configs(options = {}) {
24
+ return Object.entries(_configs).flatMap(([name, [defaultEnabled, config]]) => {
25
+ return (Object.hasOwn(options, name) ? options[/** @type {keyof ConfigOptions} */ (name)] : defaultEnabled) ? [config] : []
26
+ })
27
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'oxlint'
2
+
3
+ export default defineConfig({
4
+ rules: {
5
+ 'oxc/no-async-await': ['off'],
6
+ 'oxc/no-rest-spread-properties': ['off'],
7
+ },
8
+ })
@@ -0,0 +1,9 @@
1
+ import perfectionist from 'eslint-plugin-perfectionist'
2
+ import { defineConfig } from 'oxlint'
3
+
4
+ export default defineConfig({
5
+ jsPlugins: ['eslint-plugin-perfectionist'],
6
+ rules: {
7
+ ...perfectionist.configs['recommended-natural'].rules,
8
+ },
9
+ })
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'oxlint'
2
+
3
+ export default defineConfig({
4
+ overrides: [{
5
+ files: ['src/routes/**/*.tsx'],
6
+ rules: {
7
+ 'eslint/no-use-before-define': ['off'],
8
+ },
9
+ }],
10
+ })
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'oxlint'
2
+
3
+ export default defineConfig({
4
+ options: {
5
+ typeAware: true,
6
+ typeCheck: true,
7
+ },
8
+ rules: {
9
+ 'typescript/prefer-readonly-parameter-types': ['off'],
10
+ },
11
+ })
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'oxlint'
2
+
3
+ export default defineConfig({
4
+ rules: {
5
+ 'typescript/explicit-function-return-type': ['off'],
6
+ 'typescript/explicit-module-boundary-types': ['off'],
7
+ },
8
+ })
package/src/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { OxlintConfig } from 'oxlint'
2
+ import type { ConfigOptions } from './configs/index.js'
3
+
4
+ export type Options = ConfigOptions
5
+
6
+ declare function lint(options?: Options): OxlintConfig
7
+
8
+ export {
9
+ lint,
10
+ }
package/src/index.js CHANGED
@@ -1,3 +1,18 @@
1
1
  import { defineConfig } from 'oxlint'
2
+ import configs from './configs/index.js'
2
3
 
3
- export default defineConfig({})
4
+ /** @param {import('.').Options} [options] */
5
+ export function lint(options = {}) {
6
+ return defineConfig({
7
+ categories: {
8
+ correctness: 'error',
9
+ suspicious: 'warn',
10
+ pedantic: 'warn',
11
+ perf: 'warn',
12
+ style: 'warn',
13
+ restriction: 'warn',
14
+ nursery: 'warn',
15
+ },
16
+ extends: configs(options),
17
+ })
18
+ }