@nextnode-solutions/standards 1.3.1 → 1.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextnode-solutions/standards",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Centralized development standards for NextNode projects: oxlint, oxfmt, TypeScript, Tailwind, Vitest, commitlint",
5
5
  "keywords": [
6
6
  "commitlint",
@@ -30,7 +30,7 @@
30
30
  "format": "oxfmt --write .",
31
31
  "format:check": "oxfmt --check .",
32
32
  "lint": "oxlint",
33
- "prepare": "husky",
33
+ "prepare": "[ -n \"$CI\" ] || husky",
34
34
  "test": "echo 'Configuration package — no tests needed'"
35
35
  },
36
36
  "dependencies": {
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
3
+ "jsPlugins": ["./plugins/no-type-assertion.js"],
3
4
  "categories": {
4
5
  "correctness": "error",
5
6
  "suspicious": "warn",
@@ -41,7 +42,8 @@
41
42
  ],
42
43
  "react/exhaustive-deps": "warn",
43
44
  "react/rules-of-hooks": "error",
44
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"]
45
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
46
+ "nextnode/no-type-assertion": "error"
45
47
  },
46
48
  "overrides": [
47
49
  {
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Custom oxlint plugin that forbids `as` type assertions except `as const`.
3
+ *
4
+ * Rationale: `as` assertions bypass the type checker and hide type errors.
5
+ * Use type guards, `satisfies`, or refine your types instead.
6
+ */
7
+
8
+ const noTypeAssertion = {
9
+ meta: {
10
+ type: 'problem',
11
+ docs: {
12
+ description: 'Disallow `as` type assertions except `as const`',
13
+ },
14
+ messages: {
15
+ noTypeAssertion:
16
+ 'Type assertion with `as` is forbidden. Use type guards, `satisfies`, or refine your types instead. Only `as const` is allowed.',
17
+ },
18
+ schema: [],
19
+ },
20
+ create(context) {
21
+ return {
22
+ TSAsExpression(node) {
23
+ const typeAnnotation = node.typeAnnotation
24
+
25
+ const isAsConst =
26
+ typeAnnotation.type === 'TSTypeReference' &&
27
+ typeAnnotation.typeName?.type === 'Identifier' &&
28
+ typeAnnotation.typeName.name === 'const'
29
+
30
+ if (isAsConst) {
31
+ return
32
+ }
33
+
34
+ context.report({
35
+ node,
36
+ messageId: 'noTypeAssertion',
37
+ })
38
+ },
39
+ }
40
+ },
41
+ }
42
+
43
+ const plugin = {
44
+ meta: {
45
+ name: 'nextnode',
46
+ },
47
+ rules: {
48
+ 'no-type-assertion': noTypeAssertion,
49
+ },
50
+ }
51
+
52
+ export default plugin