@imranbarbhuiya/oxc-config 0.2.0 → 0.2.2
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 +3 -6
- package/dist/plugins/react.js +4 -0
- package/dist/plugins/react.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -58,12 +58,11 @@ npm install --save-dev @imranbarbhuiya/oxc-config oxlint oxlint-tsgolint oxfmt
|
|
|
58
58
|
Create `oxlint.config.ts`:
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
import { defineConfig } from 'oxlint';
|
|
62
|
-
|
|
63
61
|
import common from '@imranbarbhuiya/oxc-config/common';
|
|
64
62
|
import module from '@imranbarbhuiya/oxc-config/module';
|
|
65
63
|
import node from '@imranbarbhuiya/oxc-config/node';
|
|
66
64
|
import typescript from '@imranbarbhuiya/oxc-config/typescript';
|
|
65
|
+
import { defineConfig } from 'oxlint';
|
|
67
66
|
|
|
68
67
|
export default defineConfig({
|
|
69
68
|
extends: [common, node, typescript, module],
|
|
@@ -78,9 +77,8 @@ export default defineConfig({
|
|
|
78
77
|
Create `oxfmt.config.ts`:
|
|
79
78
|
|
|
80
79
|
```ts
|
|
81
|
-
import { defineConfig } from 'oxfmt';
|
|
82
|
-
|
|
83
80
|
import config from '@imranbarbhuiya/oxc-config/oxfmt';
|
|
81
|
+
import { defineConfig } from 'oxfmt';
|
|
84
82
|
|
|
85
83
|
export default defineConfig({
|
|
86
84
|
...config,
|
|
@@ -123,10 +121,9 @@ Fragments can be combined through `defineConfig({ extends: [...] })`. The Tailwi
|
|
|
123
121
|
TanStack Query can be added directly:
|
|
124
122
|
|
|
125
123
|
```ts
|
|
126
|
-
import { defineConfig } from 'oxlint';
|
|
127
|
-
|
|
128
124
|
import common from '@imranbarbhuiya/oxc-config/common';
|
|
129
125
|
import react from '@imranbarbhuiya/oxc-config/react';
|
|
126
|
+
import { defineConfig } from 'oxlint';
|
|
130
127
|
|
|
131
128
|
export default defineConfig({
|
|
132
129
|
extends: [common, react],
|
package/dist/plugins/react.js
CHANGED
|
@@ -331,6 +331,10 @@ const preferReadOnlyProps = defineRule({
|
|
|
331
331
|
else checkType(resolved, seen);
|
|
332
332
|
}
|
|
333
333
|
return {
|
|
334
|
+
before() {
|
|
335
|
+
types.clear();
|
|
336
|
+
jsxFns.clear();
|
|
337
|
+
},
|
|
334
338
|
TSTypeAliasDeclaration(node) {
|
|
335
339
|
types.set(node.id.name, node.typeAnnotation);
|
|
336
340
|
},
|
|
@@ -1 +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,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MAAM,KAAK,IAAI;GAClC;GACA,WAAW,MAAM;IAChB,MAAM,KAAK,kBAAkB,IAAI;IACjC,IAAI,IAAI,OAAO,IAAI,EAAE;GACtB;GACA,YAAY,MAAM;IACjB,MAAM,KAAK,kBAAkB,IAAI;IACjC,IAAI,IAAI,OAAO,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"}
|
|
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\tbefore() {\n\t\t\t\ttypes.clear();\n\t\t\t\tjsxFns.clear();\n\t\t\t},\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,o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mBAAmB,aAAa,SAAS,IAAI;QAC9D,UAAU,UAAU,IAAI;EAC9B;EACA,OAAO;GACN,SAAS;IACR,MAAM,MAAM;IACZ,OAAO,MAAM;GACd;GACA,uBAAuB,MAAM;IAC5B,MAAM,IAAI,KAAK,GAAG,MAAM,KAAK,cAAc;GAC5C;GACA,uBAAuB,MAAM;IAC5B,MAAM,IAAI,KAAK,GAAG,MAAM,KAAK,IAAI;GAClC;GACA,WAAW,MAAM;IAChB,MAAM,KAAK,kBAAkB,IAAI;IACjC,IAAI,IAAI,OAAO,IAAI,EAAE;GACtB;GACA,YAAY,MAAM;IACjB,MAAM,KAAK,kBAAkB,IAAI;IACjC,IAAI,IAAI,OAAO,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imranbarbhuiya/oxc-config",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Shared Oxlint and Oxfmt configs for JavaScript and TypeScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -199,14 +199,14 @@
|
|
|
199
199
|
"@types/bun": "^1.4.0",
|
|
200
200
|
"@types/node": "^25.9.5",
|
|
201
201
|
"@typescript-eslint/utils": "^8.68.0",
|
|
202
|
-
"oxfmt": "^0.
|
|
202
|
+
"oxfmt": "^0.72.0",
|
|
203
203
|
"oxlint": "^1.80.0",
|
|
204
204
|
"oxlint-tsgolint": "^7.0.2001",
|
|
205
205
|
"tsdown": "^0.22.14",
|
|
206
206
|
"typescript": "6.0.3"
|
|
207
207
|
},
|
|
208
208
|
"peerDependencies": {
|
|
209
|
-
"oxfmt": "^0.
|
|
209
|
+
"oxfmt": "^0.72.0",
|
|
210
210
|
"oxlint": "^1.80.0",
|
|
211
211
|
"oxlint-tsgolint": "^7.0.2001"
|
|
212
212
|
},
|