@imranbarbhuiya/oxc-config 0.1.7 → 0.1.9

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/dist/nest.js CHANGED
@@ -4,7 +4,7 @@ import { defineConfig } from "oxlint";
4
4
  //#region src/nest.ts
5
5
  const config = defineConfig({
6
6
  plugins: nativePlugins,
7
- jsPlugins: [localPlugin("nestjs-typed", "./nest-plugin.js")],
7
+ jsPlugins: [localPlugin("nestjs-typed", "./plugins/nest.js")],
8
8
  rules: { "nestjs-typed/sort-module-metadata-arrays": 2 }
9
9
  });
10
10
 
package/dist/nest.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"nest.js","names":[],"sources":["../src/nest.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'nestjs-typed/sort-module-metadata-arrays': 2,\n};\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('nestjs-typed', './nest-plugin.js')],\n\trules,\n});\n\nexport default config;\n"],"mappings":";;;;AAUA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,gBAAgB,kBAAkB,CAAC;CAC3D,SANA,4CAA4C,EAMxC;AACL,CAAC"}
1
+ {"version":3,"file":"nest.js","names":[],"sources":["../src/nest.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'nestjs-typed/sort-module-metadata-arrays': 2,\n};\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('nestjs-typed', './plugins/nest.js')],\n\trules,\n});\n\nexport default config;\n"],"mappings":";;;;AAUA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,gBAAgB,mBAAmB,CAAC;CAC5D,SANA,4CAA4C,EAMxC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { TSESLint } from "@typescript-eslint/utils";
2
+ //#region src/plugins/nest.d.ts
3
+ declare const plugin: TSESLint.FlatConfig.Plugin;
4
+ //#endregion
5
+ export { plugin as default };
6
+ //# sourceMappingURL=nest.d.ts.map
@@ -0,0 +1,57 @@
1
+ //#region src/plugins/nest.ts
2
+ const DEFAULT_LOCALE = "en-US";
3
+ function isSortable(node) {
4
+ return node?.type === "Identifier" || node?.type === "CallExpression";
5
+ }
6
+ function nodeName(node) {
7
+ if (node.type === "Identifier") return node.name;
8
+ if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier") return node.callee.object.name;
9
+ return "";
10
+ }
11
+ function isFactoryProviderInjectArray(node) {
12
+ if (node.parent.type !== "Property") return false;
13
+ const property = node.parent;
14
+ if (property.key.type !== "Identifier" || property.key.name !== "inject") return false;
15
+ if (property.parent.type !== "ObjectExpression") return false;
16
+ return property.parent.properties.some((item) => item.type === "Property" && item.key.type === "Identifier" && item.key.name === "useFactory");
17
+ }
18
+ const plugin = {
19
+ meta: {
20
+ name: "eslint-plugin-mahir-nest",
21
+ version: "1.0.0"
22
+ },
23
+ rules: { "sort-module-metadata-arrays": {
24
+ meta: {
25
+ type: "suggestion",
26
+ docs: { description: "Ensure Module metadata arrays are sorted alphabetically" },
27
+ fixable: "code",
28
+ schema: [{
29
+ type: "object",
30
+ additionalProperties: false,
31
+ properties: { locale: { type: "string" } }
32
+ }],
33
+ messages: { moduleMetadataArraysAreSorted: "`Module` metadata arrays should be sorted in ASC alphabetical order" }
34
+ },
35
+ defaultOptions: [{ locale: DEFAULT_LOCALE }],
36
+ create(context) {
37
+ const locale = context.options[0].locale ?? DEFAULT_LOCALE;
38
+ const sourceCode = context.sourceCode;
39
+ return { "ClassDeclaration > Decorator[expression.callee.name=\"Module\"] Property > ArrayExpression"(node) {
40
+ if (isFactoryProviderInjectArray(node)) return;
41
+ const sortable = node.elements.filter(isSortable);
42
+ const sorted = sortable.toSorted((left, right) => nodeName(left).localeCompare(nodeName(right), locale));
43
+ if (sortable.every((element, index) => element === sorted[index])) return;
44
+ const texts = sorted.map((element) => sourceCode.getText(element));
45
+ context.report({
46
+ node,
47
+ messageId: "moduleMetadataArraysAreSorted",
48
+ fix: (fixer) => sortable.map((element, index) => fixer.replaceText(element, texts[index] ?? ""))
49
+ });
50
+ } };
51
+ }
52
+ } }
53
+ };
54
+
55
+ //#endregion
56
+ export { plugin as default };
57
+ //# sourceMappingURL=nest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest.js","names":[],"sources":["../../src/plugins/nest.ts"],"sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\n\nconst DEFAULT_LOCALE = 'en-US';\n\ntype Options = [\n\t{\n\t\tlocale?: string;\n\t},\n];\n\nfunction isSortable(\n\tnode: TSESTree.Expression | TSESTree.SpreadElement | null,\n): node is TSESTree.CallExpression | TSESTree.Identifier {\n\treturn node?.type === 'Identifier' || node?.type === 'CallExpression';\n}\n\nfunction nodeName(node: TSESTree.Node) {\n\tif (node.type === 'Identifier') return node.name;\n\tif (\n\t\tnode.type === 'CallExpression' &&\n\t\tnode.callee.type === 'MemberExpression' &&\n\t\tnode.callee.object.type === 'Identifier'\n\t)\n\t\treturn node.callee.object.name;\n\treturn '';\n}\n\nfunction isFactoryProviderInjectArray(node: TSESTree.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: TSESLint.RuleModule<'moduleMetadataArraysAreSorted', Options> = {\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},\n\tdefaultOptions: [{ locale: DEFAULT_LOCALE }],\n\tcreate(context) {\n\t\tconst locale = context.options[0].locale ?? DEFAULT_LOCALE;\n\t\tconst sourceCode = context.sourceCode;\n\t\treturn {\n\t\t\t'ClassDeclaration > Decorator[expression.callee.name=\"Module\"] Property > ArrayExpression'(\n\t\t\t\tnode: TSESTree.ArrayExpression,\n\t\t\t) {\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) => 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\nconst plugin: TSESLint.FlatConfig.Plugin = {\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-nest',\n\t\tversion: '1.0.0',\n\t},\n\trules: {\n\t\t'sort-module-metadata-arrays': sortModuleMetadataArrays,\n\t},\n};\n\nexport default plugin;\n"],"mappings":";AAEA,MAAM,iBAAiB;AAQvB,SAAS,WACR,MACwD;CACxD,OAAO,MAAM,SAAS,gB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;IACnE,MAAM,QAAQ,OAAO,KAAK,YAAY,WAAW,QAAQ,OAAO,CAAC;IACjE,QAAQ,OAAO;KACd;KACA,WAAW;KACX,MAAM,UAAU,SAAS,KAAK,SAAS,UAAU,MAAM,YAAY,SAAS,MAAM,UAAU,EAAE,CAAC;IAChG,CAAC;GACF,EACD;EACD;CASuD,EACvD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imranbarbhuiya/oxc-config",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Shared Oxlint and Oxfmt configs for JavaScript and TypeScript projects",
5
5
  "keywords": [
6
6
  "config",
@@ -194,7 +194,6 @@
194
194
  },
195
195
  "dependencies": {
196
196
  "@clack/prompts": "^1.7.0",
197
- "@darraghor/eslint-plugin-nestjs-typed": "^7.2.5",
198
197
  "@typescript-eslint/eslint-plugin": "^8.63.0",
199
198
  "eslint-plugin-better-tailwindcss": "^4.6.1",
200
199
  "eslint-plugin-import-x": "^4.17.1",
@@ -1,2 +0,0 @@
1
- import { plugin as eslint_plugin_nestjs_typed_default } from "@darraghor/eslint-plugin-nestjs-typed";
2
- export { eslint_plugin_nestjs_typed_default as default };
@@ -1,3 +0,0 @@
1
- import { plugin as eslint_plugin_nestjs_typed_default } from "@darraghor/eslint-plugin-nestjs-typed";
2
-
3
- export { eslint_plugin_nestjs_typed_default as default };