Skip to content

Commit

Permalink
feat(oxlint): add oxlint config
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Philibeaux <[email protected]>
  • Loading branch information
philibea committed Nov 29, 2024
1 parent c3ee88b commit 7e326ce
Show file tree
Hide file tree
Showing 98 changed files with 751 additions and 370 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ jobs:
pnpm install
pnpm typecheck
oxlint:
runs-on: ubuntu-24.04
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_REMOTE_ONLY: true
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 20
cache: "pnpm"
- run: |
pnpm install
pnpm build
pnpm oxlint -c .oxlintrc.json
lint:
runs-on: ubuntu-24.04
env:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ vitest.config.ts.*
examples/*/.turbo
packages/*/.turbo
tools/*/.turbo

# typescript
*.tsbuildinfo
.tsbuildinfo
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
save-prefix=""
engine-strict=true
package-manager-strict-version=true
manage-package-manager-versions=true
160 changes: 160 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"categories": {
"correctness": "deny",
"style": "deny",
"suspicious": "deny",
"perf": "deny",
"pedantic": "deny",
"restriction": "deny",
"nursery": "off"
},
"plugins": [
"import",
"node",
"react",
"security",
"n",
"tree_shaking",
"typescript",
"unicorn",
"vitest"
],
"overrides": [
{
"files": ["**/__stories__/**/*.{ts,tsx}"],
"rules": {
"react/jsx-key": "off",
"no-console": "off",
"no-alert": "off"
}
}
],
"rules": {
"@typescript-eslint/ban-tslint-comment": "off",
"@typescript-eslint/consistent-indexed-object-style": "off",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript/no-explicit-any": "warn",
"@typescript-eslint/prefer-enum-initializers": "off",
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/prefer-literal-enum-member": "off",
"@typescript-eslint/prefer-ts-expect-error": "off",
"eslint/default-param-last": "off",
"eslint/max-lines": "off",
"eslint/max-params": "off",
"eslint/no-await-in-loop": "off",
"eslint/no-duplicate-imports": "off",
"eslint/no-empty-function": "off",
"eslint/no-magic-numbers": "off",
"eslint/no-ternary": "off",
"eslint/no-undef": "off",
"eslint/no-undefined": "off",
"eslint/sort-keys": "off",
"eslint/react-in-jsx-scope": "off",
"eslint/no-unused-vars": [
"error",
{
"ignoreRestSiblings": true
}
],
"eslint/require-await": "off",
"eslint/sort-imports": [
"error",
{
"ignoreDeclarationSort": true,
"memberSyntaxSortOrder": ["single", "multiple", "all", "none"]
}
],
"import/export": "off",
"import/import-no-namespace": "off",
"import/max-dependencies": "off",
"import/namespace": "off",
"import/no-default-export": "off",
"import/no-deprecated": "warn",
"import/no-duplicates": "off",
"import/no-unused-modules": "off",
"import/unambiguous": "warn",
"jest/no-conditional-expect": "off",
"jest/no-confusing-set-timeout": "off",
"jest/no-hooks": "off",
"jest/no-restricted-jest-methods": "off",
"jest/no-restricted-matchers": "off",
"jest/no-standalone-expect": "off",
"jest/no-untyped-mock-factory": "off",
"jest/prefer-called-with": "off",
"jest/prefer-comparison-matcher": "off",
"jest/prefer-equality-matcher": "off",
"jest/prefer-expect-resolves": "off",
"jest/prefer-lowercase-title": "off",
"jest/prefer-mock-promise-shorthand": "off",
"jest/prefer-spy-on": "off",
"jest/prefer-strict-equal": "off",
"jest/prefer-to-be": "off",
"jest/prefer-to-contain": "off",
"jest/prefer-to-have-length": "off",
"jest/prefer-todo": "error",
"jest/require-hook": "off",
"jest/require-to-throw-message": "off",
"oxc/no-accumulating-spread": "off",
"oxc/no-async-await": "off",
"oxc/no-barrel-file": "off",
"oxc/no-optional-chaining": "off",
"oxc/no-rest-spread-properties": "off",
"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",
"react/jsx-no-useless-fragment": "off",
"react/exhaustive-deps": "warn",
"react/iframe-missing-sandbox": "warn",
"react/jsx-no-target-blank": "off",
"react/no-set-state": "off",
"react/react-in-jsx-scope": "off",
"unicorn/error-message": "off",
"unicorn/filename-case": "off",
"unicorn/no-anonymous-default-export": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-reduce": "off",
"unicorn/no-await-expression-member": "off",
"unicorn/no-await-in-promise-methods": "off",
"unicorn/no-lonely-if": "off",
"unicorn/prefer-set-has": "off",
"unicorn/no-document-cookie": "off",
"unicorn/no-invalid-remove-event-listener": "off",
"unicorn/no-magic-array-flat-depth": "off",
"unicorn/no-negated-condition": "off",
"unicorn/no-new-array": "off",
"unicorn/no-null": "off",
"unicorn/no-object-as-default-parameter": "off",
"unicorn/no-process-exit": "off",
"unicorn/no-single-promise-in-promise-methods": "off",
"unicorn/no-useless-promise-resolve-reject": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/no-zero-fractions": "off",
"unicorn/number-literal-case": "off",
"unicorn/numeric-separators-style": "off",
"unicorn/prefer-add-event-listener": "off",
"unicorn/prefer-array-some": "off",
"unicorn/prefer-blob-reading-methods": "off",
"unicorn/prefer-code-point": "off",
"unicorn/prefer-dom-node-append": "off",
"unicorn/prefer-dom-node-remove": "off",
"unicorn/prefer-logical-operator-over-ternary": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/prefer-string-replace-all": "off",
"unicorn/prefer-string-slice": "off"
},
"settings": {
"jsx-a11y": {
"components": {
"polymorphicPropName": "as"
}
},
"react": {}
}
}
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FlatCompat } from '@eslint/eslintrc'
import scwEmotion from '@scaleway/eslint-config-react/emotion'
import scwJavascript from '@scaleway/eslint-config-react/javascript'
import scwTypescript from '@scaleway/eslint-config-react/typescript'
import oxlint from 'eslint-plugin-oxlint'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
Expand Down Expand Up @@ -148,4 +149,5 @@ export default [
'react/jsx-props-no-spreading': 'off',
},
},
oxlint.configs['flat/all'],
]
2 changes: 1 addition & 1 deletion examples/next-advanced/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const nextConfig = () => {
return config
}

