@imranbarbhuiya/oxc-config 0.1.12 → 0.2.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/README.md +1 -2
- package/dist/common.js +1 -1
- package/dist/common.js.map +1 -1
- package/dist/native.d.ts +0 -5
- package/dist/plugins/api-error.js.map +1 -1
- package/dist/plugins/i18n.js.map +1 -1
- package/dist/plugins/native-tailwind.js.map +1 -1
- package/dist/plugins/nest.js.map +1 -1
- package/dist/plugins/react.d.ts +5 -0
- package/dist/plugins/react.js +369 -0
- package/dist/plugins/react.js.map +1 -0
- package/dist/plugins/restricted-syntax.js +3 -3
- package/dist/plugins/restricted-syntax.js.map +1 -1
- package/dist/react.d.ts +0 -5
- package/dist/react.js +44 -30
- package/dist/react.js.map +1 -1
- package/package.json +1 -10
- package/dist/jsx.d.ts +0 -9
- package/dist/jsx.js +0 -76
- package/dist/jsx.js.map +0 -1
package/README.md
CHANGED
|
@@ -106,8 +106,7 @@ Add scripts to `package.json`:
|
|
|
106
106
|
- `node` contains Node.js rules
|
|
107
107
|
- `module` contains ECMAScript module rules
|
|
108
108
|
- `typescript` contains TypeScript and type-aware rules
|
|
109
|
-
- `
|
|
110
|
-
- `react` contains React rules and includes JSX
|
|
109
|
+
- `react` contains React and JSX rules
|
|
111
110
|
- `native` contains React Native rules and includes React
|
|
112
111
|
- `next` contains Next.js rules
|
|
113
112
|
- `edge` contains edge-runtime rules
|
package/dist/common.js
CHANGED
package/dist/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","names":[],"sources":["../src/common.ts"],"sourcesContent":["import { defineConfig } from 'oxlint';\n\nimport { localPlugin, nativePlugins } from './config.js';\n\nimport type { OxlintConfig } from 'oxlint';\n\nconst rules: NonNullable<OxlintConfig['rules']> = {\n\t'array-callback-return': 2,\n\t'arrow-body-style': [2, 'as-needed'],\n\t'block-scoped-var': 2,\n\t'consistent-return': 2,\n\t'constructor-super': 2,\n\tcurly: [2, 'multi-or-nest'],\n\t'default-case': 2,\n\t'default-case-last': 2,\n\t'default-param-last': 2,\n\t'dot-notation': 2,\n\teqeqeq: 2,\n\t'for-direction': 2,\n\t'func-name-matching': 2,\n\t'func-names': [2, 'as-needed'],\n\t'func-style': [\n\t\t2,\n\t\t'declaration',\n\t\t{\n\t\t\tallowArrowFunctions: true,\n\t\t},\n\t],\n\t'getter-return': 2,\n\t'grouped-accessor-pairs': [2, 'getBeforeSet'],\n\t'guard-for-in': 2,\n\t'import/export': 2,\n\t'import/first': 2,\n\t'import/newline-after-import': 2,\n\t'import/no-absolute-path': 2,\n\t'import/no-amd': 2,\n\t'import/no-duplicates': 2,\n\t'import/no-dynamic-require': 2,\n\t'import/no-mutable-exports': 2,\n\t'import/no-self-import': 2,\n\t'import/no-webpack-loader-syntax': 2,\n\t'no-alert': 2,\n\t'no-array-constructor': 2,\n\t'no-async-promise-executor': 2,\n\t'no-caller': 2,\n\t'no-case-declarations': 2,\n\t'no-class-assign': 2,\n\t'no-compare-neg-zero': 2,\n\t'no-cond-assign': 2,\n\t'no-const-assign': 2,\n\t'no-constructor-return': 2,\n\t'no-control-regex': 2,\n\t'no-debugger': 2,\n\t'no-delete-var': 2,\n\t'no-dupe-class-members': 2,\n\t'no-dupe-else-if': 2,\n\t'no-dupe-keys': 2,\n\t'no-duplicate-case': 2,\n\t'no-empty-character-class': 2,\n\t'no-empty-pattern': 2,\n\t'no-eval': 2,\n\t'no-ex-assign': 2,\n\t'no-extend-native': 2,\n\t'no-extra-bind': 2,\n\t'no-extra-boolean-cast': 2,\n\t'no-extra-label': 2,\n\t'no-fallthrough': 2,\n\t'no-func-assign': 2,\n\t'no-global-assign': 2,\n\t'no-implicit-coercion': 2,\n\t'no-implicit-globals': 2,\n\t'no-implied-eval': 2,\n\t'no-import-assign': 2,\n\t'no-inner-declarations': 2,\n\t'no-invalid-regexp': 2,\n\t'no-irregular-whitespace': 2,\n\t'no-iterator': 2,\n\t'no-label-var': 2,\n\t'no-labels': 2,\n\t'no-lone-blocks': 2,\n\t'no-lonely-if': 2,\n\t'no-loss-of-precision': 2,\n\t'no-misleading-character-class': 2,\n\t'no-multi-assign': 2,\n\t'no-multi-str': 2,\n\t'no-new-func': 2,\n\t'no-new-wrappers': 2,\n\t'no-nonoctal-decimal-escape': 2,\n\t'no-obj-calls': 2,\n\t'no-promise-executor-return': 2,\n\t'no-proto': 2,\n\t'no-prototype-builtins': 2,\n\t'no-redeclare': [\n\t\t2,\n\t\t{\n\t\t\tbuiltinGlobals: true,\n\t\t},\n\t],\n\t'no-regex-spaces': 2,\n\t'no-return-assign': 2,\n\t'no-script-url': 2,\n\t'no-self-assign': 2,\n\t'no-self-compare': 2,\n\t'no-sequences': 2,\n\t'no-setter-return': 2,\n\t'no-shadow': [\n\t\t2,\n\t\t{\n\t\t\tbuiltinGlobals: false,\n\t\t\thoist: 'all',\n\t\t},\n\t],\n\t'no-shadow-restricted-names': 2,\n\t'no-template-curly-in-string': 2,\n\t'no-this-before-super': 2,\n\t'no-throw-literal': 2,\n\t'no-undef': 2,\n\t'no-unexpected-multiline': 2,\n\t'no-unmodified-loop-condition': 2,\n\t'no-unneeded-ternary': 2,\n\t'no-unreachable-loop': 2,\n\t'no-unsafe-finally': 2,\n\t'no-unsafe-negation': 2,\n\t'no-unsafe-optional-chaining': 2,\n\t'no-unused-expressions': 2,\n\t'no-unused-labels': 2,\n\t'no-unused-vars': 2,\n\t'no-use-before-define': [\n\t\t2,\n\t\t{\n\t\t\tclasses: true,\n\t\t\tfunctions: false,\n\t\t\tvariables: true,\n\t\t},\n\t],\n\t'no-useless-backreference': 2,\n\t'no-useless-call': 2,\n\t'no-useless-catch': 2,\n\t'no-useless-computed-key': 2,\n\t'no-useless-concat': 2,\n\t'no-useless-constructor': 2,\n\t'no-useless-escape': 2,\n\t'no-useless-rename': [\n\t\t2,\n\t\t{\n\t\t\tignoreDestructuring: false,\n\t\t\tignoreExport: false,\n\t\t\tignoreImport: false,\n\t\t},\n\t],\n\t'no-useless-return': 2,\n\t'no-var': 2,\n\t'no-with': 2,\n\t'object-shorthand': [2, 'always'],\n\t'one-var': [2, 'never'],\n\t'operator-assignment': [2, 'always'],\n\t'prefer-arrow-callback': 2,\n\t'prefer-const': 2,\n\t'prefer-exponentiation-operator': 2,\n\t'prefer-numeric-literals': 2,\n\t'prefer-object-has-own': 2,\n\t'prefer-object-spread': 2,\n\t'prefer-promise-reject-errors': 2,\n\t'prefer-regex-literals': [\n\t\t2,\n\t\t{\n\t\t\tdisallowRedundantWrapping: true,\n\t\t},\n\t],\n\t'prefer-rest-params': 2,\n\t'prefer-spread': 2,\n\t'promise/param-names': 2,\n\t'promise/prefer-await-to-callbacks': 1,\n\t'promise/prefer-await-to-then': 2,\n\t'promise/valid-params': 2,\n\tradix: 2,\n\t'require-yield': 2,\n\t'sort-vars': 2,\n\t'symbol-description': 2,\n\t'unicode-bom': [2, 'never'],\n\t'unicorn/catch-error-name': [\n\t\t2,\n\t\t{\n\t\t\tname: 'error',\n\t\t},\n\t],\n\t'unicorn/consistent-function-scoping': 2,\n\t'unicorn/empty-brace-spaces': 2,\n\t'unicorn/error-message': 2,\n\t'unicorn/escape-case': 2,\n\t'unicorn/new-for-builtins': 2,\n\t'unicorn/no-abusive-eslint-disable': 2,\n\t'unicorn/no-array-for-each': 1,\n\t'unicorn/no-array-method-this-argument': 0,\n\t'unicorn/no-await-in-promise-methods': 2,\n\t'unicorn/no-document-cookie': 2,\n\t'unicorn/no-empty-file': 2,\n\t'unicorn/no-instanceof-array': 2,\n\t'unicorn/no-invalid-remove-event-listener': 2,\n\t'unicorn/no-lonely-if': 2,\n\t'unicorn/no-negated-condition': 2,\n\t'unicorn/no-new-array': 2,\n\t'unicorn/no-new-buffer': 2,\n\t'unicorn/no-object-as-default-parameter': 2,\n\t'unicorn/no-single-promise-in-promise-methods': 2,\n\t'unicorn/no-static-only-class': 2,\n\t'unicorn/no-thenable': 2,\n\t'unicorn/no-this-assignment': 2,\n\t'unicorn/no-typeof-undefined': 2,\n\t'unicorn/no-unnecessary-await': 2,\n\t'unicorn/no-unreadable-iife': 2,\n\t'unicorn/no-useless-fallback-in-spread': 2,\n\t'unicorn/no-useless-length-check': 2,\n\t'unicorn/no-useless-promise-resolve-reject': 2,\n\t'unicorn/no-useless-spread': 2,\n\t'unicorn/no-useless-switch-case': 2,\n\t'unicorn/no-zero-fractions': 2,\n\t'unicorn/numeric-separators-style': [\n\t\t2,\n\t\t{\n\t\t\tbinary: {\n\t\t\t\tonlyIfContainsSeparator: true,\n\t\t\t},\n\t\t\thexadecimal: {\n\t\t\t\tonlyIfContainsSeparator: true,\n\t\t\t},\n\t\t\tnumber: {\n\t\t\t\tgroupLength: 3,\n\t\t\t\tminimumDigits: 0,\n\t\t\t},\n\t\t\toctal: {\n\t\t\t\tonlyIfContainsSeparator: true,\n\t\t\t},\n\t\t},\n\t],\n\t'unicorn/prefer-array-find': 2,\n\t'unicorn/prefer-array-flat': 2,\n\t'unicorn/prefer-array-flat-map': 2,\n\t'unicorn/prefer-array-index-of': 2,\n\t'unicorn/prefer-array-some': 2,\n\t'unicorn/prefer-code-point': 2,\n\t'unicorn/prefer-date-now': 2,\n\t'unicorn/prefer-default-parameters': 2,\n\t'unicorn/prefer-export-from': 2,\n\t'unicorn/prefer-includes': 2,\n\t'unicorn/prefer-math-trunc': 2,\n\t'unicorn/prefer-modern-math-apis': 2,\n\t'unicorn/prefer-native-coercion-functions': 2,\n\t'unicorn/prefer-number-properties': 2,\n\t'unicorn/prefer-object-from-entries': 2,\n\t'unicorn/prefer-optional-catch-binding': 2,\n\t'unicorn/prefer-query-selector': 2,\n\t'unicorn/prefer-reflect-apply': 2,\n\t'unicorn/prefer-regexp-test': 2,\n\t'unicorn/prefer-set-size': 2,\n\t'unicorn/prefer-string-replace-all': 2,\n\t'unicorn/prefer-string-slice': 2,\n\t'unicorn/prefer-string-starts-ends-with': 2,\n\t'unicorn/prefer-string-trim-start-end': 2,\n\t'unicorn/prefer-type-error': 2,\n\t'unicorn/relative-url-style': [2, 'never'],\n\t'unicorn/require-array-join-separator': 2,\n\t'unicorn/require-number-to-fixed-digits-argument': 2,\n\t'unicorn/require-post-message-target-origin': 2,\n\t'unicorn/text-encoding-identifier-case': 2,\n\t'unicorn/throw-new-error': 2,\n\t'use-isnan': 2,\n\t'valid-typeof': [\n\t\t2,\n\t\t{\n\t\t\trequireStringLiterals: true,\n\t\t},\n\t],\n\t'vars-on-top': 2,\n\tyoda: [2, 'never'],\n};\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('mahir-restricted-syntax', './plugins/restricted-syntax.js')],\n\tcategories: {\n\t\tcorrectness: 'off',\n\t},\n\toptions: {\n\t\treportUnusedDisableDirectives: 'warn',\n\t},\n\trules,\n});\n\nexport default config;\n"],"mappings":";;;;AAqRA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,2BAA2B,gCAAgC,CAAC;CACpF,YAAY,EACX,aAAa,MACd;CACA,SAAS,EACR,+BAA+B,OAChC;CACA;EAvRA,yBAAyB;EACzB,oBAAoB,CAAC,GAAG,WAAW;EACnC,oBAAoB;EACpB,qBAAqB;EACrB,qBAAqB;EACrB,OAAO,CAAC,GAAG,eAAe;EAC1B,gBAAgB;EAChB,qBAAqB;EACrB,sBAAsB;EACtB,gBAAgB;EAChB,QAAQ;EACR,iBAAiB;EACjB,sBAAsB;EACtB,cAAc,CAAC,GAAG,WAAW;EAC7B,cAAc;GACb;GACA;GACA,EACC,qBAAqB,KACtB;EACD;EACA,iBAAiB;EACjB,0BAA0B,CAAC,GAAG,cAAc;EAC5C,gBAAgB;EAChB,iBAAiB;EACjB,gBAAgB;EAChB,+BAA+B;EAC/B,2BAA2B;EAC3B,iBAAiB;EACjB,wBAAwB;EACxB,6BAA6B;EAC7B,6BAA6B;EAC7B,yBAAyB;EACzB,mCAAmC;EACnC,YAAY;EACZ,wBAAwB;EACxB,6BAA6B;EA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D,CACD;EACA,6BAA6B;EAC7B,6BAA6B;EAC7B,iCAAiC;EACjC,iCAAiC;EACjC,6BAA6B;EAC7B,6BAA6B;EAC7B,2BAA2B;EAC3B,qCAAqC;EACrC,8BAA8B;EAC9B,2BAA2B;EAC3B,6BAA6B;EAC7B,mCAAmC;EACnC,4CAA4C;EAC5C,oCAAoC;EACpC,sCAAsC;EACtC,yCAAyC;EACzC,iCAAiC;EACjC,gCAAgC;EAChC,8BAA8B;EAC9B,2BAA2B;EAC3B,qCAAqC;EACrC,+BAA+B;EAC/B,0CAA0C;EAC1C,wCAAwC;EACxC,6BAA6B;EAC7B,8BAA8B,CAAC,GAAG,OAAO;EACzC,wCAAwC;EACxC,mDAAmD;EACnD,8CAA8C;EAC9C,yCAAyC;EACzC,2BAA2B;EAC3B,aAAa;EACb,gBAAgB,CACf,GACA,EACC,uBAAuB,KACxB,CACD;EACA,eAAe;EACf,MAAM,CAAC,GAAG,OAAO;CAYb;AACL,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["../src/common.ts"],"sourcesContent":["import { defineConfig } from 'oxlint';\n\nimport { localPlugin, nativePlugins } from './config.js';\n\nimport type { OxlintConfig } from 'oxlint';\n\nconst rules: NonNullable<OxlintConfig['rules']> = {\n\t'array-callback-return': 2,\n\t'arrow-body-style': [2, 'as-needed'],\n\t'block-scoped-var': 2,\n\t'consistent-return': 2,\n\t'constructor-super': 2,\n\t// `multi-line` is the only option that leaves line breaking to oxfmt. Under `multi-or-nest` a\n\t// single statement longer than `printWidth` gets wrapped in braces by the formatter, and the\n\t// linter then asks for those braces back, so the two never agree. This still catches what the\n\t// rule is for, a body sitting on its own line without braces.\n\tcurly: [2, 'multi-line'],\n\t'default-case': 2,\n\t'default-case-last': 2,\n\t'default-param-last': 2,\n\t'dot-notation': 2,\n\teqeqeq: 2,\n\t'for-direction': 2,\n\t'func-name-matching': 2,\n\t'func-names': [2, 'as-needed'],\n\t'func-style': [\n\t\t2,\n\t\t'declaration',\n\t\t{\n\t\t\tallowArrowFunctions: true,\n\t\t},\n\t],\n\t'getter-return': 2,\n\t'grouped-accessor-pairs': [2, 'getBeforeSet'],\n\t'guard-for-in': 2,\n\t'import/export': 2,\n\t'import/first': 2,\n\t'import/newline-after-import': 2,\n\t'import/no-absolute-path': 2,\n\t'import/no-amd': 2,\n\t'import/no-duplicates': 2,\n\t'import/no-dynamic-require': 2,\n\t'import/no-mutable-exports': 2,\n\t'import/no-self-import': 2,\n\t'import/no-webpack-loader-syntax': 2,\n\t'no-alert': 2,\n\t'no-array-constructor': 2,\n\t'no-async-promise-executor': 2,\n\t'no-caller': 2,\n\t'no-case-declarations': 2,\n\t'no-class-assign': 2,\n\t'no-compare-neg-zero': 2,\n\t'no-cond-assign': 2,\n\t'no-const-assign': 2,\n\t'no-constructor-return': 2,\n\t'no-control-regex': 2,\n\t'no-debugger': 2,\n\t'no-delete-var': 2,\n\t'no-dupe-class-members': 2,\n\t'no-dupe-else-if': 2,\n\t'no-dupe-keys': 2,\n\t'no-duplicate-case': 2,\n\t'no-empty-character-class': 2,\n\t'no-empty-pattern': 2,\n\t'no-eval': 2,\n\t'no-ex-assign': 2,\n\t'no-extend-native': 2,\n\t'no-extra-bind': 2,\n\t'no-extra-boolean-cast': 2,\n\t'no-extra-label': 2,\n\t'no-fallthrough': 2,\n\t'no-func-assign': 2,\n\t'no-global-assign': 2,\n\t'no-implicit-coercion': 2,\n\t'no-implicit-globals': 2,\n\t'no-implied-eval': 2,\n\t'no-import-assign': 2,\n\t'no-inner-declarations': 2,\n\t'no-invalid-regexp': 2,\n\t'no-irregular-whitespace': 2,\n\t'no-iterator': 2,\n\t'no-label-var': 2,\n\t'no-labels': 2,\n\t'no-lone-blocks': 2,\n\t'no-lonely-if': 2,\n\t'no-loss-of-precision': 2,\n\t'no-misleading-character-class': 2,\n\t'no-multi-assign': 2,\n\t'no-multi-str': 2,\n\t'no-new-func': 2,\n\t'no-new-wrappers': 2,\n\t'no-nonoctal-decimal-escape': 2,\n\t'no-obj-calls': 2,\n\t'no-promise-executor-return': 2,\n\t'no-proto': 2,\n\t'no-prototype-builtins': 2,\n\t'no-redeclare': [\n\t\t2,\n\t\t{\n\t\t\tbuiltinGlobals: true,\n\t\t},\n\t],\n\t'no-regex-spaces': 2,\n\t'no-return-assign': 2,\n\t'no-script-url': 2,\n\t'no-self-assign': 2,\n\t'no-self-compare': 2,\n\t'no-sequences': 2,\n\t'no-setter-return': 2,\n\t'no-shadow': [\n\t\t2,\n\t\t{\n\t\t\tbuiltinGlobals: false,\n\t\t\thoist: 'all',\n\t\t},\n\t],\n\t'no-shadow-restricted-names': 2,\n\t'no-template-curly-in-string': 2,\n\t'no-this-before-super': 2,\n\t'no-throw-literal': 2,\n\t'no-undef': 2,\n\t'no-unexpected-multiline': 2,\n\t'no-unmodified-loop-condition': 2,\n\t'no-unneeded-ternary': 2,\n\t'no-unreachable-loop': 2,\n\t'no-unsafe-finally': 2,\n\t'no-unsafe-negation': 2,\n\t'no-unsafe-optional-chaining': 2,\n\t'no-unused-expressions': 2,\n\t'no-unused-labels': 2,\n\t'no-unused-vars': 2,\n\t'no-use-before-define': [\n\t\t2,\n\t\t{\n\t\t\tclasses: true,\n\t\t\tfunctions: false,\n\t\t\tvariables: true,\n\t\t},\n\t],\n\t'no-useless-backreference': 2,\n\t'no-useless-call': 2,\n\t'no-useless-catch': 2,\n\t'no-useless-computed-key': 2,\n\t'no-useless-concat': 2,\n\t'no-useless-constructor': 2,\n\t'no-useless-escape': 2,\n\t'no-useless-rename': [\n\t\t2,\n\t\t{\n\t\t\tignoreDestructuring: false,\n\t\t\tignoreExport: false,\n\t\t\tignoreImport: false,\n\t\t},\n\t],\n\t'no-useless-return': 2,\n\t'no-var': 2,\n\t'no-with': 2,\n\t'object-shorthand': [2, 'always'],\n\t'one-var': [2, 'never'],\n\t'operator-assignment': [2, 'always'],\n\t'prefer-arrow-callback': 2,\n\t'prefer-const': 2,\n\t'prefer-exponentiation-operator': 2,\n\t'prefer-numeric-literals': 2,\n\t'prefer-object-has-own': 2,\n\t'prefer-object-spread': 2,\n\t'prefer-promise-reject-errors': 2,\n\t'prefer-regex-literals': [\n\t\t2,\n\t\t{\n\t\t\tdisallowRedundantWrapping: true,\n\t\t},\n\t],\n\t'prefer-rest-params': 2,\n\t'prefer-spread': 2,\n\t'promise/param-names': 2,\n\t'promise/prefer-await-to-callbacks': 1,\n\t'promise/prefer-await-to-then': 2,\n\t'promise/valid-params': 2,\n\tradix: 2,\n\t'require-yield': 2,\n\t'sort-vars': 2,\n\t'symbol-description': 2,\n\t'unicode-bom': [2, 'never'],\n\t'unicorn/catch-error-name': [\n\t\t2,\n\t\t{\n\t\t\tname: 'error',\n\t\t},\n\t],\n\t'unicorn/consistent-function-scoping': 2,\n\t'unicorn/empty-brace-spaces': 2,\n\t'unicorn/error-message': 2,\n\t'unicorn/escape-case': 2,\n\t'unicorn/new-for-builtins': 2,\n\t'unicorn/no-abusive-eslint-disable': 2,\n\t'unicorn/no-array-for-each': 1,\n\t'unicorn/no-array-method-this-argument': 0,\n\t'unicorn/no-await-in-promise-methods': 2,\n\t'unicorn/no-document-cookie': 2,\n\t'unicorn/no-empty-file': 2,\n\t'unicorn/no-instanceof-array': 2,\n\t'unicorn/no-invalid-remove-event-listener': 2,\n\t'unicorn/no-lonely-if': 2,\n\t'unicorn/no-negated-condition': 2,\n\t'unicorn/no-new-array': 2,\n\t'unicorn/no-new-buffer': 2,\n\t'unicorn/no-object-as-default-parameter': 2,\n\t'unicorn/no-single-promise-in-promise-methods': 2,\n\t'unicorn/no-static-only-class': 2,\n\t'unicorn/no-thenable': 2,\n\t'unicorn/no-this-assignment': 2,\n\t'unicorn/no-typeof-undefined': 2,\n\t'unicorn/no-unnecessary-await': 2,\n\t'unicorn/no-unreadable-iife': 2,\n\t'unicorn/no-useless-fallback-in-spread': 2,\n\t'unicorn/no-useless-length-check': 2,\n\t'unicorn/no-useless-promise-resolve-reject': 2,\n\t'unicorn/no-useless-spread': 2,\n\t'unicorn/no-useless-switch-case': 2,\n\t'unicorn/no-zero-fractions': 2,\n\t'unicorn/numeric-separators-style': [\n\t\t2,\n\t\t{\n\t\t\tbinary: {\n\t\t\t\tonlyIfContainsSeparator: true,\n\t\t\t},\n\t\t\thexadecimal: {\n\t\t\t\tonlyIfContainsSeparator: true,\n\t\t\t},\n\t\t\tnumber: {\n\t\t\t\tgroupLength: 3,\n\t\t\t\tminimumDigits: 0,\n\t\t\t},\n\t\t\toctal: {\n\t\t\t\tonlyIfContainsSeparator: true,\n\t\t\t},\n\t\t},\n\t],\n\t'unicorn/prefer-array-find': 2,\n\t'unicorn/prefer-array-flat': 2,\n\t'unicorn/prefer-array-flat-map': 2,\n\t'unicorn/prefer-array-index-of': 2,\n\t'unicorn/prefer-array-some': 2,\n\t'unicorn/prefer-code-point': 2,\n\t'unicorn/prefer-date-now': 2,\n\t'unicorn/prefer-default-parameters': 2,\n\t'unicorn/prefer-export-from': 2,\n\t'unicorn/prefer-includes': 2,\n\t'unicorn/prefer-math-trunc': 2,\n\t'unicorn/prefer-modern-math-apis': 2,\n\t'unicorn/prefer-native-coercion-functions': 2,\n\t'unicorn/prefer-number-properties': 2,\n\t'unicorn/prefer-object-from-entries': 2,\n\t'unicorn/prefer-optional-catch-binding': 2,\n\t'unicorn/prefer-query-selector': 2,\n\t'unicorn/prefer-reflect-apply': 2,\n\t'unicorn/prefer-regexp-test': 2,\n\t'unicorn/prefer-set-size': 2,\n\t'unicorn/prefer-string-replace-all': 2,\n\t'unicorn/prefer-string-slice': 2,\n\t'unicorn/prefer-string-starts-ends-with': 2,\n\t'unicorn/prefer-string-trim-start-end': 2,\n\t'unicorn/prefer-type-error': 2,\n\t'unicorn/relative-url-style': [2, 'never'],\n\t'unicorn/require-array-join-separator': 2,\n\t'unicorn/require-number-to-fixed-digits-argument': 2,\n\t'unicorn/require-post-message-target-origin': 2,\n\t'unicorn/text-encoding-identifier-case': 2,\n\t'unicorn/throw-new-error': 2,\n\t'use-isnan': 2,\n\t'valid-typeof': [\n\t\t2,\n\t\t{\n\t\t\trequireStringLiterals: true,\n\t\t},\n\t],\n\t'vars-on-top': 2,\n\tyoda: [2, 'never'],\n};\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('mahir-restricted-syntax', './plugins/restricted-syntax.js')],\n\tcategories: {\n\t\tcorrectness: 'off',\n\t},\n\toptions: {\n\t\treportUnusedDisableDirectives: 'warn',\n\t},\n\trules,\n});\n\nexport default config;\n"],"mappings":";;;;AAyRA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,2BAA2B,gCAAgC,CAAC;CACpF,YAAY,EACX,aAAa,MACd;CACA,SAAS,EACR,+BAA+B,OAChC;CACA;EA3RA,yBAAyB;EACzB,oBAAoB,CAAC,GAAG,WAAW;EACnC,oBAAoB;EACpB,qBAAqB;EACrB,qBAAqB;EAKrB,OAAO,CAAC,GAAG,YAAY;EACvB,gBAAgB;EAChB,qBAAqB;EACrB,sBAAsB;EACtB,gBAAgB;EAChB,QAAQ;EACR,iBAAiB;EACjB,sBAAsB;EACtB,cAAc,CAAC,GAAG,WAAW;EAC7B,cAAc;GACb;GACA;GACA,EACC,qBAAqB,KACtB;EACD;EACA,iBAAiB;EACjB,0BAA0B,CAAC,GAAG,cAAc;EAC5C,gBAAgB;EAChB,iBAAiB;EACjB,gBAAgB;EAChB,+BAA+B;EAC/B,2BAA2B;EAC3B,iBAAiB;EACjB,wBAAwB;EACxB,6BAA6B;EAC7B,6BAA6B;EAC7B,yBAAyB;EACzB,mCAAmC;EACnC,YAAY;EACZ,wBAAwB;EACxB,6BAA6B;EAC7B,aAAa;EACb,wBAAwB;EACxB,mBAAmB;EACnB,uBAAuB;EACvB,kBAAkB;EAClB,mBAAmB;EACnB,yBAAyB;EACzB,oBAAoB;EACpB,eAAe;EACf,iBAAiB;EACjB,yBAAyB;EACzB,mBAAmB;EACnB,gBAAgB;EAChB,qBAAqB;EACrB,4BAA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AC5C,oCAAoC;EACpC,sCAAsC;EACtC,yCAAyC;EACzC,iCAAiC;EACjC,gCAAgC;EAChC,8BAA8B;EAC9B,2BAA2B;EAC3B,qCAAqC;EACrC,+BAA+B;EAC/B,0CAA0C;EAC1C,wCAAwC;EACxC,6BAA6B;EAC7B,8BAA8B,CAAC,GAAG,OAAO;EACzC,wCAAwC;EACxC,mDAAmD;EACnD,8CAA8C;EAC9C,yCAAyC;EACzC,2BAA2B;EAC3B,aAAa;EACb,gBAAgB,CACf,GACA,EACC,uBAAuB,KACxB,CACD;EACA,eAAe;EACf,MAAM,CAAC,GAAG,OAAO;CAYb;AACL,CAAC"}
|
package/dist/native.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
//#region src/native.d.ts
|
|
2
2
|
declare const config: {
|
|
3
3
|
extends: {
|
|
4
|
-
extends: {
|
|
5
|
-
plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
|
|
6
|
-
jsPlugins: import("oxlint").ExternalPluginEntry[];
|
|
7
|
-
rules: import("oxlint").DummyRuleMap;
|
|
8
|
-
}[];
|
|
9
4
|
plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
|
|
10
5
|
jsPlugins: import("oxlint").ExternalPluginEntry[];
|
|
11
6
|
env: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-error.js","names":[],"sources":["../../src/plugins/api-error.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst DEFAULT_ALLOWED_ERRORS = ['ApiError', 'FormValidationError'];\n\nfunction getStaticFactoryCallee(arg: ESTree.Node) {\n\tif (arg.type !== 'CallExpression') return undefined;\n\tconst { callee } = arg;\n\tif (callee.type !== 'MemberExpression' || callee.computed) return undefined;\n\tconst { object, property } = callee;\n\tif (object.type !== 'Identifier' || property.type !== 'Identifier') return undefined;\n\treturn { callee, name: object.name };\n}\n\nfunction isAstNode(value: unknown): value is ESTree.Node {\n\treturn typeof value === 'object' && value !== null && 'type' in value && typeof (value as { type: unknown }).type === 'string';\n}\n\nconst requireApiError = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription:\n\t\t\t\t'Require an allowed API error instead of Error inside queryFn/mutationFn so status codes propagate to QueryCache error handling',\n\t\t},\n\t\tschema: [\n\t\t\t{\n\t\t\t\ttype: 'object',\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tproperties: {\n\t\t\t\t\tallowedErrors: {\n\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\titems: { type: 'string', minLength: 1 },\n\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\tuniqueItems: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tmessages: {\n\t\t\tuseApiError:\n\t\t\t\t'Use `new {{allowed}}(...)` or `{{allowed}}.from(...)` instead of `new {{thrown}}(...)` inside {{fnType}}. This ensures the HTTP status code is available in QueryCache/retry/error reporting.',\n\t\t\tuseApiErrorCall:\n\t\t\t\t'Use `new {{allowed}}(...)` or `{{allowed}}.from(...)` instead of `{{thrown}}(...)` inside {{fnType}}. This ensures the HTTP status code is available in QueryCache/retry/error reporting.',\n\t\t\tuseApiErrorMember:\n\t\t\t\t'Throw `new {{allowed}}(...)` or `{{allowed}}.from(...)` instead of re-throwing `{{thrown}}` directly inside {{fnType}}. The client error object may lose its HTTP status code in QueryCache/retry/error reporting.',\n\t\t},\n\t\tdefaultOptions: [{ allowedErrors: [...DEFAULT_ALLOWED_ERRORS] }],\n\t},\n\tcreateOnce(context) {\n\t\tlet allowedErrors = new Set(DEFAULT_ALLOWED_ERRORS);\n\t\tlet allowedExample = DEFAULT_ALLOWED_ERRORS[0];\n\t\tconst fnStack: string[] = [];\n\t\tconst extractedRefs: { name: string; fnType: string }[] = [];\n\t\tconst moduleFns = new Map<string, ESTree.Node>();\n\n\t\tfunction recordModuleFn(name: string | undefined, body: ESTree.Node | null | undefined) {\n\t\t\tif (!name || !body) return;\n\t\t\tif (!moduleFns.has(name)) moduleFns.set(name, body);\n\t\t}\n\n\t\tfunction isAllowedThrow(arg: ESTree.Node) {\n\t\t\tif (arg.type === 'NewExpression' && arg.callee.type === 'Identifier') return allowedErrors.has(arg.callee.name);\n\t\t\tconst factory = getStaticFactoryCallee(arg);\n\t\t\treturn factory !== undefined && allowedErrors.has(factory.name);\n\t\t}\n\n\t\tfunction checkThrowNode(node: ESTree.ThrowStatement, fnType: string) {\n\t\t\tconst arg = node.argument;\n\t\t\tif (isAllowedThrow(arg)) return;\n\n\t\t\tif (arg.type === 'NewExpression' && arg.callee.type === 'Identifier') {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: arg,\n\t\t\t\t\tmessageId: 'useApiError',\n\t\t\t\t\tdata: { thrown: arg.callee.name, fnType, allowed: allowedExample },\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst factory = getStaticFactoryCallee(arg);\n\t\t\tif (factory) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: arg,\n\t\t\t\t\tmessageId: 'useApiErrorCall',\n\t\t\t\t\tdata: { thrown: context.sourceCode.getText(factory.callee), fnType, allowed: allowedExample },\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (arg.type === 'MemberExpression') {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: arg,\n\t\t\t\t\tmessageId: 'useApiErrorMember',\n\t\t\t\t\tdata: { thrown: context.sourceCode.getText(arg), fnType, allowed: allowedExample },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tfunction walkThrows(node: ESTree.Node | null | undefined, fnType: string, visited = new Set<ESTree.Node>()) {\n\t\t\tif (!node || visited.has(node)) return;\n\t\t\tvisited.add(node);\n\n\t\t\tif (node.type === 'ThrowStatement') {\n\t\t\t\tcheckThrowNode(node, fnType);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tnode.type === 'FunctionDeclaration' ||\n\t\t\t\tnode.type === 'FunctionExpression' ||\n\t\t\t\tnode.type === 'ArrowFunctionExpression'\n\t\t\t) {\n\t\t\t\twalkThrows(node.body, fnType, visited);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const key of Object.keys(node)) {\n\t\t\t\tif (key === 'parent' || key === 'loc' || key === 'range') continue;\n\t\t\t\tconst child = (node as unknown as Record<string, unknown>)[key];\n\t\t\t\tif (Array.isArray(child)) {\n\t\t\t\t\tfor (const item of child) if (isAstNode(item)) walkThrows(item, fnType, visited);\n\t\t\t\t} else if (isAstNode(child)) walkThrows(child, fnType, visited);\n\t\t\t}\n\t\t}\n\n\t\tfunction enterQueryOrMutationFn(node: ESTree.ArrowFunctionExpression | ESTree.Function) {\n\t\t\tconst parent = node.parent;\n\t\t\tif (parent.type !== 'Property' || parent.key.type !== 'Identifier') return;\n\t\t\tconst name = parent.key.name;\n\t\t\tif (name === 'queryFn' || name === 'mutationFn') fnStack.push(name);\n\t\t}\n\n\t\tfunction exitQueryOrMutationFn(node: ESTree.ArrowFunctionExpression | ESTree.Function) {\n\t\t\tconst parent = node.parent;\n\t\t\tif (parent.type !== 'Property' || parent.key.type !== 'Identifier') return;\n\t\t\tconst name = parent.key.name;\n\t\t\tif (name === 'queryFn' || name === 'mutationFn') fnStack.pop();\n\t\t}\n\n\t\tfunction checkThrowStatement(node: ESTree.ThrowStatement) {\n\t\t\tif (fnStack.length === 0) return;\n\t\t\tcheckThrowNode(node, fnStack.at(-1) ?? '');\n\t\t}\n\n\t\tfunction recordExtractedRef(prop: ESTree.Node) {\n\t\t\tif (prop.type !== 'Property') return;\n\t\t\tif (\n\t\t\t\tprop.key.type !== 'Identifier' ||\n\t\t\t\t(prop.key.name !== 'queryFn' && prop.key.name !== 'mutationFn') ||\n\t\t\t\tprop.value.type !== 'Identifier'\n\t\t\t)\n\t\t\t\treturn;\n\t\t\textractedRefs.push({ name: prop.value.name, fnType: prop.key.name });\n\t\t}\n\n\t\treturn {\n\t\t\tbefore() {\n\t\t\t\tconst options = context.options[0] as { allowedErrors?: string[] } | undefined;\n\t\t\t\tconst allowedList = options?.allowedErrors ?? DEFAULT_ALLOWED_ERRORS;\n\t\t\t\tallowedErrors = new Set(allowedList);\n\t\t\t\tallowedExample = allowedList[0] ?? DEFAULT_ALLOWED_ERRORS[0];\n\t\t\t\tfnStack.length = 0;\n\t\t\t\textractedRefs.length = 0;\n\t\t\t\tmoduleFns.clear();\n\t\t\t},\n\t\t\t'Program > FunctionDeclaration'(node) {\n\t\t\t\tif (node.type !== 'FunctionDeclaration') return;\n\t\t\t\trecordModuleFn(node.id?.name, node.body);\n\t\t\t},\n\t\t\t'Program > VariableDeclaration > VariableDeclarator'(node) {\n\t\t\t\tif (node.type !== 'VariableDeclarator') return;\n\t\t\t\tif (\n\t\t\t\t\tnode.id.type === 'Identifier' &&\n\t\t\t\t\t(node.init?.type === 'ArrowFunctionExpression' || node.init?.type === 'FunctionExpression')\n\t\t\t\t)\n\t\t\t\t\trecordModuleFn(node.id.name, node.init.body);\n\t\t\t},\n\t\t\tArrowFunctionExpression: enterQueryOrMutationFn,\n\t\t\t'ArrowFunctionExpression:exit': exitQueryOrMutationFn,\n\t\t\tFunctionExpression: enterQueryOrMutationFn,\n\t\t\t'FunctionExpression:exit': exitQueryOrMutationFn,\n\t\t\tProperty: recordExtractedRef,\n\t\t\tThrowStatement: checkThrowStatement,\n\t\t\t'Program:exit'() {\n\t\t\t\tfor (const { name, fnType } of extractedRefs) {\n\t\t\t\t\tconst body = moduleFns.get(name);\n\t\t\t\t\tif (body) walkThrows(body, fnType);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlug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AAe,KAAK,IAAI,MAAM,KAAK,IAAI;GACxC;GACA,qDAAqD,MAAM;IAC1D,IAAI,KAAK,SAAS,sBAAsB;IACxC,IACC,KAAK,GAAG,SAAS,iBAChB,KAAK,MAAM,SAAS,6BAA6B,KAAK,MAAM,SAAS,uBAEtE,eAAe,KAAK,GAAG,MAAM,KAAK,KAAK,IAAI;GAC7C;GACA,yBAAyB;GACzB,gCAAgC;GAChC,oBAAoB;GACpB,2BAA2B;GAC3B,UAAU;GACV,gBAAgB;GAChB,iBAAiB;IAChB,KAAK,MAAM,EAAE,MAAM,YAAY,eAAe;KAC7C,MAAM,OAAO,UAAU,IAAI,IAAI;KAC/B,IAAI,MAAM,WAAW,MAAM,MAAM;IAClC;GACD;EACD;CACD;AACD,CAAC;AAED,wBAAe,aAAa;CAC3B,MAAM,EACL,MAAM,gCACP;CACA,OAAO,EACN,qBAAqB,gBACtB;AACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"api-error.js","names":[],"sources":["../../src/plugins/api-error.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst DEFAULT_ALLOWED_ERRORS = ['ApiError', 'FormValidationError'];\n\nfunction getStaticFactoryCallee(arg: ESTree.Node) {\n\tif (arg.type !== 'CallExpression') return undefined;\n\tconst { callee } = arg;\n\tif (callee.type !== 'MemberExpression' || callee.computed) return undefined;\n\tconst { object, property } = callee;\n\tif (object.type !== 'Identifier' || property.type !== 'Identifier') return undefined;\n\treturn { callee, name: object.name };\n}\n\nfunction isAstNode(value: unknown): value is ESTree.Node {\n\treturn typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string';\n}\n\nconst requireApiError = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription:\n\t\t\t\t'Require an allowed API error instead of Error inside queryFn/mutationFn so status codes propagate to QueryCache error handling',\n\t\t},\n\t\tschema: [\n\t\t\t{\n\t\t\t\ttype: 'object',\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tproperties: {\n\t\t\t\t\tallowedErrors: {\n\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\titems: { type: 'string', minLength: 1 },\n\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\tuniqueItems: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tmessages: {\n\t\t\tuseApiError:\n\t\t\t\t'Use `new {{allowed}}(...)` or `{{allowed}}.from(...)` instead of `new {{thrown}}(...)` inside {{fnType}}. This ensures the HTTP status code is available in QueryCache/retry/error reporting.',\n\t\t\tuseApiErrorCall:\n\t\t\t\t'Use `new {{allowed}}(...)` or `{{allowed}}.from(...)` instead of `{{thrown}}(...)` inside {{fnType}}. This ensures the HTTP status code is available in QueryCache/retry/error reporting.',\n\t\t\tuseApiErrorMember:\n\t\t\t\t'Throw `new {{allowed}}(...)` or `{{allowed}}.from(...)` instead of re-throwing `{{thrown}}` directly inside {{fnType}}. The client error object may lose its HTTP status code in QueryCache/retry/error reporting.',\n\t\t},\n\t\tdefaultOptions: [{ allowedErrors: [...DEFAULT_ALLOWED_ERRORS] }],\n\t},\n\tcreateOnce(context) {\n\t\tlet allowedErrors = new Set(DEFAULT_ALLOWED_ERRORS);\n\t\tlet allowedExample = DEFAULT_ALLOWED_ERRORS[0];\n\t\tconst fnStack: string[] = [];\n\t\tconst extractedRefs: { name: string; fnType: string }[] = [];\n\t\tconst moduleFns = new Map<string, ESTree.Node>();\n\n\t\tfunction recordModuleFn(name: string | undefined, body: ESTree.Node | null | undefined) {\n\t\t\tif (!name || !body) return;\n\t\t\tif (!moduleFns.has(name)) moduleFns.set(name, body);\n\t\t}\n\n\t\tfunction isAllowedThrow(arg: ESTree.Node) {\n\t\t\tif (arg.type === 'NewExpression' && arg.callee.type === 'Identifier') return allowedErrors.has(arg.callee.name);\n\t\t\tconst factory = getStaticFactoryCallee(arg);\n\t\t\treturn factory !== undefined && allowedErrors.has(factory.name);\n\t\t}\n\n\t\tfunction checkThrowNode(node: ESTree.ThrowStatement, fnType: string) {\n\t\t\tconst arg = node.argument;\n\t\t\tif (isAllowedThrow(arg)) return;\n\n\t\t\tif (arg.type === 'NewExpression' && arg.callee.type === 'Identifier') {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: arg,\n\t\t\t\t\tmessageId: 'useApiError',\n\t\t\t\t\tdata: { thrown: arg.callee.name, fnType, allowed: allowedExample },\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst factory = getStaticFactoryCallee(arg);\n\t\t\tif (factory) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: arg,\n\t\t\t\t\tmessageId: 'useApiErrorCall',\n\t\t\t\t\tdata: { thrown: context.sourceCode.getText(factory.callee), fnType, allowed: allowedExample },\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (arg.type === 'MemberExpression') {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: arg,\n\t\t\t\t\tmessageId: 'useApiErrorMember',\n\t\t\t\t\tdata: { thrown: context.sourceCode.getText(arg), fnType, allowed: allowedExample },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tfunction walkThrows(node: ESTree.Node | null | undefined, fnType: string, visited = new Set<ESTree.Node>()) {\n\t\t\tif (!node || visited.has(node)) return;\n\t\t\tvisited.add(node);\n\n\t\t\tif (node.type === 'ThrowStatement') {\n\t\t\t\tcheckThrowNode(node, fnType);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tnode.type === 'FunctionDeclaration' ||\n\t\t\t\tnode.type === 'FunctionExpression' ||\n\t\t\t\tnode.type === 'ArrowFunctionExpression'\n\t\t\t) {\n\t\t\t\twalkThrows(node.body, fnType, visited);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const key of Object.keys(node)) {\n\t\t\t\tif (key === 'parent' || key === 'loc' || key === 'range') continue;\n\t\t\t\tconst child = (node as unknown as Record<string, unknown>)[key];\n\t\t\t\tif (Array.isArray(child)) {\n\t\t\t\t\tfor (const item of child) if (isAstNode(item)) walkThrows(item, fnType, visited);\n\t\t\t\t} else if (isAstNode(child)) walkThrows(child, fnType, visited);\n\t\t\t}\n\t\t}\n\n\t\tfunction enterQueryOrMutationFn(node: ESTree.ArrowFunctionExpression | ESTree.Function) {\n\t\t\tconst parent = node.parent;\n\t\t\tif (parent.type !== 'Property' || parent.key.type !== 'Identifier') return;\n\t\t\tconst name = parent.key.name;\n\t\t\tif (name === 'queryFn' || name === 'mutationFn') fnStack.push(name);\n\t\t}\n\n\t\tfunction exitQueryOrMutationFn(node: ESTree.ArrowFunctionExpression | ESTree.Function) {\n\t\t\tconst parent = node.parent;\n\t\t\tif (parent.type !== 'Property' || parent.key.type !== 'Identifier') return;\n\t\t\tconst name = parent.key.name;\n\t\t\tif (name === 'queryFn' || name === 'mutationFn') fnStack.pop();\n\t\t}\n\n\t\tfunction checkThrowStatement(node: ESTree.ThrowStatement) {\n\t\t\tif (fnStack.length === 0) return;\n\t\t\tcheckThrowNode(node, fnStack.at(-1) ?? '');\n\t\t}\n\n\t\tfunction recordExtractedRef(prop: ESTree.Node) {\n\t\t\tif (prop.type !== 'Property') return;\n\t\t\tif (\n\t\t\t\tprop.key.type !== 'Identifier' ||\n\t\t\t\t(prop.key.name !== 'queryFn' && prop.key.name !== 'mutationFn') ||\n\t\t\t\tprop.value.type !== 'Identifier'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\textractedRefs.push({ name: prop.value.name, fnType: prop.key.name });\n\t\t}\n\n\t\treturn {\n\t\t\tbefore() {\n\t\t\t\tconst options = context.options[0] as { allowedErrors?: string[] } | undefined;\n\t\t\t\tconst allowedList = options?.allowedErrors ?? DEFAULT_ALLOWED_ERRORS;\n\t\t\t\tallowedErrors = new Set(allowedList);\n\t\t\t\tallowedExample = allowedList[0] ?? DEFAULT_ALLOWED_ERRORS[0];\n\t\t\t\tfnStack.length = 0;\n\t\t\t\textractedRefs.length = 0;\n\t\t\t\tmoduleFns.clear();\n\t\t\t},\n\t\t\t'Program > FunctionDeclaration'(node) {\n\t\t\t\tif (node.type !== 'FunctionDeclaration') return;\n\t\t\t\trecordModuleFn(node.id?.name, node.body);\n\t\t\t},\n\t\t\t'Program > VariableDeclaration > VariableDeclarator'(node) {\n\t\t\t\tif (node.type !== 'VariableDeclarator') return;\n\t\t\t\tif (\n\t\t\t\t\tnode.id.type === 'Identifier' &&\n\t\t\t\t\t(node.init?.type === 'ArrowFunctionExpression' || node.init?.type === 'FunctionExpression')\n\t\t\t\t) {\n\t\t\t\t\trecordModuleFn(node.id.name, node.init.body);\n\t\t\t\t}\n\t\t\t},\n\t\t\tArrowFunctionExpression: enterQueryOrMutationFn,\n\t\t\t'ArrowFunctionExpression:exit': exitQueryOrMutationFn,\n\t\t\tFunctionExpression: enterQueryOrMutationFn,\n\t\t\t'FunctionExpression:exit': exitQueryOrMutationFn,\n\t\t\tProperty: recordExtractedRef,\n\t\t\tThrowStatement: checkThrowStatement,\n\t\t\t'Program:exit'() {\n\t\t\t\tfor (const { name, fnType } of extractedRefs) {\n\t\t\t\t\tconst body = moduleFns.get(name);\n\t\t\t\t\tif (body) walkThrows(body, fnType);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-api-error',\n\t},\n\trules: {\n\t\t'require-api-error': requireApiError,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,yBAAyB,CAAC,YAAY,qBAAqB;AAEjE,SAAS,uBAAuB,KAAkB;CACjD,IAAI,IAAI,SAAS,kBAAkB,OAAO;CAC1C,MAAM,EAAE,WAAW;CACnB,IAAI,OAAO,SAAS,sBAAsB,OAAO,UAAU,OAAO;CAClE,MAAM,EAAE,QAAQ,aAAa;CAC7B,IAAI,OAAO,SAAS,gBAAgB,SAAS,SAAS,cAAc,OAAO;CAC3E,O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,UAAU,IAAI,IAAI;KAC/B,IAAI,MAAM,WAAW,MAAM,MAAM;IAClC;GACD;EACD;CACD;AACD,CAAC;AAED,wBAAe,aAAa;CAC3B,MAAM,EACL,MAAM,gCACP;CACA,OAAO,EACN,qBAAqB,gBACtB;AACD,CAAC"}
|
package/dist/plugins/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":[],"sources":["../../src/plugins/i18n.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nconst staticTArguments = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Require t() calls to use static string literals so next-intl can extract messages at build time',\n\t\t},\n\t\tmessages: {\n\t\t\tstaticArgument:\n\t\t\t\t'`t()` must receive a static string literal. Dynamic expressions cannot be extracted by next-intl. Use separate `t(\"Key\")` calls instead.',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tif (node.callee.type !== 'Identifier' || node.callee.name !== 't') return;\n\t\t\t\tif (node.arguments.length === 0) return;\n\t\t\t\tconst firstArg = node.arguments[0];\n\t\t\t\tif (firstArg.type !== 'Literal' || typeof firstArg.value !== 'string')\n\t\t\t\t\tcontext.report({ node: firstArg, messageId: 'staticArgument' });\n\t\t\t},\n\t\t};\n\t},\n});\n\nconst noTAsParameter = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow passing the `t` translation function as an argument to other functions or components',\n\t\t},\n\t\tmessages: {\n\t\t\tnoTParam:\n\t\t\t\t'Do not pass `t` as an argument. Call `useExtracted()` or `getExtracted()` directly in the consuming component/function instead.',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tfor (const arg of node.arguments)\n\t\t\t\t\tif (arg.type === 'Identifier' && arg.name === 't') context.report({ node: arg, messageId: 'noTParam' });\n\t\t\t},\n\t\t\tJSXAttribute(node) {\n\t\t\t\tif (\n\t\t\t\t\tnode.value?.type === 'JSXExpressionContainer' &&\n\t\t\t\t\tnode.value.expression.type === 'Identifier' &&\n\t\t\t\t\tnode.value.expression.name === 't'\n\t\t\t\t)\n\t\t\t\t\tcontext.report({ node: node.value.expression, messageId: 'noTParam' });\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-i18n',\n\t},\n\trules: {\n\t\t'static-t-arguments': staticTArguments,\n\t\t'no-t-as-parameter': noTAsParameter,\n\t},\n});\n"],"mappings":";;;AAEA,MAAM,mBAAmB,WAAW;CACnC,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,kGACd;EACA,UAAU,EACT,gBACC,6IACF;CACD;CACA,WAAW,SAAS;EACnB,OAAO,EACN,eAAe,MAAM;GACpB,IAAI,KAAK,OAAO,SAAS,gBAAgB,KAAK,OAAO,SAAS,KAAK;GACnE,IAAI,KAAK,UAAU,WAAW,GAAG;GACjC,MAAM,WAAW,KAAK,UAAU;GAChC,IAAI,SAAS,SAAS,aAAa,OAAO,SAAS,UAAU,UAC5D,QAAQ,OAAO;IAAE,MAAM;IAAU,WAAW;GAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"i18n.js","names":[],"sources":["../../src/plugins/i18n.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nconst staticTArguments = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Require t() calls to use static string literals so next-intl can extract messages at build time',\n\t\t},\n\t\tmessages: {\n\t\t\tstaticArgument:\n\t\t\t\t'`t()` must receive a static string literal. Dynamic expressions cannot be extracted by next-intl. Use separate `t(\"Key\")` calls instead.',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tif (node.callee.type !== 'Identifier' || node.callee.name !== 't') return;\n\t\t\t\tif (node.arguments.length === 0) return;\n\t\t\t\tconst firstArg = node.arguments[0];\n\t\t\t\tif (firstArg.type !== 'Literal' || typeof firstArg.value !== 'string') {\n\t\t\t\t\tcontext.report({ node: firstArg, messageId: 'staticArgument' });\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nconst noTAsParameter = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow passing the `t` translation function as an argument to other functions or components',\n\t\t},\n\t\tmessages: {\n\t\t\tnoTParam:\n\t\t\t\t'Do not pass `t` as an argument. Call `useExtracted()` or `getExtracted()` directly in the consuming component/function instead.',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tfor (const arg of node.arguments) {\n\t\t\t\t\tif (arg.type === 'Identifier' && arg.name === 't') context.report({ node: arg, messageId: 'noTParam' });\n\t\t\t\t}\n\t\t\t},\n\t\t\tJSXAttribute(node) {\n\t\t\t\tif (\n\t\t\t\t\tnode.value?.type === 'JSXExpressionContainer' &&\n\t\t\t\t\tnode.value.expression.type === 'Identifier' &&\n\t\t\t\t\tnode.value.expression.name === 't'\n\t\t\t\t) {\n\t\t\t\t\tcontext.report({ node: node.value.expression, messageId: 'noTParam' });\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-i18n',\n\t},\n\trules: {\n\t\t'static-t-arguments': staticTArguments,\n\t\t'no-t-as-parameter': noTAsParameter,\n\t},\n});\n"],"mappings":";;;AAEA,MAAM,mBAAmB,WAAW;CACnC,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,kGACd;EACA,UAAU,EACT,gBACC,6IACF;CACD;CACA,WAAW,SAAS;EACnB,OAAO,EACN,eAAe,MAAM;GACpB,IAAI,KAAK,OAAO,SAAS,gBAAgB,KAAK,OAAO,SAAS,KAAK;GACnE,IAAI,KAAK,UAAU,WAAW,GAAG;GACjC,MAAM,WAAW,KAAK,UAAU;GAChC,IAAI,SAAS,SAAS,aAAa,OAAO,SAAS,UAAU,UAC5D,QAAQ,OAAO;IAAE,MAAM;IAAU,WAAW;GAAiB,CAAC;EAEhE,EACD;CACD;AACD,CAAC;AAED,MAAM,iBAAiB,WAAW;CACjC,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,gGACd;EACA,UAAU,EACT,UACC,kIACF;CACD;CACA,WAAW,SAAS;EACnB,OAAO;GACN,eAAe,MAAM;IACpB,KAAK,MAAM,OAAO,KAAK,WACtB,IAAI,IAAI,SAAS,gBAAgB,IAAI,SAAS,KAAK,QAAQ,OAAO;KAAE,MAAM;KAAK,WAAW;IAAW,CAAC;GAExG;GACA,aAAa,MAAM;IAClB,IACC,KAAK,OAAO,SAAS,4BACrB,KAAK,MAAM,WAAW,SAAS,gBAC/B,KAAK,MAAM,WAAW,SAAS,KAE/B,QAAQ,OAAO;KAAE,MAAM,KAAK,MAAM;KAAY,WAAW;IAAW,CAAC;GAEvE;EACD;CACD;AACD,CAAC;AAED,mBAAe,aAAa;CAC3B,MAAM,EACL,MAAM,2BACP;CACA,OAAO;EACN,sBAAsB;EACtB,qBAAqB;CACtB;AACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-tailwind.js","names":[],"sources":["../../src/plugins/native-tailwind.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst FORBIDDEN = new Set(['flex-col']);\n\nconst classNameRules = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow Tailwind flex-col, and standalone flex',\n\t\t},\n\t\tfixable: 'code',\n\t\tmessages: {\n\t\t\tforbidden: \"Class '{{cls}}' is the default in react-native, so no need to explicitly set it.\",\n\t\t\tflexOnly: \"Class 'flex' should be removed or changed to 'flex-row' for explicit direction.\",\n\t\t},\n\t\thasSuggestions: true,\n\t},\n\tcreateOnce(context) {\n\t\tfunction reportAndFix(node: ESTree.Node, text: string, raw: string | null) {\n\t\t\tconst classes = text.trim().split(/\\s+/);\n\t\t\tconst hasFlex = classes.includes('flex');\n\t\t\tconst hasFlexCol = classes.includes('flex-col');\n\t\t\tconst hasFlexRow = classes.includes('flex-row');\n\t\t\tconst offendingForbidden = classes.filter((cl) => FORBIDDEN.has(cl));\n\n\t\t\tif (!hasFlex && offendingForbidden.length === 0) return;\n\n\t\t\tif (hasFlex && hasFlexRow) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex, flex-row' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlex && hasFlexCol) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex, flex-col' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex' && cl !== 'flex-col' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlexCol && !hasFlex) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex-col' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex-col' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlex && !hasFlexCol) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'flexOnly',\n\t\t\t\t\tdata: { cls: 'flex' },\n\t\t\t\t\tsuggest: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessageId: 'flexOnly',\n\t\t\t\t\t\t\tdata: { cls: 'flex' },\n\t\t\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\t\t\tconst replacedClasses = classes.map((cl) => (cl === 'flex' ? 'flex-row' : cl));\n\t\t\t\t\t\t\t\tconst finalClasses = replacedClasses.join(' ');\n\t\t\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (offendingForbidden.length > 0) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: offendingForbidden.join(', ') },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tJSXAttribute(attr) {\n\t\t\t\tif (attr.name.type !== 'JSXIdentifier' || attr.name.name !== 'className') return;\n\n\t\t\t\tif (attr.value?.type === 'Literal' && typeof attr.value.value === 'string') {\n\t\t\t\t\treportAndFix(attr.value, attr.value.value, attr.value.raw);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tattr.value?.type === 'JSXExpressionContainer' &&\n\t\t\t\t\tattr.value.expression.type === 'Literal' &&\n\t\t\t\t\ttypeof attr.value.expression.value === 'string'\n\t\t\t\t)\n\t\t\t\t\treportAndFix(attr.value.expression, attr.value.expression.value, attr.value.expression.raw);\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-native-tailwind',\n\t},\n\trules: {\n\t\t'class-name-rules': classNameRules,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,4BAAY,IAAI,IAAI,CAAC,UAAU,CAAC;AAEtC,MAAM,iBAAiB,WAAW;CACjC,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,kDACd;EACA,SAAS;EACT,UAAU;GACT,WAAW;GACX,UAAU;EACX;EACA,gBAAgB;CACjB;CACA,WAAW,SAAS;EACnB,SAAS,aAAa,MAAmB,MAAc,KAAoB;GAC1E,MAAM,UAAU,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK;GACvC,MAAM,UAAU,QAAQ,SAAS,MAAM;GACvC,MAAM,aAAa,QAAQ,SAAS,UAAU;GAC9C,MAAM,aAAa,QAAQ,SAAS,UAAU;GAC9C,MAAM,qBAAqB,QAAQ,QAAQ,OAAO,UAAU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,KAAK,OAAO;KACpB,SAAS,CACR;MACC,WAAW;MACX,MAAM,EAAE,KAAK,OAAO;MACpB,IAAI,OAAO;OAEV,MAAM,eADkB,QAAQ,KAAK,OAAQ,OAAO,SAAS,aAAa,EACvC,CAAC,CAAC,KAAK,GAAG;OAC7C,MAAM,SAAS,OAAO,KAAG,CAAE,WAAW,GAAG,IAAI,MAAM;OACnD,OAAO,MAAM,YAAY,MAAM,GAAG,QAAQ,eAAe,OAAO;MACjE;KACD,CACD;IACD,CAAC;IACD;GACD;GAEA,IAAI,mBAAmB,SAAS,GAC/B,QAAQ,OAAO;IACd;IACA,WAAW;IACX,MAAM,EAAE,KAAK,mBAAmB,KAAK,IAAI,EAAE;IAC3C,IAAI,OAAO;KAEV,MAAM,eADO,QAAQ,QAAQ,OAAO,CAAC,UAAU,IAAI,EAAE,CAC7B,CAAC,CAAC,KAAK,GAAG;KAClC,MAAM,SAAS,OAAO,KAAG,CAAE,WAAW,GAAG,IAAI,MAAM;KACnD,OAAO,MAAM,YAAY,MAAM,GAAG,QAAQ,eAAe,OAAO;IACjE;GACD,CAAC;EAEH;EAEA,OAAO,EACN,aAAa,MAAM;GAClB,IAAI,KAAK,KAAK,SAAS,mBAAmB,KAAK,KAAK,SAAS,aAAa;GAE1E,IAAI,KAAK,OAAO,SAAS,aAAa,OAAO,KAAK,MAAM,UAAU,UAAU;IAC3E,aAAa,KAAK,OAAO,KAAK,MAAM,OAAO,KAAK,MAAM,GAAG;IACzD;GACD;GAEA,IACC,KAAK,OAAO,SAAS,4BACrB,KAAK,MAAM,WAAW,SAAS,aAC/B,OAAO,KAAK,MAAM,WAAW,UAAU,UAEvC,aAAa,KAAK,MAAM,YAAY,KAAK,MAAM,WAAW,OAAO,KAAK,MAAM,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"native-tailwind.js","names":[],"sources":["../../src/plugins/native-tailwind.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst FORBIDDEN = new Set(['flex-col']);\n\nconst classNameRules = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow Tailwind flex-col, and standalone flex',\n\t\t},\n\t\tfixable: 'code',\n\t\tmessages: {\n\t\t\tforbidden: \"Class '{{cls}}' is the default in react-native, so no need to explicitly set it.\",\n\t\t\tflexOnly: \"Class 'flex' should be removed or changed to 'flex-row' for explicit direction.\",\n\t\t},\n\t\thasSuggestions: true,\n\t},\n\tcreateOnce(context) {\n\t\tfunction reportAndFix(node: ESTree.Node, text: string, raw: string | null) {\n\t\t\tconst classes = text.trim().split(/\\s+/);\n\t\t\tconst hasFlex = classes.includes('flex');\n\t\t\tconst hasFlexCol = classes.includes('flex-col');\n\t\t\tconst hasFlexRow = classes.includes('flex-row');\n\t\t\tconst offendingForbidden = classes.filter((cl) => FORBIDDEN.has(cl));\n\n\t\t\tif (!hasFlex && offendingForbidden.length === 0) return;\n\n\t\t\tif (hasFlex && hasFlexRow) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex, flex-row' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlex && hasFlexCol) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex, flex-col' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex' && cl !== 'flex-col' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlexCol && !hasFlex) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex-col' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex-col' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlex && !hasFlexCol) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'flexOnly',\n\t\t\t\t\tdata: { cls: 'flex' },\n\t\t\t\t\tsuggest: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessageId: 'flexOnly',\n\t\t\t\t\t\t\tdata: { cls: 'flex' },\n\t\t\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\t\t\tconst replacedClasses = classes.map((cl) => (cl === 'flex' ? 'flex-row' : cl));\n\t\t\t\t\t\t\t\tconst finalClasses = replacedClasses.join(' ');\n\t\t\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (offendingForbidden.length > 0) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: offendingForbidden.join(', ') },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tJSXAttribute(attr) {\n\t\t\t\tif (attr.name.type !== 'JSXIdentifier' || attr.name.name !== 'className') return;\n\n\t\t\t\tif (attr.value?.type === 'Literal' && typeof attr.value.value === 'string') {\n\t\t\t\t\treportAndFix(attr.value, attr.value.value, attr.value.raw);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tattr.value?.type === 'JSXExpressionContainer' &&\n\t\t\t\t\tattr.value.expression.type === 'Literal' &&\n\t\t\t\t\ttypeof attr.value.expression.value === 'string'\n\t\t\t\t) {\n\t\t\t\t\treportAndFix(attr.value.expression, attr.value.expression.value, attr.value.expression.raw);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-native-tailwind',\n\t},\n\trules: {\n\t\t'class-name-rules': classNameRules,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,4BAAY,IAAI,IAAI,CAAC,UAAU,CAAC;AAEtC,MAAM,iBAAiB,WAAW;CACjC,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,kDACd;EACA,SAAS;EACT,UAAU;GACT,WAAW;GACX,UAAU;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OAAO,SAAS,4BACrB,KAAK,MAAM,WAAW,SAAS,aAC/B,OAAO,KAAK,MAAM,WAAW,UAAU,UAEvC,aAAa,KAAK,MAAM,YAAY,KAAK,MAAM,WAAW,OAAO,KAAK,MAAM,WAAW,GAAG;EAE5F,EACD;CACD;AACD,CAAC;AAED,8BAAe,aAAa;CAC3B,MAAM,EACL,MAAM,sCACP;CACA,OAAO,EACN,oBAAoB,eACrB;AACD,CAAC"}
|
package/dist/plugins/nest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest.js","names":[],"sources":["../../src/plugins/nest.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst DEFAULT_LOCALE = 'en-US';\n\nfunction isSortable(
|
|
1
|
+
{"version":3,"file":"nest.js","names":[],"sources":["../../src/plugins/nest.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst DEFAULT_LOCALE = 'en-US';\n\nfunction isSortable(\n\tnode: ESTree.ArrayExpressionElement,\n): node is ESTree.CallExpression | ESTree.IdentifierName | ESTree.IdentifierReference {\n\treturn node?.type === 'Identifier' || node?.type === 'CallExpression';\n}\n\nfunction nodeName(node: ESTree.CallExpression | ESTree.IdentifierName | ESTree.IdentifierReference) {\n\tif (node.type === 'Identifier') return node.name;\n\tif (node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier') {\n\t\treturn node.callee.object.name;\n\t}\n\treturn '';\n}\n\nfunction isFactoryProviderInjectArray(node: ESTree.ArrayExpression) {\n\tif (node.parent.type !== 'Property') return false;\n\tconst property = node.parent;\n\tif (property.key.type !== 'Identifier' || property.key.name !== 'inject') return false;\n\tif (property.parent.type !== 'ObjectExpression') return false;\n\treturn property.parent.properties.some(\n\t\t(item) => item.type === 'Property' && item.key.type === 'Identifier' && item.key.name === 'useFactory',\n\t);\n}\n\nconst sortModuleMetadataArrays = defineRule({\n\tmeta: {\n\t\ttype: 'suggestion',\n\t\tdocs: {\n\t\t\tdescription: 'Ensure Module metadata arrays are sorted alphabetically',\n\t\t},\n\t\tfixable: 'code',\n\t\tschema: [\n\t\t\t{\n\t\t\t\ttype: 'object',\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tproperties: {\n\t\t\t\t\tlocale: { type: 'string' },\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tmessages: {\n\t\t\tmoduleMetadataArraysAreSorted: '`Module` metadata arrays should be sorted in ASC alphabetical order',\n\t\t},\n\t\tdefaultOptions: [{ locale: DEFAULT_LOCALE }],\n\t},\n\tcreateOnce(context) {\n\t\tlet locale = DEFAULT_LOCALE;\n\t\treturn {\n\t\t\tbefore() {\n\t\t\t\tconst options = context.options[0] as { locale?: string } | undefined;\n\t\t\t\tlocale = options?.locale ?? DEFAULT_LOCALE;\n\t\t\t},\n\t\t\t'ClassDeclaration > Decorator[expression.callee.name=\"Module\"] Property > ArrayExpression'(node) {\n\t\t\t\tif (node.type !== 'ArrayExpression') return;\n\t\t\t\tif (isFactoryProviderInjectArray(node)) return;\n\t\t\t\tconst sortable = node.elements.filter(isSortable);\n\t\t\t\tconst sorted = sortable.toSorted((left, right) => nodeName(left).localeCompare(nodeName(right), locale));\n\t\t\t\tif (sortable.every((element, index) => element === sorted[index])) return;\n\t\t\t\tconst texts = sorted.map((element) => context.sourceCode.getText(element));\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'moduleMetadataArraysAreSorted',\n\t\t\t\t\tfix: (fixer) => sortable.map((element, index) => fixer.replaceText(element, texts[index] ?? '')),\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-nest',\n\t},\n\trules: {\n\t\t'sort-module-metadata-arrays': sortModuleMetadataArrays,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,iBAAiB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AAO,MAAM,GAAG;IACnE,MAAM,QAAQ,OAAO,KAAK,YAAY,QAAQ,WAAW,QAAQ,OAAO,CAAC;IACzE,QAAQ,OAAO;KACd;KACA,WAAW;KACX,MAAM,UAAU,SAAS,KAAK,SAAS,UAAU,MAAM,YAAY,SAAS,MAAM,UAAU,EAAE,CAAC;IAChG,CAAC;GACF;EACD;CACD;AACD,CAAC;AAED,mBAAe,aAAa;CAC3B,MAAM,EACL,MAAM,2BACP;CACA,OAAO,EACN,+BAA+B,yBAChC;AACD,CAAC"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/react.ts
|
|
4
|
+
const REL_TAGS = /* @__PURE__ */ new Set([
|
|
5
|
+
"a",
|
|
6
|
+
"area",
|
|
7
|
+
"form",
|
|
8
|
+
"link"
|
|
9
|
+
]);
|
|
10
|
+
const REL_VALUES = /* @__PURE__ */ new Map([
|
|
11
|
+
["alternate", /* @__PURE__ */ new Set([
|
|
12
|
+
"link",
|
|
13
|
+
"area",
|
|
14
|
+
"a"
|
|
15
|
+
])],
|
|
16
|
+
["apple-touch-icon", /* @__PURE__ */ new Set(["link"])],
|
|
17
|
+
["apple-touch-startup-image", /* @__PURE__ */ new Set(["link"])],
|
|
18
|
+
["author", /* @__PURE__ */ new Set([
|
|
19
|
+
"link",
|
|
20
|
+
"area",
|
|
21
|
+
"a"
|
|
22
|
+
])],
|
|
23
|
+
["bookmark", /* @__PURE__ */ new Set(["area", "a"])],
|
|
24
|
+
["canonical", /* @__PURE__ */ new Set(["link"])],
|
|
25
|
+
["dns-prefetch", /* @__PURE__ */ new Set(["link"])],
|
|
26
|
+
["external", /* @__PURE__ */ new Set([
|
|
27
|
+
"area",
|
|
28
|
+
"a",
|
|
29
|
+
"form"
|
|
30
|
+
])],
|
|
31
|
+
["help", /* @__PURE__ */ new Set([
|
|
32
|
+
"link",
|
|
33
|
+
"area",
|
|
34
|
+
"a",
|
|
35
|
+
"form"
|
|
36
|
+
])],
|
|
37
|
+
["icon", /* @__PURE__ */ new Set(["link"])],
|
|
38
|
+
["license", /* @__PURE__ */ new Set([
|
|
39
|
+
"link",
|
|
40
|
+
"area",
|
|
41
|
+
"a",
|
|
42
|
+
"form"
|
|
43
|
+
])],
|
|
44
|
+
["manifest", /* @__PURE__ */ new Set(["link"])],
|
|
45
|
+
["mask-icon", /* @__PURE__ */ new Set(["link"])],
|
|
46
|
+
["modulepreload", /* @__PURE__ */ new Set(["link"])],
|
|
47
|
+
["next", /* @__PURE__ */ new Set([
|
|
48
|
+
"link",
|
|
49
|
+
"area",
|
|
50
|
+
"a",
|
|
51
|
+
"form"
|
|
52
|
+
])],
|
|
53
|
+
["nofollow", /* @__PURE__ */ new Set([
|
|
54
|
+
"area",
|
|
55
|
+
"a",
|
|
56
|
+
"form"
|
|
57
|
+
])],
|
|
58
|
+
["noopener", /* @__PURE__ */ new Set([
|
|
59
|
+
"area",
|
|
60
|
+
"a",
|
|
61
|
+
"form"
|
|
62
|
+
])],
|
|
63
|
+
["noreferrer", /* @__PURE__ */ new Set([
|
|
64
|
+
"area",
|
|
65
|
+
"a",
|
|
66
|
+
"form"
|
|
67
|
+
])],
|
|
68
|
+
["opener", /* @__PURE__ */ new Set([
|
|
69
|
+
"area",
|
|
70
|
+
"a",
|
|
71
|
+
"form"
|
|
72
|
+
])],
|
|
73
|
+
["pingback", /* @__PURE__ */ new Set(["link"])],
|
|
74
|
+
["preconnect", /* @__PURE__ */ new Set(["link"])],
|
|
75
|
+
["prefetch", /* @__PURE__ */ new Set(["link"])],
|
|
76
|
+
["preload", /* @__PURE__ */ new Set(["link"])],
|
|
77
|
+
["prerender", /* @__PURE__ */ new Set(["link"])],
|
|
78
|
+
["prev", /* @__PURE__ */ new Set([
|
|
79
|
+
"link",
|
|
80
|
+
"area",
|
|
81
|
+
"a",
|
|
82
|
+
"form"
|
|
83
|
+
])],
|
|
84
|
+
["search", /* @__PURE__ */ new Set([
|
|
85
|
+
"link",
|
|
86
|
+
"area",
|
|
87
|
+
"a",
|
|
88
|
+
"form"
|
|
89
|
+
])],
|
|
90
|
+
["shortcut", /* @__PURE__ */ new Set(["link"])],
|
|
91
|
+
["shortcut icon", /* @__PURE__ */ new Set(["link"])],
|
|
92
|
+
["stylesheet", /* @__PURE__ */ new Set(["link"])],
|
|
93
|
+
["tag", /* @__PURE__ */ new Set(["area", "a"])]
|
|
94
|
+
]);
|
|
95
|
+
function isJsxSibling(node) {
|
|
96
|
+
return node.type === "JSXElement" || node.type === "JSXExpressionContainer";
|
|
97
|
+
}
|
|
98
|
+
function isFunction(node) {
|
|
99
|
+
return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
100
|
+
}
|
|
101
|
+
function attrName(attribute) {
|
|
102
|
+
if (attribute.name.type === "JSXIdentifier") return attribute.name.name;
|
|
103
|
+
return `${attribute.name.namespace.name}:${attribute.name.name.name}`;
|
|
104
|
+
}
|
|
105
|
+
function memberName(member) {
|
|
106
|
+
if (member.key.type === "Identifier") return member.key.name;
|
|
107
|
+
if (member.key.type === "Literal" && typeof member.key.value === "string") return member.key.value;
|
|
108
|
+
return "unknown";
|
|
109
|
+
}
|
|
110
|
+
function patternType(pattern) {
|
|
111
|
+
if (!("typeAnnotation" in pattern)) return void 0;
|
|
112
|
+
const annotation = pattern.typeAnnotation;
|
|
113
|
+
if (annotation === void 0 || annotation === null || typeof annotation !== "object") return void 0;
|
|
114
|
+
if (!("type" in annotation) || annotation.type !== "TSTypeAnnotation") return void 0;
|
|
115
|
+
return annotation.typeAnnotation;
|
|
116
|
+
}
|
|
117
|
+
function paramType(fn) {
|
|
118
|
+
if (fn.params.length === 0) return void 0;
|
|
119
|
+
const param = fn.params[0];
|
|
120
|
+
if (param.type === "TSParameterProperty") return patternType(param.parameter);
|
|
121
|
+
if (param.type === "RestElement") return void 0;
|
|
122
|
+
if (param.type === "AssignmentPattern") return patternType(param.left);
|
|
123
|
+
return patternType(param);
|
|
124
|
+
}
|
|
125
|
+
function unwrapType(type) {
|
|
126
|
+
let current = type;
|
|
127
|
+
while (current.type === "TSParenthesizedType") current = current.typeAnnotation;
|
|
128
|
+
return current;
|
|
129
|
+
}
|
|
130
|
+
function isReadonlyWrapper(type) {
|
|
131
|
+
return type.type === "TSTypeReference" && type.typeName.type === "Identifier" && type.typeName.name === "Readonly";
|
|
132
|
+
}
|
|
133
|
+
function enclosingFunction(node) {
|
|
134
|
+
let current = node.parent;
|
|
135
|
+
while (current) {
|
|
136
|
+
if (isFunction(current)) return current;
|
|
137
|
+
current = current.parent;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const jsxNewline = defineRule({
|
|
141
|
+
meta: {
|
|
142
|
+
type: "layout",
|
|
143
|
+
docs: { description: "Prevent blank lines between adjacent JSX siblings" },
|
|
144
|
+
fixable: "code",
|
|
145
|
+
messages: { prevent: "JSX element should not start in a new line" }
|
|
146
|
+
},
|
|
147
|
+
createOnce(context) {
|
|
148
|
+
function check(children) {
|
|
149
|
+
for (let index = 0; index < children.length - 2; index++) {
|
|
150
|
+
const current = children[index];
|
|
151
|
+
const between = children[index + 1];
|
|
152
|
+
const next = children[index + 2];
|
|
153
|
+
if (!isJsxSibling(current) || !isJsxSibling(next) || between.type !== "JSXText") continue;
|
|
154
|
+
if (!/\n\s*\n/.test(between.value)) continue;
|
|
155
|
+
context.report({
|
|
156
|
+
node: next,
|
|
157
|
+
messageId: "prevent",
|
|
158
|
+
fix(fixer) {
|
|
159
|
+
return fixer.replaceText(between, context.sourceCode.getText(between).replace(/\n\s*\n/, "\n"));
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
JSXElement(node) {
|
|
166
|
+
check(node.children);
|
|
167
|
+
},
|
|
168
|
+
JSXFragment(node) {
|
|
169
|
+
check(node.children);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const jsxSortProps = defineRule({
|
|
175
|
+
meta: {
|
|
176
|
+
type: "layout",
|
|
177
|
+
docs: { description: "Sort JSX props alphabetically" },
|
|
178
|
+
fixable: "code",
|
|
179
|
+
messages: { sortPropsByAlpha: "Props should be sorted alphabetically" }
|
|
180
|
+
},
|
|
181
|
+
createOnce(context) {
|
|
182
|
+
return { JSXOpeningElement(node) {
|
|
183
|
+
let group = [];
|
|
184
|
+
function flush() {
|
|
185
|
+
if (group.length < 2) {
|
|
186
|
+
group = [];
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const sorted = group.toSorted((left, right) => {
|
|
190
|
+
const leftName = attrName(left);
|
|
191
|
+
const rightName = attrName(right);
|
|
192
|
+
if (leftName === rightName) return 0;
|
|
193
|
+
return leftName < rightName ? -1 : 1;
|
|
194
|
+
});
|
|
195
|
+
if (group.every((attribute, index) => attribute === sorted[index])) {
|
|
196
|
+
group = [];
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const texts = sorted.map((attribute) => context.sourceCode.getText(attribute));
|
|
200
|
+
context.report({
|
|
201
|
+
node: group[0],
|
|
202
|
+
messageId: "sortPropsByAlpha",
|
|
203
|
+
fix(fixer) {
|
|
204
|
+
return group.map((attribute, index) => fixer.replaceText(attribute, texts[index] ?? ""));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
group = [];
|
|
208
|
+
}
|
|
209
|
+
for (const attribute of node.attributes) {
|
|
210
|
+
if (attribute.type === "JSXSpreadAttribute") {
|
|
211
|
+
flush();
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
group.push(attribute);
|
|
215
|
+
}
|
|
216
|
+
flush();
|
|
217
|
+
} };
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const noInvalidHtmlAttribute = defineRule({
|
|
221
|
+
meta: {
|
|
222
|
+
type: "suggestion",
|
|
223
|
+
docs: { description: "Disallow invalid HTML rel attribute values" },
|
|
224
|
+
messages: {
|
|
225
|
+
emptyIsMeaningless: "An empty “rel” attribute is meaningless.",
|
|
226
|
+
neverValid: "“{{value}}” is never a valid “rel” attribute value.",
|
|
227
|
+
notAlone: "“shortcut” must be directly followed by “icon”.",
|
|
228
|
+
notValidFor: "“{{value}}” is not a valid “rel” attribute value for <{{tag}}>.",
|
|
229
|
+
onlyMeaningfulFor: "The “rel” attribute only has meaning on the tags: \"<link>\", \"<a>\", \"<area>\", \"<form>\""
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
createOnce(context) {
|
|
233
|
+
return { JSXAttribute(node) {
|
|
234
|
+
if (node.name.type !== "JSXIdentifier" || node.name.name !== "rel") return;
|
|
235
|
+
if (node.parent.type !== "JSXOpeningElement" || node.parent.name.type !== "JSXIdentifier") return;
|
|
236
|
+
const tag = node.parent.name.name;
|
|
237
|
+
if (tag !== tag.toLowerCase()) return;
|
|
238
|
+
if (!REL_TAGS.has(tag)) {
|
|
239
|
+
context.report({
|
|
240
|
+
node: node.name,
|
|
241
|
+
messageId: "onlyMeaningfulFor"
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (node.value === null) {
|
|
246
|
+
context.report({
|
|
247
|
+
node: node.name,
|
|
248
|
+
messageId: "emptyIsMeaningless"
|
|
249
|
+
});
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
let literal;
|
|
253
|
+
if (node.value.type === "Literal" && typeof node.value.value === "string") literal = node.value;
|
|
254
|
+
if (node.value.type === "JSXExpressionContainer" && node.value.expression.type === "Literal" && typeof node.value.expression.value === "string") literal = node.value.expression;
|
|
255
|
+
if (literal === void 0) return;
|
|
256
|
+
if (!literal.value.trim()) {
|
|
257
|
+
context.report({
|
|
258
|
+
node: literal,
|
|
259
|
+
messageId: "emptyIsMeaningless"
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const values = literal.value.trim().split(/\s+/);
|
|
264
|
+
for (const value of values) {
|
|
265
|
+
const allowed = REL_VALUES.get(value);
|
|
266
|
+
if (allowed === void 0) {
|
|
267
|
+
context.report({
|
|
268
|
+
node: literal,
|
|
269
|
+
messageId: "neverValid",
|
|
270
|
+
data: { value }
|
|
271
|
+
});
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (!allowed.has(tag)) context.report({
|
|
275
|
+
node: literal,
|
|
276
|
+
messageId: "notValidFor",
|
|
277
|
+
data: {
|
|
278
|
+
value,
|
|
279
|
+
tag
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
if (values.includes("shortcut") && !values.includes("icon")) context.report({
|
|
284
|
+
node: literal,
|
|
285
|
+
messageId: "notAlone"
|
|
286
|
+
});
|
|
287
|
+
} };
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const preferReadOnlyProps = defineRule({
|
|
291
|
+
meta: {
|
|
292
|
+
type: "suggestion",
|
|
293
|
+
docs: { description: "Require component props type members to be readonly" },
|
|
294
|
+
fixable: "code",
|
|
295
|
+
messages: { readOnlyProp: "Prop '{{name}}' should be read-only." }
|
|
296
|
+
},
|
|
297
|
+
createOnce(context) {
|
|
298
|
+
const types = /* @__PURE__ */ new Map();
|
|
299
|
+
const jsxFns = /* @__PURE__ */ new Set();
|
|
300
|
+
function checkMembers(members) {
|
|
301
|
+
for (const member of members) {
|
|
302
|
+
if (member.type !== "TSPropertySignature" || member.readonly) continue;
|
|
303
|
+
context.report({
|
|
304
|
+
node: member,
|
|
305
|
+
messageId: "readOnlyProp",
|
|
306
|
+
data: { name: memberName(member) },
|
|
307
|
+
fix(fixer) {
|
|
308
|
+
return fixer.insertTextBefore(member, "readonly ");
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function checkType(type, seen = /* @__PURE__ */ new Set()) {
|
|
314
|
+
const current = unwrapType(type);
|
|
315
|
+
if (isReadonlyWrapper(current)) return;
|
|
316
|
+
if (current.type === "TSTypeLiteral") {
|
|
317
|
+
checkMembers(current.members);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (current.type === "TSIntersectionType") {
|
|
321
|
+
for (const item of current.types) checkType(item, seen);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (current.type !== "TSTypeReference" || current.typeName.type !== "Identifier") return;
|
|
325
|
+
const name = current.typeName.name;
|
|
326
|
+
if (seen.has(name)) return;
|
|
327
|
+
seen.add(name);
|
|
328
|
+
const resolved = types.get(name);
|
|
329
|
+
if (resolved === void 0) return;
|
|
330
|
+
if (resolved.type === "TSInterfaceBody") checkMembers(resolved.body);
|
|
331
|
+
else checkType(resolved, seen);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
TSTypeAliasDeclaration(node) {
|
|
335
|
+
types.set(node.id.name, node.typeAnnotation);
|
|
336
|
+
},
|
|
337
|
+
TSInterfaceDeclaration(node) {
|
|
338
|
+
types.set(node.id.name, node.body);
|
|
339
|
+
},
|
|
340
|
+
JSXElement(node) {
|
|
341
|
+
const fn = enclosingFunction(node);
|
|
342
|
+
if (fn) jsxFns.add(fn);
|
|
343
|
+
},
|
|
344
|
+
JSXFragment(node) {
|
|
345
|
+
const fn = enclosingFunction(node);
|
|
346
|
+
if (fn) jsxFns.add(fn);
|
|
347
|
+
},
|
|
348
|
+
"Program:exit"() {
|
|
349
|
+
for (const fn of jsxFns) {
|
|
350
|
+
const type = paramType(fn);
|
|
351
|
+
if (type) checkType(type);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
var react_default = definePlugin({
|
|
358
|
+
meta: { name: "eslint-plugin-mahir-react" },
|
|
359
|
+
rules: {
|
|
360
|
+
"jsx-newline": jsxNewline,
|
|
361
|
+
"jsx-sort-props": jsxSortProps,
|
|
362
|
+
"no-invalid-html-attribute": noInvalidHtmlAttribute,
|
|
363
|
+
"prefer-read-only-props": preferReadOnlyProps
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
//#endregion
|
|
368
|
+
export { react_default as default };
|
|
369
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","names":[],"sources":["../../src/plugins/react.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst REL_TAGS = new Set(['a', 'area', 'form', 'link']);\n\nconst REL_VALUES = new Map<string, Set<string>>([\n\t['alternate', new Set(['link', 'area', 'a'])],\n\t['apple-touch-icon', new Set(['link'])],\n\t['apple-touch-startup-image', new Set(['link'])],\n\t['author', new Set(['link', 'area', 'a'])],\n\t['bookmark', new Set(['area', 'a'])],\n\t['canonical', new Set(['link'])],\n\t['dns-prefetch', new Set(['link'])],\n\t['external', new Set(['area', 'a', 'form'])],\n\t['help', new Set(['link', 'area', 'a', 'form'])],\n\t['icon', new Set(['link'])],\n\t['license', new Set(['link', 'area', 'a', 'form'])],\n\t['manifest', new Set(['link'])],\n\t['mask-icon', new Set(['link'])],\n\t['modulepreload', new Set(['link'])],\n\t['next', new Set(['link', 'area', 'a', 'form'])],\n\t['nofollow', new Set(['area', 'a', 'form'])],\n\t['noopener', new Set(['area', 'a', 'form'])],\n\t['noreferrer', new Set(['area', 'a', 'form'])],\n\t['opener', new Set(['area', 'a', 'form'])],\n\t['pingback', new Set(['link'])],\n\t['preconnect', new Set(['link'])],\n\t['prefetch', new Set(['link'])],\n\t['preload', new Set(['link'])],\n\t['prerender', new Set(['link'])],\n\t['prev', new Set(['link', 'area', 'a', 'form'])],\n\t['search', new Set(['link', 'area', 'a', 'form'])],\n\t['shortcut', new Set(['link'])],\n\t['shortcut icon', new Set(['link'])],\n\t['stylesheet', new Set(['link'])],\n\t['tag', new Set(['area', 'a'])],\n]);\n\nfunction isJsxSibling(node: ESTree.JSXChild) {\n\treturn node.type === 'JSXElement' || node.type === 'JSXExpressionContainer';\n}\n\nfunction isFunction(node: ESTree.Node): node is ESTree.Function | ESTree.ArrowFunctionExpression {\n\treturn (\n\t\tnode.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression'\n\t);\n}\n\nfunction attrName(attribute: ESTree.JSXAttribute) {\n\tif (attribute.name.type === 'JSXIdentifier') return attribute.name.name;\n\treturn `${attribute.name.namespace.name}:${attribute.name.name.name}`;\n}\n\nfunction memberName(member: ESTree.TSPropertySignature) {\n\tif (member.key.type === 'Identifier') return member.key.name;\n\tif (member.key.type === 'Literal' && typeof member.key.value === 'string') return member.key.value;\n\treturn 'unknown';\n}\n\nfunction patternType(pattern: ESTree.Node): ESTree.TSType | undefined {\n\tif (!('typeAnnotation' in pattern)) return undefined;\n\tconst annotation = pattern.typeAnnotation;\n\tif (annotation === undefined || annotation === null || typeof annotation !== 'object') return undefined;\n\tif (!('type' in annotation) || annotation.type !== 'TSTypeAnnotation') return undefined;\n\treturn annotation.typeAnnotation;\n}\n\nfunction paramType(fn: ESTree.Function | ESTree.ArrowFunctionExpression) {\n\tif (fn.params.length === 0) return undefined;\n\tconst param = fn.params[0];\n\tif (param.type === 'TSParameterProperty') return patternType(param.parameter);\n\tif (param.type === 'RestElement') return undefined;\n\tif (param.type === 'AssignmentPattern') return patternType(param.left);\n\treturn patternType(param);\n}\n\nfunction unwrapType(type: ESTree.TSType): ESTree.TSType {\n\tlet current = type;\n\twhile (current.type === 'TSParenthesizedType') current = current.typeAnnotation;\n\treturn current;\n}\n\nfunction isReadonlyWrapper(type: ESTree.TSType) {\n\treturn type.type === 'TSTypeReference' && type.typeName.type === 'Identifier' && type.typeName.name === 'Readonly';\n}\n\nfunction enclosingFunction(node: ESTree.Node) {\n\tlet current: ESTree.Node | null | undefined = node.parent;\n\twhile (current) {\n\t\tif (isFunction(current)) return current;\n\t\tcurrent = current.parent;\n\t}\n\treturn undefined;\n}\n\nconst jsxNewline = defineRule({\n\tmeta: {\n\t\ttype: 'layout',\n\t\tdocs: {\n\t\t\tdescription: 'Prevent blank lines between adjacent JSX siblings',\n\t\t},\n\t\tfixable: 'code',\n\t\tmessages: {\n\t\t\tprevent: 'JSX element should not start in a new line',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\tfunction check(children: ESTree.JSXChild[]) {\n\t\t\tfor (let index = 0; index < children.length - 2; index++) {\n\t\t\t\tconst current = children[index];\n\t\t\t\tconst between = children[index + 1];\n\t\t\t\tconst next = children[index + 2];\n\t\t\t\tif (!isJsxSibling(current) || !isJsxSibling(next) || between.type !== 'JSXText') continue;\n\t\t\t\tif (!/\\n\\s*\\n/.test(between.value)) continue;\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: next,\n\t\t\t\t\tmessageId: 'prevent',\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\treturn fixer.replaceText(between, context.sourceCode.getText(between).replace(/\\n\\s*\\n/, '\\n'));\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tJSXElement(node) {\n\t\t\t\tcheck(node.children);\n\t\t\t},\n\t\t\tJSXFragment(node) {\n\t\t\t\tcheck(node.children);\n\t\t\t},\n\t\t};\n\t},\n});\n\nconst jsxSortProps = defineRule({\n\tmeta: {\n\t\ttype: 'layout',\n\t\tdocs: {\n\t\t\tdescription: 'Sort JSX props alphabetically',\n\t\t},\n\t\tfixable: 'code',\n\t\tmessages: {\n\t\t\tsortPropsByAlpha: 'Props should be sorted alphabetically',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\treturn {\n\t\t\tJSXOpeningElement(node) {\n\t\t\t\tlet group: ESTree.JSXAttribute[] = [];\n\t\t\t\tfunction flush() {\n\t\t\t\t\tif (group.length < 2) {\n\t\t\t\t\t\tgroup = [];\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst sorted = group.toSorted((left, right) => {\n\t\t\t\t\t\tconst leftName = attrName(left);\n\t\t\t\t\t\tconst rightName = attrName(right);\n\t\t\t\t\t\tif (leftName === rightName) return 0;\n\t\t\t\t\t\treturn leftName < rightName ? -1 : 1;\n\t\t\t\t\t});\n\t\t\t\t\tif (group.every((attribute, index) => attribute === sorted[index])) {\n\t\t\t\t\t\tgroup = [];\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst texts = sorted.map((attribute) => context.sourceCode.getText(attribute));\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: group[0],\n\t\t\t\t\t\tmessageId: 'sortPropsByAlpha',\n\t\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\t\treturn group.map((attribute, index) => fixer.replaceText(attribute, texts[index] ?? ''));\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\tgroup = [];\n\t\t\t\t}\n\t\t\t\tfor (const attribute of node.attributes) {\n\t\t\t\t\tif (attribute.type === 'JSXSpreadAttribute') {\n\t\t\t\t\t\tflush();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tgroup.push(attribute);\n\t\t\t\t}\n\t\t\t\tflush();\n\t\t\t},\n\t\t};\n\t},\n});\n\nconst noInvalidHtmlAttribute = defineRule({\n\tmeta: {\n\t\ttype: 'suggestion',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow invalid HTML rel attribute values',\n\t\t},\n\t\tmessages: {\n\t\t\temptyIsMeaningless: 'An empty “rel” attribute is meaningless.',\n\t\t\tneverValid: '“{{value}}” is never a valid “rel” attribute value.',\n\t\t\tnotAlone: '“shortcut” must be directly followed by “icon”.',\n\t\t\tnotValidFor: '“{{value}}” is not a valid “rel” attribute value for <{{tag}}>.',\n\t\t\tonlyMeaningfulFor: 'The “rel” attribute only has meaning on the tags: \"<link>\", \"<a>\", \"<area>\", \"<form>\"',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\treturn {\n\t\t\tJSXAttribute(node) {\n\t\t\t\tif (node.name.type !== 'JSXIdentifier' || node.name.name !== 'rel') return;\n\t\t\t\tif (node.parent.type !== 'JSXOpeningElement' || node.parent.name.type !== 'JSXIdentifier') return;\n\t\t\t\tconst tag = node.parent.name.name;\n\t\t\t\tif (tag !== tag.toLowerCase()) return;\n\t\t\t\tif (!REL_TAGS.has(tag)) {\n\t\t\t\t\tcontext.report({ node: node.name, messageId: 'onlyMeaningfulFor' });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (node.value === null) {\n\t\t\t\t\tcontext.report({ node: node.name, messageId: 'emptyIsMeaningless' });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet literal: ESTree.StringLiteral | undefined;\n\t\t\t\tif (node.value.type === 'Literal' && typeof node.value.value === 'string') literal = node.value;\n\t\t\t\tif (\n\t\t\t\t\tnode.value.type === 'JSXExpressionContainer' &&\n\t\t\t\t\tnode.value.expression.type === 'Literal' &&\n\t\t\t\t\ttypeof node.value.expression.value === 'string'\n\t\t\t\t) {\n\t\t\t\t\tliteral = node.value.expression;\n\t\t\t\t}\n\t\t\t\tif (literal === undefined) return;\n\t\t\t\tif (!literal.value.trim()) {\n\t\t\t\t\tcontext.report({ node: literal, messageId: 'emptyIsMeaningless' });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst values = literal.value.trim().split(/\\s+/);\n\t\t\t\tfor (const value of values) {\n\t\t\t\t\tconst allowed = REL_VALUES.get(value);\n\t\t\t\t\tif (allowed === undefined) {\n\t\t\t\t\t\tcontext.report({ node: literal, messageId: 'neverValid', data: { value } });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!allowed.has(tag)) {\n\t\t\t\t\t\tcontext.report({ node: literal, messageId: 'notValidFor', data: { value, tag } });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (values.includes('shortcut') && !values.includes('icon')) {\n\t\t\t\t\tcontext.report({ node: literal, messageId: 'notAlone' });\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nconst preferReadOnlyProps = defineRule({\n\tmeta: {\n\t\ttype: 'suggestion',\n\t\tdocs: {\n\t\t\tdescription: 'Require component props type members to be readonly',\n\t\t},\n\t\tfixable: 'code',\n\t\tmessages: {\n\t\t\treadOnlyProp: \"Prop '{{name}}' should be read-only.\",\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\tconst types = new Map<string, ESTree.TSType | ESTree.TSInterfaceBody>();\n\t\tconst jsxFns = new Set<ESTree.Function | ESTree.ArrowFunctionExpression>();\n\t\tfunction checkMembers(members: ESTree.TSSignature[]) {\n\t\t\tfor (const member of members) {\n\t\t\t\tif (member.type !== 'TSPropertySignature' || member.readonly) continue;\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode: member,\n\t\t\t\t\tmessageId: 'readOnlyProp',\n\t\t\t\t\tdata: { name: memberName(member) },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\treturn fixer.insertTextBefore(member, 'readonly ');\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfunction checkType(type: ESTree.TSType, seen = new Set<string>()) {\n\t\t\tconst current = unwrapType(type);\n\t\t\tif (isReadonlyWrapper(current)) return;\n\t\t\tif (current.type === 'TSTypeLiteral') {\n\t\t\t\tcheckMembers(current.members);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (current.type === 'TSIntersectionType') {\n\t\t\t\tfor (const item of current.types) checkType(item, seen);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (current.type !== 'TSTypeReference' || current.typeName.type !== 'Identifier') return;\n\t\t\tconst name = current.typeName.name;\n\t\t\tif (seen.has(name)) return;\n\t\t\tseen.add(name);\n\t\t\tconst resolved = types.get(name);\n\t\t\tif (resolved === undefined) return;\n\t\t\tif (resolved.type === 'TSInterfaceBody') checkMembers(resolved.body);\n\t\t\telse checkType(resolved, seen);\n\t\t}\n\t\treturn {\n\t\t\tTSTypeAliasDeclaration(node) {\n\t\t\t\ttypes.set(node.id.name, node.typeAnnotation);\n\t\t\t},\n\t\t\tTSInterfaceDeclaration(node) {\n\t\t\t\ttypes.set(node.id.name, node.body);\n\t\t\t},\n\t\t\tJSXElement(node) {\n\t\t\t\tconst fn = enclosingFunction(node);\n\t\t\t\tif (fn) jsxFns.add(fn);\n\t\t\t},\n\t\t\tJSXFragment(node) {\n\t\t\t\tconst fn = enclosingFunction(node);\n\t\t\t\tif (fn) jsxFns.add(fn);\n\t\t\t},\n\t\t\t'Program:exit'() {\n\t\t\t\tfor (const fn of jsxFns) {\n\t\t\t\t\tconst type = paramType(fn);\n\t\t\t\t\tif (type) checkType(type);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-react',\n\t},\n\trules: {\n\t\t'jsx-newline': jsxNewline,\n\t\t'jsx-sort-props': jsxSortProps,\n\t\t'no-invalid-html-attribute': noInvalidHtmlAttribute,\n\t\t'prefer-read-only-props': preferReadOnlyProps,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,2BAAW,IAAI,IAAI;CAAC;CAAK;CAAQ;CAAQ;AAAM,CAAC;AAEtD,MAAM,6BAAa,IAAI,IAAyB;CAC/C,CAAC,6BAAa,IAAI,IAAI;EAAC;EAAQ;EAAQ;CAAG,CAAC,CAAC;CAC5C,CAAC,oCAAoB,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;CACtC,CAAC,6CAA6B,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;CAC/C,CAAC,0BAAU,IAAI,IAAI;EAAC;EAAQ;EAAQ;CAAG,CAAC,CAAC;CACzC,CAAC,4BAAY,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;CACnC,CAAC,6BAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC,gCAAgB,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;CAClC,CAAC,4BAAY,IAAI,IAAI;EA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AAO,IAAI,EAAE;GACtB;GACA,iBAAiB;IAChB,KAAK,MAAM,MAAM,QAAQ;KACxB,MAAM,OAAO,UAAU,EAAE;KACzB,IAAI,MAAM,UAAU,IAAI;IACzB;GACD;EACD;CACD;AACD,CAAC;AAED,oBAAe,aAAa;CAC3B,MAAM,EACL,MAAM,4BACP;CACA,OAAO;EACN,eAAe;EACf,kBAAkB;EAClB,6BAA6B;EAC7B,0BAA0B;CAC3B;AACD,CAAC"}
|
|
@@ -14,7 +14,7 @@ function isAstNode(value) {
|
|
|
14
14
|
function pathValue(node, path) {
|
|
15
15
|
let current = node;
|
|
16
16
|
for (const part of path.split(".")) {
|
|
17
|
-
if (current
|
|
17
|
+
if (current === null || current === void 0 || typeof current !== "object") return void 0;
|
|
18
18
|
current = current[part];
|
|
19
19
|
}
|
|
20
20
|
return current;
|
|
@@ -24,7 +24,7 @@ function matchAttributes(node, attributes) {
|
|
|
24
24
|
const expression = attribute[1];
|
|
25
25
|
const equal = /^(.+?)=(?:'([^']*)'|"([^"]*)")$/.exec(expression);
|
|
26
26
|
if (!equal) return false;
|
|
27
|
-
if (String(pathValue(node, equal[1].trim())) !== (equal
|
|
27
|
+
if (String(pathValue(node, equal[1].trim())) !== (equal.at(2) ?? equal.at(3))) return false;
|
|
28
28
|
}
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
@@ -33,7 +33,7 @@ function matchSimple(node, simple) {
|
|
|
33
33
|
if (!type || node.type !== type) return false;
|
|
34
34
|
const not = /:not\((?<inner>[^)]*)\)/.exec(simple);
|
|
35
35
|
if (not?.groups?.inner && matchAttributes(node, not.groups.inner)) return false;
|
|
36
|
-
return matchAttributes(node, simple.
|
|
36
|
+
return matchAttributes(node, simple.replaceAll(/:not\([^)]*\)/g, ""));
|
|
37
37
|
}
|
|
38
38
|
function matchSelector(node, selector) {
|
|
39
39
|
const parts = selector.split(/\s*>\s*/);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restricted-syntax.js","names":[],"sources":["../../src/plugins/restricted-syntax.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\ntype Restriction =\n\t| string\n\t| {\n\t\t\tmessage?: string;\n\t\t\tselector: string;\n\t };\n\nfunction restrictionSelector(restriction: Restriction) {\n\treturn typeof restriction === 'string' ? restriction : restriction.selector;\n}\n\nfunction restrictionMessage(restriction: Restriction) {\n\tif (typeof restriction === 'string') return `Using '${restriction}' is not allowed.`;\n\treturn restriction.message ?? `Using '${restriction.selector}' is not allowed.`;\n}\n\nfunction isAstNode(value: unknown): value is ESTree.Node {\n\treturn typeof value === 'object' && value !== null && 'type' in value && typeof
|
|
1
|
+
{"version":3,"file":"restricted-syntax.js","names":[],"sources":["../../src/plugins/restricted-syntax.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\ntype Restriction =\n\t| string\n\t| {\n\t\t\tmessage?: string;\n\t\t\tselector: string;\n\t };\n\nfunction restrictionSelector(restriction: Restriction) {\n\treturn typeof restriction === 'string' ? restriction : restriction.selector;\n}\n\nfunction restrictionMessage(restriction: Restriction) {\n\tif (typeof restriction === 'string') return `Using '${restriction}' is not allowed.`;\n\treturn restriction.message ?? `Using '${restriction.selector}' is not allowed.`;\n}\n\nfunction isAstNode(value: unknown): value is ESTree.Node {\n\treturn typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string';\n}\n\nfunction pathValue(node: ESTree.Node, path: string) {\n\tlet current: unknown = node;\n\tfor (const part of path.split('.')) {\n\t\tif (current === null || current === undefined || typeof current !== 'object') return undefined;\n\t\tcurrent = (current as Record<string, unknown>)[part];\n\t}\n\treturn current;\n}\n\nfunction matchAttributes(node: ESTree.Node, attributes: string) {\n\tfor (const attribute of attributes.matchAll(/\\[([^\\]]+)\\]/g)) {\n\t\tconst expression = attribute[1];\n\t\tconst equal = /^(.+?)=(?:'([^']*)'|\"([^\"]*)\")$/.exec(expression);\n\t\tif (!equal) return false;\n\t\tif (String(pathValue(node, equal[1].trim())) !== (equal.at(2) ?? equal.at(3))) return false;\n\t}\n\treturn true;\n}\n\nfunction matchSimple(node: ESTree.Node, simple: string) {\n\tconst type = /^(?<type>[A-Za-z]+)/.exec(simple)?.groups?.type;\n\tif (!type || node.type !== type) return false;\n\tconst not = /:not\\((?<inner>[^)]*)\\)/.exec(simple);\n\tif (not?.groups?.inner && matchAttributes(node, not.groups.inner)) return false;\n\treturn matchAttributes(node, simple.replaceAll(/:not\\([^)]*\\)/g, ''));\n}\n\nfunction matchSelector(node: ESTree.Node, selector: string) {\n\tconst parts = selector.split(/\\s*>\\s*/);\n\tlet current: ESTree.Node | null | undefined = node;\n\tfor (let index = parts.length - 1; index >= 0; index--) {\n\t\tif (!current || !matchSimple(current, parts[index] ?? '')) return false;\n\t\tcurrent = index > 0 ? current.parent : current;\n\t}\n\treturn true;\n}\n\nfunction walk(node: ESTree.Node, visit: (current: ESTree.Node) => void, seen = new Set<ESTree.Node>()) {\n\tif (seen.has(node)) return;\n\tseen.add(node);\n\tvisit(node);\n\tfor (const key of Object.keys(node)) {\n\t\tif (key === 'parent' || key === 'loc' || key === 'range') continue;\n\t\tconst child = (node as unknown as Record<string, unknown>)[key];\n\t\tif (Array.isArray(child)) {\n\t\t\tfor (const item of child) if (isAstNode(item)) walk(item, visit, seen);\n\t\t} else if (isAstNode(child)) walk(child, visit, seen);\n\t}\n}\n\nconst noRestrictedSyntax = defineRule({\n\tmeta: {\n\t\ttype: 'suggestion',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow specified syntax via ESLint selectors',\n\t\t},\n\t\tschema: {\n\t\t\ttype: 'array',\n\t\t\titems: {\n\t\t\t\toneOf: [\n\t\t\t\t\t{ type: 'string', minLength: 1 },\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t\trequired: ['selector'],\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tselector: { type: 'string', minLength: 1 },\n\t\t\t\t\t\t\tmessage: { type: 'string', minLength: 1 },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tmessages: {\n\t\t\trestricted: '{{message}}',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\tlet restrictions: Restriction[] = [];\n\t\treturn {\n\t\t\tbefore() {\n\t\t\t\trestrictions = Array.isArray(context.options) ? [...(context.options as Restriction[])] : [];\n\t\t\t\treturn restrictions.length > 0;\n\t\t\t},\n\t\t\tProgram(program) {\n\t\t\t\twalk(program, (node) => {\n\t\t\t\t\tfor (const restriction of restrictions) {\n\t\t\t\t\t\tif (!matchSelector(node, restrictionSelector(restriction))) continue;\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'restricted',\n\t\t\t\t\t\t\tdata: { message: restrictionMessage(restriction) },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-restricted-syntax',\n\t},\n\trules: {\n\t\t'no-restricted-syntax': noRestrictedSyntax,\n\t},\n});\n"],"mappings":";;;AAWA,SAAS,oBAAoB,aAA0B;CACtD,OAAO,OAAO,gBAAgB,WAAW,cAAc,YAAY;AACpE;AAEA,SAAS,mBAAmB,aAA0B;CACrD,IAAI,OAAO,gBAAgB,UAAU,OAAO,UAAU,YAAY;CAClE,OAAO,YAAY,WAAW,UAAU,YAAY,SAAS;AAC9D;AAEA,SAAS,UAAU,OAAsC;CACxD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,OAAO,MAAM,SAAS;AAChG;AAEA,SAAS,UAAU,MAAmB,MAAc;CACnD,IAAI,UAAmB;CACvB,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG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
declare const config: {
|
|
3
|
-
extends: {
|
|
4
|
-
plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
|
|
5
|
-
jsPlugins: import("oxlint").ExternalPluginEntry[];
|
|
6
|
-
rules: import("oxlint").DummyRuleMap;
|
|
7
|
-
}[];
|
|
8
3
|
plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
|
|
9
4
|
jsPlugins: import("oxlint").ExternalPluginEntry[];
|
|
10
5
|
env: {
|
package/dist/react.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import config$1 from "./jsx.js";
|
|
1
|
+
import { localPlugin, nativePlugins } from "./config.js";
|
|
3
2
|
import { defineConfig } from "oxlint";
|
|
4
3
|
|
|
5
4
|
//#region src/react.ts
|
|
6
5
|
const config = defineConfig({
|
|
7
|
-
extends: [config$1],
|
|
8
6
|
plugins: nativePlugins,
|
|
9
|
-
jsPlugins: [
|
|
7
|
+
jsPlugins: [localPlugin("mahir-react", "./plugins/react.js")],
|
|
10
8
|
env: {
|
|
11
9
|
browser: true,
|
|
12
10
|
serviceworker: true
|
|
@@ -19,43 +17,59 @@ const config = defineConfig({
|
|
|
19
17
|
"react/purity": 2,
|
|
20
18
|
"react/refs": 2,
|
|
21
19
|
"react/set-state-in-render": 2,
|
|
22
|
-
"react-js/boolean-prop-naming": 2,
|
|
23
20
|
"react/button-has-type": 2,
|
|
24
21
|
"react/hook-use-state": 2,
|
|
25
22
|
"react/iframe-missing-sandbox": 2,
|
|
26
|
-
"react
|
|
27
|
-
"react
|
|
23
|
+
"react/jsx-boolean-value": [2, "never"],
|
|
24
|
+
"react/jsx-curly-brace-presence": [2, {
|
|
25
|
+
children: "never",
|
|
26
|
+
props: "never"
|
|
27
|
+
}],
|
|
28
|
+
"react/jsx-fragments": [2, "syntax"],
|
|
29
|
+
"react/jsx-key": [2, {
|
|
30
|
+
checkFragmentShorthand: true,
|
|
31
|
+
checkKeyMustBeforeSpread: true,
|
|
32
|
+
warnOnDuplicates: false
|
|
33
|
+
}],
|
|
34
|
+
"react/jsx-no-comment-textnodes": 2,
|
|
35
|
+
"react/jsx-no-constructed-context-values": 2,
|
|
36
|
+
"react/jsx-no-duplicate-props": 2,
|
|
37
|
+
"react/jsx-no-script-url": 2,
|
|
38
|
+
"react/jsx-no-undef": 2,
|
|
39
|
+
"react/jsx-no-useless-fragment": [2, { allowExpressions: true }],
|
|
40
|
+
"react/jsx-pascal-case": [2, { ignore: [
|
|
41
|
+
"h{}",
|
|
42
|
+
"h2",
|
|
43
|
+
"h3",
|
|
44
|
+
"h4",
|
|
45
|
+
"h5",
|
|
46
|
+
"h6",
|
|
47
|
+
"p",
|
|
48
|
+
"a",
|
|
49
|
+
"ul",
|
|
50
|
+
"ol",
|
|
51
|
+
"li",
|
|
52
|
+
"img",
|
|
53
|
+
"div",
|
|
54
|
+
"span",
|
|
55
|
+
"dl",
|
|
56
|
+
"dt",
|
|
57
|
+
"dd"
|
|
58
|
+
] }],
|
|
28
59
|
"react/no-children-prop": 2,
|
|
29
60
|
"react/no-danger": 2,
|
|
30
61
|
"react/no-danger-with-children": 2,
|
|
31
|
-
"react-js/no-deprecated": 2,
|
|
32
|
-
"react/no-did-mount-set-state": 2,
|
|
33
|
-
"react/no-did-update-set-state": 2,
|
|
34
|
-
"react/no-direct-mutation-state": 2,
|
|
35
62
|
"react/no-find-dom-node": 2,
|
|
36
|
-
"react-js/no-invalid-html-attribute": 2,
|
|
37
|
-
"react/no-is-mounted": 2,
|
|
38
63
|
"react/no-namespace": 2,
|
|
39
|
-
"react/no-redundant-should-component-update": 2,
|
|
40
64
|
"react/no-render-return-value": 2,
|
|
41
|
-
"react/no-set-state": 2,
|
|
42
|
-
"react/no-string-refs": 2,
|
|
43
|
-
"react/no-this-in-sfc": 2,
|
|
44
|
-
"react-js/no-typos": 2,
|
|
45
65
|
"react/no-unknown-property": 2,
|
|
46
|
-
"react/no-unsafe": 2,
|
|
47
66
|
"react/no-unstable-nested-components": 2,
|
|
48
|
-
"react
|
|
49
|
-
"react
|
|
50
|
-
"react/
|
|
51
|
-
"react/
|
|
52
|
-
"react
|
|
53
|
-
"
|
|
54
|
-
"react/require-render-return": 2,
|
|
55
|
-
"react-js/sort-comp": 2,
|
|
56
|
-
"react/state-in-constructor": [2, "always"],
|
|
57
|
-
"react-js/static-property-placement": 2,
|
|
58
|
-
"react/void-dom-elements-no-children": 2
|
|
67
|
+
"react/void-dom-elements-no-children": 2,
|
|
68
|
+
"mahir-react/jsx-newline": 2,
|
|
69
|
+
"mahir-react/jsx-sort-props": 2,
|
|
70
|
+
"mahir-react/no-invalid-html-attribute": 2,
|
|
71
|
+
"mahir-react/prefer-read-only-props": 2,
|
|
72
|
+
"unicorn/consistent-function-scoping": 0
|
|
59
73
|
}
|
|
60
74
|
});
|
|
61
75
|
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","names":[
|
|
1
|
+
{"version":3,"file":"react.js","names":[],"sources":["../src/react.ts"],"sourcesContent":["import { defineConfig } from 'oxlint';\n\nimport { localPlugin, nativePlugins } from './config.js';\n\nimport type { OxlintConfig } from 'oxlint';\n\nconst rules: NonNullable<OxlintConfig['rules']> = {\n\t'react/exhaustive-deps': 2,\n\t'react/rules-of-hooks': 2,\n\t'react/immutability': 2,\n\t'react/purity': 2,\n\t'react/refs': 2,\n\t'react/set-state-in-render': 2,\n\t'react/button-has-type': 2,\n\t'react/hook-use-state': 2,\n\t'react/iframe-missing-sandbox': 2,\n\t'react/jsx-boolean-value': [2, 'never'],\n\t'react/jsx-curly-brace-presence': [\n\t\t2,\n\t\t{\n\t\t\tchildren: 'never',\n\t\t\tprops: 'never',\n\t\t},\n\t],\n\t'react/jsx-fragments': [2, 'syntax'],\n\t'react/jsx-key': [\n\t\t2,\n\t\t{\n\t\t\tcheckFragmentShorthand: true,\n\t\t\tcheckKeyMustBeforeSpread: true,\n\t\t\twarnOnDuplicates: false,\n\t\t},\n\t],\n\t'react/jsx-no-comment-textnodes': 2,\n\t'react/jsx-no-constructed-context-values': 2,\n\t'react/jsx-no-duplicate-props': 2,\n\t'react/jsx-no-script-url': 2,\n\t'react/jsx-no-undef': 2,\n\t'react/jsx-no-useless-fragment': [\n\t\t2,\n\t\t{\n\t\t\tallowExpressions: true,\n\t\t},\n\t],\n\t'react/jsx-pascal-case': [\n\t\t2,\n\t\t{\n\t\t\tignore: ['h{}', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'a', 'ul', 'ol', 'li', 'img', 'div', 'span', 'dl', 'dt', 'dd'],\n\t\t},\n\t],\n\t'react/no-children-prop': 2,\n\t'react/no-danger': 2,\n\t'react/no-danger-with-children': 2,\n\t'react/no-find-dom-node': 2,\n\t'react/no-namespace': 2,\n\t'react/no-render-return-value': 2,\n\t'react/no-unknown-property': 2,\n\t'react/no-unstable-nested-components': 2,\n\t'react/void-dom-elements-no-children': 2,\n\t'mahir-react/jsx-newline': 2,\n\t'mahir-react/jsx-sort-props': 2,\n\t'mahir-react/no-invalid-html-attribute': 2,\n\t'mahir-react/prefer-read-only-props': 2,\n\t'unicorn/consistent-function-scoping': 0,\n};\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('mahir-react', './plugins/react.js')],\n\tenv: {\n\t\tbrowser: true,\n\t\tserviceworker: true,\n\t},\n\tsettings: {\n\t\treact: {\n\t\t\tversion: '19.0.0',\n\t\t},\n\t},\n\trules,\n});\n\nexport default config;\n"],"mappings":";;;;AAkEA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,eAAe,oBAAoB,CAAC;CAC5D,KAAK;EACJ,SAAS;EACT,eAAe;CAChB;CACA,UAAU,EACT,OAAO,EACN,SAAS,SACV,EACD;CACA;EAvEA,yBAAyB;EACzB,wBAAwB;EACxB,sBAAsB;EACtB,gBAAgB;EAChB,cAAc;EACd,6BAA6B;EAC7B,yBAAyB;EACzB,wBAAwB;EACxB,gCAAgC;EAChC,2BAA2B,CAAC,GAAG,OAAO;EACtC,kCAAkC,CACjC,GACA;GACC,UAAU;GACV,OAAO;EACR,CACD;EACA,uBAAuB,CAAC,GAAG,QAAQ;EACnC,iBAAiB,CAChB,GACA;GACC,wBAAwB;GACxB,0BAA0B;GAC1B,kBAAkB;EACnB,CACD;EACA,kCAAkC;EAClC,2CAA2C;EAC3C,gCAAgC;EAChC,2BAA2B;EAC3B,sBAAsB;EACtB,iCAAiC,CAChC,GACA,EACC,kBAAkB,KACnB,CACD;EACA,yBAAyB,CACxB,GACA,EACC,QAAQ;GAAC;GAAO;GAAM;GAAM;GAAM;GAAM;GAAM;GAAK;GAAK;GAAM;GAAM;GAAM;GAAO;GAAO;GAAQ;GAAM;GAAM;EAAI,EACjH,CACD;EACA,0BAA0B;EAC1B,mBAAmB;EACnB,iCAAiC;EACjC,0BAA0B;EAC1B,sBAAsB;EACtB,gCAAgC;EAChC,6BAA6B;EAC7B,uCAAuC;EACvC,uCAAuC;EACvC,2BAA2B;EAC3B,8BAA8B;EAC9B,yCAAyC;EACzC,sCAAsC;EACtC,uCAAuC;CAenC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imranbarbhuiya/oxc-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared Oxlint and Oxfmt configs for JavaScript and TypeScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -50,9 +50,6 @@
|
|
|
50
50
|
"jsdoc": [
|
|
51
51
|
"./dist/jsdoc.d.ts"
|
|
52
52
|
],
|
|
53
|
-
"jsx": [
|
|
54
|
-
"./dist/jsx.d.ts"
|
|
55
|
-
],
|
|
56
53
|
"module": [
|
|
57
54
|
"./dist/module.d.ts"
|
|
58
55
|
],
|
|
@@ -119,11 +116,6 @@
|
|
|
119
116
|
"import": "./dist/jsdoc.js",
|
|
120
117
|
"default": "./dist/jsdoc.js"
|
|
121
118
|
},
|
|
122
|
-
"./jsx": {
|
|
123
|
-
"types": "./dist/jsx.d.ts",
|
|
124
|
-
"import": "./dist/jsx.js",
|
|
125
|
-
"default": "./dist/jsx.js"
|
|
126
|
-
},
|
|
127
119
|
"./module": {
|
|
128
120
|
"types": "./dist/module.d.ts",
|
|
129
121
|
"import": "./dist/module.js",
|
|
@@ -198,7 +190,6 @@
|
|
|
198
190
|
"eslint": "^10.9.1",
|
|
199
191
|
"eslint-plugin-jsdoc": "^64.2.1",
|
|
200
192
|
"eslint-plugin-n": "^18.3.0",
|
|
201
|
-
"eslint-plugin-react": "^7.37.5",
|
|
202
193
|
"eslint-plugin-sonarjs": "^4.2.0",
|
|
203
194
|
"eslint-plugin-tsdoc": "^0.5.2",
|
|
204
195
|
"nypm": "^0.6.9",
|
package/dist/jsx.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/jsx.d.ts
|
|
2
|
-
declare const config: {
|
|
3
|
-
plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
|
|
4
|
-
jsPlugins: import("oxlint").ExternalPluginEntry[];
|
|
5
|
-
rules: import("oxlint").DummyRuleMap;
|
|
6
|
-
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { config as default };
|
|
9
|
-
//# sourceMappingURL=jsx.d.ts.map
|
package/dist/jsx.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { nativePlugins, packagePlugin } from "./config.js";
|
|
2
|
-
import { defineConfig } from "oxlint";
|
|
3
|
-
|
|
4
|
-
//#region src/jsx.ts
|
|
5
|
-
const config = defineConfig({
|
|
6
|
-
plugins: nativePlugins,
|
|
7
|
-
jsPlugins: [packagePlugin("react-js", "eslint-plugin-react")],
|
|
8
|
-
rules: {
|
|
9
|
-
"react/jsx-boolean-value": 0,
|
|
10
|
-
"react-js/jsx-boolean-value": [2, "never"],
|
|
11
|
-
"react-js/jsx-closing-bracket-location": [2, "line-aligned"],
|
|
12
|
-
"react-js/jsx-closing-tag-location": 2,
|
|
13
|
-
"react/jsx-curly-brace-presence": 0,
|
|
14
|
-
"react-js/jsx-curly-brace-presence": [2, {
|
|
15
|
-
children: "never",
|
|
16
|
-
props: "never"
|
|
17
|
-
}],
|
|
18
|
-
"react-js/jsx-equals-spacing": [2, "never"],
|
|
19
|
-
"react-js/jsx-first-prop-new-line": [2, "multiline-multiprop"],
|
|
20
|
-
"react/jsx-fragments": [2, "syntax"],
|
|
21
|
-
"react/jsx-key": [2, {
|
|
22
|
-
checkFragmentShorthand: true,
|
|
23
|
-
checkKeyMustBeforeSpread: true,
|
|
24
|
-
warnOnDuplicates: false
|
|
25
|
-
}],
|
|
26
|
-
"react-js/jsx-max-props-per-line": [2, {
|
|
27
|
-
maximum: 3,
|
|
28
|
-
when: "multiline"
|
|
29
|
-
}],
|
|
30
|
-
"react-js/jsx-newline": [2, { prevent: true }],
|
|
31
|
-
"react-js/jsx-no-bind": [2, {
|
|
32
|
-
allowArrowFunctions: true,
|
|
33
|
-
allowBind: false,
|
|
34
|
-
ignoreRefs: true
|
|
35
|
-
}],
|
|
36
|
-
"react/jsx-no-comment-textnodes": 2,
|
|
37
|
-
"react/jsx-no-constructed-context-values": 2,
|
|
38
|
-
"react/jsx-no-duplicate-props": 2,
|
|
39
|
-
"react/jsx-no-script-url": 2,
|
|
40
|
-
"react/jsx-no-undef": 2,
|
|
41
|
-
"react/jsx-no-useless-fragment": [2, { allowExpressions: true }],
|
|
42
|
-
"react/jsx-pascal-case": [2, { ignore: [
|
|
43
|
-
"h{}",
|
|
44
|
-
"h2",
|
|
45
|
-
"h3",
|
|
46
|
-
"h4",
|
|
47
|
-
"h5",
|
|
48
|
-
"h6",
|
|
49
|
-
"p",
|
|
50
|
-
"a",
|
|
51
|
-
"ul",
|
|
52
|
-
"ol",
|
|
53
|
-
"li",
|
|
54
|
-
"img",
|
|
55
|
-
"div",
|
|
56
|
-
"span",
|
|
57
|
-
"dl",
|
|
58
|
-
"dt",
|
|
59
|
-
"dd"
|
|
60
|
-
] }],
|
|
61
|
-
"react-js/jsx-sort-props": 2,
|
|
62
|
-
"react-js/jsx-tag-spacing": [2, {
|
|
63
|
-
afterOpening: "never",
|
|
64
|
-
beforeSelfClosing: "always",
|
|
65
|
-
closingSlash: "never"
|
|
66
|
-
}],
|
|
67
|
-
"react-js/jsx-uses-react": 2,
|
|
68
|
-
"react-js/jsx-uses-vars": 2,
|
|
69
|
-
"react-js/sort-default-props": 2,
|
|
70
|
-
"unicorn/consistent-function-scoping": 0
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { config as default };
|
|
76
|
-
//# sourceMappingURL=jsx.js.map
|
package/dist/jsx.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.js","names":[],"sources":["../src/jsx.ts"],"sourcesContent":["import { defineConfig } from 'oxlint';\n\nimport { nativePlugins, packagePlugin } from './config.js';\n\nimport type { OxlintConfig } from 'oxlint';\n\nconst rules: NonNullable<OxlintConfig['rules']> = {\n\t'react/jsx-boolean-value': 0,\n\t'react-js/jsx-boolean-value': [2, 'never'],\n\t'react-js/jsx-closing-bracket-location': [2, 'line-aligned'],\n\t'react-js/jsx-closing-tag-location': 2,\n\t'react/jsx-curly-brace-presence': 0,\n\t'react-js/jsx-curly-brace-presence': [\n\t\t2,\n\t\t{\n\t\t\tchildren: 'never',\n\t\t\tprops: 'never',\n\t\t},\n\t],\n\t'react-js/jsx-equals-spacing': [2, 'never'],\n\t'react-js/jsx-first-prop-new-line': [2, 'multiline-multiprop'],\n\t'react/jsx-fragments': [2, 'syntax'],\n\t'react/jsx-key': [\n\t\t2,\n\t\t{\n\t\t\tcheckFragmentShorthand: true,\n\t\t\tcheckKeyMustBeforeSpread: true,\n\t\t\twarnOnDuplicates: false,\n\t\t},\n\t],\n\t'react-js/jsx-max-props-per-line': [\n\t\t2,\n\t\t{\n\t\t\tmaximum: 3,\n\t\t\twhen: 'multiline',\n\t\t},\n\t],\n\t'react-js/jsx-newline': [\n\t\t2,\n\t\t{\n\t\t\tprevent: true,\n\t\t},\n\t],\n\t'react-js/jsx-no-bind': [\n\t\t2,\n\t\t{\n\t\t\tallowArrowFunctions: true,\n\t\t\tallowBind: false,\n\t\t\tignoreRefs: true,\n\t\t},\n\t],\n\t'react/jsx-no-comment-textnodes': 2,\n\t'react/jsx-no-constructed-context-values': 2,\n\t'react/jsx-no-duplicate-props': 2,\n\t'react/jsx-no-script-url': 2,\n\t'react/jsx-no-undef': 2,\n\t'react/jsx-no-useless-fragment': [\n\t\t2,\n\t\t{\n\t\t\tallowExpressions: true,\n\t\t},\n\t],\n\t'react/jsx-pascal-case': [\n\t\t2,\n\t\t{\n\t\t\tignore: ['h{}', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'a', 'ul', 'ol', 'li', 'img', 'div', 'span', 'dl', 'dt', 'dd'],\n\t\t},\n\t],\n\t'react-js/jsx-sort-props': 2,\n\t'react-js/jsx-tag-spacing': [\n\t\t2,\n\t\t{\n\t\t\tafterOpening: 'never',\n\t\t\tbeforeSelfClosing: 'always',\n\t\t\tclosingSlash: 'never',\n\t\t},\n\t],\n\t'react-js/jsx-uses-react': 2,\n\t'react-js/jsx-uses-vars': 2,\n\t'react-js/sort-default-props': 2,\n\t'unicorn/consistent-function-scoping': 0,\n};\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [packagePlugin('react-js', 'eslint-plugin-react')],\n\trules,\n});\n\nexport default config;\n"],"mappings":";;;;AAmFA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,cAAc,YAAY,qBAAqB,CAAC;CAC5D;EA/EA,2BAA2B;EAC3B,8BAA8B,CAAC,GAAG,OAAO;EACzC,yCAAyC,CAAC,GAAG,cAAc;EAC3D,qCAAqC;EACrC,kCAAkC;EAClC,qCAAqC,CACpC,GACA;GACC,UAAU;GACV,OAAO;EACR,CACD;EACA,+BAA+B,CAAC,GAAG,OAAO;EAC1C,oCAAoC,CAAC,GAAG,qBAAqB;EAC7D,uBAAuB,CAAC,GAAG,QAAQ;EACnC,iBAAiB,CAChB,GACA;GACC,wBAAwB;GACxB,0BAA0B;GAC1B,kBAAkB;EACnB,CACD;EACA,mCAAmC,CAClC,GACA;GACC,SAAS;GACT,MAAM;EACP,CACD;EACA,wBAAwB,CACvB,GACA,EACC,SAAS,KACV,CACD;EACA,wBAAwB,CACvB,GACA;GACC,qBAAqB;GACrB,WAAW;GACX,YAAY;EACb,CACD;EACA,kCAAkC;EAClC,2CAA2C;EAC3C,gCAAgC;EAChC,2BAA2B;EAC3B,sBAAsB;EACtB,iCAAiC,CAChC,GACA,EACC,kBAAkB,KACnB,CACD;EACA,yBAAyB,CACxB,GACA,EACC,QAAQ;GAAC;GAAO;GAAM;GAAM;GAAM;GAAM;GAAM;GAAK;GAAK;GAAM;GAAM;GAAM;GAAO;GAAO;GAAQ;GAAM;GAAM;EAAI,EACjH,CACD;EACA,2BAA2B;EAC3B,4BAA4B,CAC3B,GACA;GACC,cAAc;GACd,mBAAmB;GACnB,cAAc;EACf,CACD;EACA,2BAA2B;EAC3B,0BAA0B;EAC1B,+BAA+B;EAC/B,uCAAuC;CAMnC;AACL,CAAC"}
|