Enable oxlint restriction ruleset (#34307)
* Remove stale max-len disablements * Remove stale camelCase & naming-convention disablements * Remove stale ban-ts-comment disablements * Remove stale no-var disablements * Remove stale no-empty-property disablements * Remove stale react rule disablements * Remove stale no-constant-condition disablements * Remove stale no-unused-vars disablements * Remove stale disablements for disabled rules * fixup camelcase * Remove dead code * Tidy code * Tweak oxlint config * Use oxlint to apply jsx/tsx extension consistently * Fix import * Fix imports * Rename affected snapshots * Update more imports * Enable restriction ruleset * Make code comply with new rules * Make code comply with react/button-has-type * Make code comply with typescript/non-nullable-type-assertion-style * Comply with node/no-process-env * Comply with unicorn/prefer-node-protocol * Comply with unicorn/import-style * Comply with unicorn/no-process-exit * Comply with no-proto * Comply with node/handle-callback-err * Comply with import/no-commonjs * Comply with node/no-path-concat * Comply with unicorn/no-length-as-slice-end * Comply with unicorn/no-document-cookie * Comply with unicorn/prefer-module * Comply with typescript/prefer-literal-enum-member * Comply with jsx-a11y/anchor-ambiguous-text * Tweak oxlint config * Fix resolves * Iterate * Iterate * Iterate * Iterate * Iterate * Iterate * Iterate
This commit is contained in:
+98
-16
@@ -52,6 +52,7 @@ export default defineConfig({
|
||||
correctness: "error",
|
||||
perf: "error",
|
||||
suspicious: "error",
|
||||
restriction: "warn",
|
||||
},
|
||||
options: {
|
||||
typeAware: true,
|
||||
@@ -82,7 +83,7 @@ export default defineConfig({
|
||||
"/packages/shared-components/typedoc/",
|
||||
],
|
||||
settings: {
|
||||
jsdoc: {
|
||||
"jsdoc": {
|
||||
tagNamePreference: {
|
||||
remark: "remarks",
|
||||
privateRemarks: "privateRemarks",
|
||||
@@ -96,6 +97,23 @@ export default defineConfig({
|
||||
resolves: "resolves",
|
||||
},
|
||||
},
|
||||
"vitest": {
|
||||
typecheck: true,
|
||||
},
|
||||
"jsx-a11y": {
|
||||
components: {
|
||||
Button: "button",
|
||||
IconButton: "button",
|
||||
AccessibleButton: "button",
|
||||
RovingAccessibleButton: "button",
|
||||
ContextMenuButton: "button",
|
||||
ContextMenuTooltipButton: "button",
|
||||
},
|
||||
// polymorphicPropName: "as", // Would be good to enable in the future
|
||||
},
|
||||
"react": {
|
||||
componentWrapperFunctions: ["withMatrixClientHOC"],
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"no-constant-condition": ["error", { checkLoops: "allExceptWhileTrue" }],
|
||||
@@ -108,17 +126,56 @@ export default defineConfig({
|
||||
],
|
||||
"prefer-const": ["error", { destructuring: "all" }],
|
||||
"import/first": "error",
|
||||
"typescript/no-require-imports": "error",
|
||||
"new-cap": "error",
|
||||
"no-empty-pattern": "error",
|
||||
"typescript/no-unsafe-function-type": "error",
|
||||
"react/rules-of-hooks": "error",
|
||||
"no-extend-native": "error",
|
||||
"no-inner-declarations": "error",
|
||||
"no-var": "error",
|
||||
"typescript/no-unnecessary-type-constraint": "error",
|
||||
"jsx-filename-extension": ["error", { allow: "as-needed", extensions: ["tsx"] }],
|
||||
|
||||
// Tune restriction ruleset
|
||||
"no-undefined": "off",
|
||||
"typescript/use-unknown-in-catch-callback-variable": "off",
|
||||
"typescript/promise-function-async": "off",
|
||||
"typescript/no-non-null-assertion": "off",
|
||||
"typescript/no-invalid-void-type": "off",
|
||||
"typescript/no-explicit-any": "off",
|
||||
"typescript/no-import-type-side-effects": "off",
|
||||
"typescript/no-dynamic-delete": "off",
|
||||
"typescript/explicit-module-boundary-types": "off",
|
||||
"no-param-reassign": "off",
|
||||
"no-use-before-define": "off",
|
||||
"class-methods-use-this": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-default-export": "off",
|
||||
"no-console": "off",
|
||||
"complexity": "off",
|
||||
"no-void": "off",
|
||||
"no-empty-function": "off",
|
||||
"default-case": "off",
|
||||
"no-implicit-globals": "off",
|
||||
"no-bitwise": "off",
|
||||
"no-empty": "off",
|
||||
"no-eq-null": "off",
|
||||
"promise/catch-or-return": "off",
|
||||
"node/no-process-env": "off", // We enable this for src in overrides
|
||||
"unicorn/no-array-reduce": "off",
|
||||
"unicorn/no-anonymous-default-export": "off",
|
||||
"import/no-relative-parent-imports": "off",
|
||||
"import/unambiguous": "off",
|
||||
"import/no-cycle": "off",
|
||||
"jsdoc/empty-tags": "off",
|
||||
"vitest/require-test-timeout": "off",
|
||||
"react/jsx-no-literals": "off",
|
||||
"react/prefer-function-component": "off",
|
||||
"react/forbid-component-props": "off",
|
||||
"react/no-multi-comp": "off",
|
||||
"react/no-danger": "off",
|
||||
"react/only-export-components": "off",
|
||||
"react/no-react-children": "off",
|
||||
"react/no-clone-element": "off",
|
||||
|
||||
"unicorn/no-instanceof-array": "error",
|
||||
"no-restricted-globals": ["error", ...defaultRestrictedGlobals],
|
||||
"no-restricted-properties": ["error", ...defaultRestrictedProperties],
|
||||
@@ -141,10 +198,6 @@ export default defineConfig({
|
||||
allowExpressions: true,
|
||||
},
|
||||
],
|
||||
"typescript/explicit-member-accessibility": "error",
|
||||
|
||||
// Require us to be more explicit about type conversions to help prevent bugs
|
||||
"typescript/no-base-to-string": ["error"],
|
||||
|
||||
// Prevent invalid non-type re-exports of types, these can cause downstream build failures
|
||||
"typescript/consistent-type-exports": ["error"],
|
||||
@@ -232,19 +285,13 @@ export default defineConfig({
|
||||
message: "Buffer is not available in the web.",
|
||||
},
|
||||
],
|
||||
"node/no-process-env": "error",
|
||||
"unicorn/prefer-node-protocol": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["{packages,apps,modules}/*/src/**/*"],
|
||||
rules: {
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
name: "events",
|
||||
message: "Please use TypedEventEmitter instead",
|
||||
},
|
||||
],
|
||||
|
||||
// Enable this in the future, it has a lot of false positives right now
|
||||
// "react/react-compiler": "error",
|
||||
},
|
||||
@@ -285,6 +332,24 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
"apps/desktop/src/**/*",
|
||||
"packages/playwright-common/src/**/*",
|
||||
"**/scripts/**/*",
|
||||
"apps/web/module_system/**/*",
|
||||
],
|
||||
rules: {
|
||||
"no-restricted-globals": "off",
|
||||
"unicorn/prefer-node-protocol": "error",
|
||||
// These files can use envvars
|
||||
"node/no-process-env": "off",
|
||||
// They do not depend on js-sdk for access to TypedEventEmitter so disable this rule
|
||||
"no-restricted-imports": "off",
|
||||
// They can use process.exit
|
||||
"unicorn/no-process-exit": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["apps/web/**/*"],
|
||||
rules: {
|
||||
@@ -307,6 +372,10 @@ export default defineConfig({
|
||||
"error",
|
||||
{
|
||||
paths: [
|
||||
{
|
||||
name: "events",
|
||||
message: "Please use TypedEventEmitter instead",
|
||||
},
|
||||
{
|
||||
name: "react",
|
||||
importNames: ["forwardRef"],
|
||||
@@ -471,12 +540,16 @@ export default defineConfig({
|
||||
],
|
||||
"jsdoc/check-tag-names": "off",
|
||||
"typescript/explicit-function-return-type": "off",
|
||||
"typescript/explicit-module-boundary-types": "off",
|
||||
"typescript/explicit-member-accessibility": "off",
|
||||
"no-proto": "off",
|
||||
|
||||
// Disable a11y rules for components in tests
|
||||
"jsx-a11y/role-has-required-aria-props": "off",
|
||||
"react/button-has-type": "off",
|
||||
"jsx-a11y/interactive-supports-focus": "off",
|
||||
"jsx-a11y/no-static-element-interactions": "off",
|
||||
"jsx-a11y/anchor-ambiguous-text": "off",
|
||||
"jsx-a11y/click-events-have-key-events": "off",
|
||||
"jsx-a11y/media-has-caption": "off",
|
||||
"jsx-a11y/no-noninteractive-element-to-interactive-role": "off",
|
||||
@@ -519,6 +592,15 @@ export default defineConfig({
|
||||
files: ["**/*.{cjs,js}"],
|
||||
rules: {
|
||||
"typescript/no-require-imports": "off",
|
||||
"import/no-commonjs": "off",
|
||||
"unicorn/prefer-module": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["apps/web/test/**/*-test.*"],
|
||||
rules: {
|
||||
// Jest is still CommonJS
|
||||
"unicorn/prefer-module": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user