module.exports = nextConfig()
export default nextConfig()
2 changes: 1 addition & 1 deletion examples/next-advanced/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MyDocument extends Document {
return (
<Html>
<Head>
<meta charSet="UTF-8" />
<meta charSet="utf8" />
<meta
name="description"
content="Scaleway Open Source Component Library"
Expand Down
2 changes: 1 addition & 1 deletion examples/next-login/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const nextConfig = () => {
return config
}

module.exports = nextConfig()
export default nextConfig()
4 changes: 2 additions & 2 deletions examples/next-login/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ThemeProvider, Global, css } from '@emotion/react'
import { Global, ThemeProvider, css } from '@emotion/react'
import { Button } from '@ultraviolet/ui'
import { darkTheme, theme, normalize } from '@ultraviolet/ui'
import { darkTheme, normalize, theme } from '@ultraviolet/ui'
import type { AppProps } from 'next/app'
import { useState } from 'react'

Expand Down
2 changes: 1 addition & 1 deletion examples/next-login/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MyDocument extends Document {
return (
<Html>
<Head>
<meta charSet="UTF-8" />
<meta charSet="utf8" />
<meta
name="description"
content="Scaleway Open Source Component Library"
Expand Down
8 changes: 5 additions & 3 deletions examples/next-login/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react'
import LogIn from './login'
import SignUp from './signup'
import { SwitchButton, Stack } from '@ultraviolet/ui'
import { Stack, SwitchButton } from '@ultraviolet/ui'
import styled from '@emotion/styled'

const StyledSwitchButton = styled(SwitchButton)`
Expand All @@ -14,11 +14,13 @@ const StyledPage = styled(Stack)`
const Content = (props: { tab: string }) => {
let tabLoaded = undefined
switch (props.tab) {
case 'login':
case 'login': {
tabLoaded = <LogIn />
break
default:
}
default: {
tabLoaded = <SignUp />
}
}
return tabLoaded
}
Expand Down
8 changes: 5 additions & 3 deletions examples/next-login/src/pages/home/login.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Text, Link, Stack } from '@ultraviolet/ui'
import { Link, Stack, Text } from '@ultraviolet/ui'
import { IdIcon } from '@ultraviolet/icons'
import {
CheckboxField,
Form,
TextInputField,
Submit,
CheckboxField,
TextInputField,
useForm,
useWatch,
} from '@ultraviolet/form'
Expand Down Expand Up @@ -49,6 +49,8 @@ const LogIn = () => {
`,
)
setTimeout(() => setLoginText(''), 3000)

// oxlint-disable-next-line eslint/no-console
console.log('Values :', values)
}

Expand Down
8 changes: 4 additions & 4 deletions examples/next-login/src/pages/home/signup.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Text, Stack, Alert } from '@ultraviolet/ui'
import { Alert, Stack, Text } from '@ultraviolet/ui'
import { ProfileIcon } from '@ultraviolet/icons'
import {
DateField,
Form,
TextInputFieldV2,
RadioGroupField,
Submit,
TextInputFieldV2,
useForm,
RadioGroupField,
DateField,
useWatch,
} from '@ultraviolet/form'
import { useState } from 'react'
Expand Down
2 changes: 1 addition & 1 deletion examples/next-simple/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ const nextConfig = () => {
return config
}

module.exports = nextConfig()
export default nextConfig()
1 change: 1 addition & 0 deletions examples/next-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"directory": "examples/next-simple"
},
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
2 changes: 1 addition & 1 deletion examples/next-simple/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MyDocument extends Document {
return (
<Html>
<Head>
<meta charSet="UTF-8" />
<meta charSet="utf8" />
<meta
name="description"
content="Scaleway Open Source Component Library"
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
},
"lint-staged": {
"*.(j|t|mj)s?(x)": [
"eslint --fix",
"biome format --write ."
"biome format --write .",
"oxlint -c .oxlintrc.json --quiet --fix",
"eslint --cache --cache-strategy content --fix"
],
"*.svg": [
"pnpm run svg"
Expand Down Expand Up @@ -149,6 +150,7 @@
"emoji-toolkit": "9.0.1",
"esbuild-plugin-browserslist": "0.15.0",
"eslint": "9.15.0",
"eslint-plugin-oxlint": "0.13.2",
"eslint-plugin-testing-library": "6.5.0",
"expect": "29.7.0",
"file-loader": "6.2.0",
Expand All @@ -159,6 +161,7 @@
"identity-obj-proxy": "3.0.0",
"jest-axe": "9.0.0",
"lint-staged": "15.2.10",
"oxlint": "0.13.2",
"postcss": "8.4.49",
"publint": "0.2.12",
"react": "18.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default {
return (
<Form
onSubmit={data => {
//oxlint-disable-next-line eslint/no-console
console.log('data', data)
}}
errors={mockErrors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export const Playground: StoryFn<typeof Form> = () => {

Playground.args = {
onSubmit: values => {
//oxlint-disable-next-line eslint/no-console
console.log('Submit', values)
},
}
2 changes: 1 addition & 1 deletion packages/form/src/components/KeyValueField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const KeyValueField = <

return (
<Stack gap={3}>
{fields.length ? (
{fields.length > 0 ? (
<Stack gap={3}>
{fields.map((field, index) => (
<Row
Expand Down
Loading

0 comments on commit 7e326ce

Please sign in to comment.