@akanjs/lint 0.0.44 → 0.0.46

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.
Files changed (2) hide show
  1. package/index.js +328 -325
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,351 +1,354 @@
1
- (() => {
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined")
12
- return require.apply(this, arguments);
13
- throw Error('Dynamic require of "' + x + '" is not supported');
14
- });
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
28
 
32
- // pkgs/@akanjs/lint/rules/noImportClientFunctions.ts
33
- var import_utils = __require("@typescript-eslint/utils");
29
+ // pkgs/@akanjs/lint/index.ts
30
+ var lint_exports = {};
31
+ __export(lint_exports, {
32
+ default: () => lint_default
33
+ });
34
+ module.exports = __toCommonJS(lint_exports);
34
35
 
35
- // pkgs/@akanjs/lint/util/fileIsServerFile.ts
36
- var serverFileNameSet = /* @__PURE__ */ new Set();
37
- var clientFileNameSet = /* @__PURE__ */ new Set(["st.ts", "store.ts"]);
38
- var serverFileSuffixSet = /* @__PURE__ */ new Set(["page.tsx", "layout.tsx", "Unit.tsx", "View.tsx"]);
39
- var clientFileSuffixSet = /* @__PURE__ */ new Set(["Zone.tsx", "Util.tsx", "Template.tsx"]);
40
- var fileIsServerFile = (absFilePath, sourceCode) => {
41
- if (absFilePath.includes("eslint-rules"))
42
- return true;
43
- const filePaths = absFilePath.split("/");
44
- const filename = filePaths.at(-1) ?? "";
45
- const fileLastName = absFilePath.split(".").slice(-2).join(".");
46
- if (filename === "page.tsx") {
47
- if (filePaths.includes("admin"))
48
- return false;
49
- else
50
- return true;
51
- }
52
- if (filename === "layout.tsx") {
53
- if (filePaths.at(-2) === "app")
54
- return false;
55
- else
56
- return true;
57
- }
58
- if (serverFileNameSet.has(filename))
59
- return true;
60
- if (clientFileNameSet.has(filename))
36
+ // pkgs/@akanjs/lint/rules/noImportClientFunctions.ts
37
+ var import_utils = require("@typescript-eslint/utils");
38
+
39
+ // pkgs/@akanjs/lint/util/fileIsServerFile.ts
40
+ var serverFileNameSet = /* @__PURE__ */ new Set();
41
+ var clientFileNameSet = /* @__PURE__ */ new Set(["st.ts", "store.ts"]);
42
+ var serverFileSuffixSet = /* @__PURE__ */ new Set(["page.tsx", "layout.tsx", "Unit.tsx", "View.tsx"]);
43
+ var clientFileSuffixSet = /* @__PURE__ */ new Set(["Zone.tsx", "Util.tsx", "Template.tsx"]);
44
+ var fileIsServerFile = (absFilePath, sourceCode) => {
45
+ if (absFilePath.includes("eslint-rules"))
46
+ return true;
47
+ const filePaths = absFilePath.split("/");
48
+ const filename = filePaths.at(-1) ?? "";
49
+ const fileLastName = absFilePath.split(".").slice(-2).join(".");
50
+ if (filename === "page.tsx") {
51
+ if (filePaths.includes("admin"))
61
52
  return false;
62
- if (serverFileSuffixSet.has(fileLastName))
53
+ else
63
54
  return true;
64
- if (clientFileSuffixSet.has(fileLastName))
65
- return false;
66
- if (new RegExp(/useEffect|useState|useContext|st\.do\.|st\.use\./g).test(sourceCode))
55
+ }
56
+ if (filename === "layout.tsx") {
57
+ if (filePaths.at(-2) === "app")
67
58
  return false;
68
- return null;
69
- };
59
+ else
60
+ return true;
61
+ }
62
+ if (serverFileNameSet.has(filename))
63
+ return true;
64
+ if (clientFileNameSet.has(filename))
65
+ return false;
66
+ if (serverFileSuffixSet.has(fileLastName))
67
+ return true;
68
+ if (clientFileSuffixSet.has(fileLastName))
69
+ return false;
70
+ if (new RegExp(/useEffect|useState|useContext|st\.do\.|st\.use\./g).test(sourceCode))
71
+ return false;
72
+ return null;
73
+ };
70
74
 
71
- // pkgs/@akanjs/lint/util/fileHasUseClient.ts
72
- var fileHasUseClient = (context) => {
73
- const firstLineIdx = context.sourceCode.lines.findIndex((line) => line.trim() !== "");
74
- return { hasUseClient: context.sourceCode.lines[firstLineIdx].includes('"use client"'), firstLineIdx };
75
- };
75
+ // pkgs/@akanjs/lint/util/fileHasUseClient.ts
76
+ var fileHasUseClient = (context) => {
77
+ const firstLineIdx = context.sourceCode.lines.findIndex((line) => line.trim() !== "");
78
+ return { hasUseClient: context.sourceCode.lines[firstLineIdx].includes('"use client"'), firstLineIdx };
79
+ };
76
80
 
77
- // pkgs/@akanjs/lint/util/fileHasContent.ts
78
- var fileHasContent = (context, node) => {
79
- const firstToken = context.sourceCode.getFirstToken(node);
80
- return !!firstToken;
81
- };
81
+ // pkgs/@akanjs/lint/util/fileHasContent.ts
82
+ var fileHasContent = (context, node) => {
83
+ const firstToken = context.sourceCode.getFirstToken(node);
84
+ return !!firstToken;
85
+ };
82
86
 
83
- // pkgs/@akanjs/lint/util/fileHasClientFunction.ts
84
- var reactClientFunctionSet = /* @__PURE__ */ new Set([
85
- "useState",
86
- "useEffect",
87
- "useContext",
88
- "useReducer",
89
- "useCallback",
90
- "useMemo",
91
- "useRef",
92
- "useImperativeHandle",
93
- "useLayoutEffect",
94
- "useDebugValue"
95
- ]);
96
- var frameworkClientFunctionSet = /* @__PURE__ */ new Set(["st"]);
97
- var fileHasClientFunction = (node) => {
98
- if (node.source.value === "react")
99
- return node.specifiers.some((specifier) => reactClientFunctionSet.has(specifier.local.name));
100
- else if (node.specifiers.some((specifier) => frameworkClientFunctionSet.has(specifier.local.name)))
101
- return true;
102
- else
103
- return false;
104
- };
87
+ // pkgs/@akanjs/lint/util/fileHasClientFunction.ts
88
+ var reactClientFunctionSet = /* @__PURE__ */ new Set([
89
+ "useState",
90
+ "useEffect",
91
+ "useContext",
92
+ "useReducer",
93
+ "useCallback",
94
+ "useMemo",
95
+ "useRef",
96
+ "useImperativeHandle",
97
+ "useLayoutEffect",
98
+ "useDebugValue"
99
+ ]);
100
+ var frameworkClientFunctionSet = /* @__PURE__ */ new Set(["st"]);
101
+ var fileHasClientFunction = (node) => {
102
+ if (node.source.value === "react")
103
+ return node.specifiers.some((specifier) => reactClientFunctionSet.has(specifier.local.name));
104
+ else if (node.specifiers.some((specifier) => frameworkClientFunctionSet.has(specifier.local.name)))
105
+ return true;
106
+ else
107
+ return false;
108
+ };
105
109
 
106
- // pkgs/@akanjs/lint/util/getFilename.ts
107
- var getFilename = (absFilePath) => {
108
- const filePaths = absFilePath.split("/");
109
- return filePaths.at(-1) ?? "";
110
- };
110
+ // pkgs/@akanjs/lint/util/getFilename.ts
111
+ var getFilename = (absFilePath) => {
112
+ const filePaths = absFilePath.split("/");
113
+ return filePaths.at(-1) ?? "";
114
+ };
111
115
 
112
- // pkgs/@akanjs/lint/util/fileIsPureImportFile.ts
113
- var fileSuffixSet = /* @__PURE__ */ new Set([
114
- "page.tsx",
115
- "layout.tsx",
116
- "index.ts",
117
- "cnst_.ts",
118
- "cnst.ts",
119
- "db.ts",
120
- "dict.ts",
121
- "fetch.ts",
122
- "option.ts",
123
- "sig.ts",
124
- "srv.ts",
125
- "st.ts",
126
- "usePage.ts",
127
- "_server.ts",
128
- "constant.ts",
129
- "dictionary.ts",
130
- "document.ts",
131
- "service.ts",
132
- "signal.ts",
133
- "spec.ts",
134
- "test.ts",
135
- "store.ts",
136
- "Template.tsx",
137
- "Unit.tsx",
138
- "Util.tsx",
139
- "View.tsx",
140
- "Zone.tsx",
141
- "index.tsx"
142
- ]);
143
- var fileIsPureImportFile = (filename) => {
144
- const suffixFilename = filename.split("/").at(-1)?.split(".").slice(-2).join(".") ?? "";
145
- if (fileSuffixSet.has(suffixFilename))
146
- return true;
147
- else
148
- return false;
149
- };
116
+ // pkgs/@akanjs/lint/util/fileIsPureImportFile.ts
117
+ var fileSuffixSet = /* @__PURE__ */ new Set([
118
+ "page.tsx",
119
+ "layout.tsx",
120
+ "index.ts",
121
+ "cnst_.ts",
122
+ "cnst.ts",
123
+ "db.ts",
124
+ "dict.ts",
125
+ "fetch.ts",
126
+ "option.ts",
127
+ "sig.ts",
128
+ "srv.ts",
129
+ "st.ts",
130
+ "usePage.ts",
131
+ "_server.ts",
132
+ "constant.ts",
133
+ "dictionary.ts",
134
+ "document.ts",
135
+ "service.ts",
136
+ "signal.ts",
137
+ "spec.ts",
138
+ "test.ts",
139
+ "store.ts",
140
+ "Template.tsx",
141
+ "Unit.tsx",
142
+ "Util.tsx",
143
+ "View.tsx",
144
+ "Zone.tsx",
145
+ "index.tsx"
146
+ ]);
147
+ var fileIsPureImportFile = (filename) => {
148
+ const suffixFilename = filename.split("/").at(-1)?.split(".").slice(-2).join(".") ?? "";
149
+ if (fileSuffixSet.has(suffixFilename))
150
+ return true;
151
+ else
152
+ return false;
153
+ };
150
154
 
151
- // pkgs/@akanjs/lint/util/isInternalImport.ts
152
- var fs = __toESM(__require("fs"));
153
- var projectRoot = process.cwd();
154
- var libNames = [...fs.readdirSync(`${projectRoot}/libs`), ...fs.readdirSync(`${projectRoot}/pkgs`)];
155
- var internalImportSet = /* @__PURE__ */ new Set([
156
- ...libNames.map((libName) => `@${libName}`),
157
- "react-icons",
158
- "react",
159
- "next",
160
- "@radix-ui",
161
- "@playwright",
162
- "@akanjs",
163
- ".",
164
- ".."
165
- ]);
166
- var isInternalImport = (importPaths, appName) => {
167
- if (internalImportSet.has(importPaths[0]))
168
- return true;
169
- else if (importPaths[0] === appName)
170
- return true;
171
- else
172
- return false;
173
- };
155
+ // pkgs/@akanjs/lint/util/isInternalImport.ts
156
+ var fs = __toESM(require("fs"));
157
+ var projectRoot = process.cwd();
158
+ var libNames = [...fs.readdirSync(`${projectRoot}/libs`), ...fs.readdirSync(`${projectRoot}/pkgs`)];
159
+ var internalImportSet = /* @__PURE__ */ new Set([
160
+ ...libNames.map((libName) => `@${libName}`),
161
+ "react-icons",
162
+ "react",
163
+ "next",
164
+ "@radix-ui",
165
+ "@playwright",
166
+ "@akanjs",
167
+ ".",
168
+ ".."
169
+ ]);
170
+ var isInternalImport = (importPaths, appName) => {
171
+ if (internalImportSet.has(importPaths[0]))
172
+ return true;
173
+ else if (importPaths[0] === appName)
174
+ return true;
175
+ else
176
+ return false;
177
+ };
174
178
 
175
- // pkgs/@akanjs/lint/util/getAppName.ts
176
- var getAppName = (filePaths) => {
177
- const appsIdx = filePaths.findIndex((part) => part === "apps");
178
- const appName = appsIdx === -1 ? null : filePaths[appsIdx + 1];
179
- return appName;
180
- };
179
+ // pkgs/@akanjs/lint/util/getAppName.ts
180
+ var getAppName = (filePaths) => {
181
+ const appsIdx = filePaths.findIndex((part) => part === "apps");
182
+ const appName = appsIdx === -1 ? null : filePaths[appsIdx + 1];
183
+ return appName;
184
+ };
181
185
 
182
- // pkgs/@akanjs/lint/rules/noImportClientFunctions.ts
183
- var noImportClientFunctions = import_utils.ESLintUtils.RuleCreator(() => __filename)({
184
- name: "noImportClientFunctions",
185
- meta: {
186
- type: "problem",
187
- docs: {
188
- description: "Enforce that client functions are not imported."
189
- },
190
- messages: {
191
- noImportClientFunctions: "Error: Client functions should not be imported."
192
- },
193
- // fixable: "code",
194
- schema: []
186
+ // pkgs/@akanjs/lint/rules/noImportClientFunctions.ts
187
+ var noImportClientFunctions = import_utils.ESLintUtils.RuleCreator(() => __filename)({
188
+ name: "noImportClientFunctions",
189
+ meta: {
190
+ type: "problem",
191
+ docs: {
192
+ description: "Enforce that client functions are not imported."
195
193
  },
196
- defaultOptions: [],
197
- create(context) {
198
- const isServerFile = fileIsServerFile(context.filename, context.sourceCode.text);
199
- if (!isServerFile)
200
- return {};
201
- return {
202
- ImportDeclaration(node) {
203
- const hasClientFunction = fileHasClientFunction(node);
204
- if (hasClientFunction)
205
- context.report({
206
- node,
207
- messageId: "noImportClientFunctions"
208
- });
194
+ messages: {
195
+ noImportClientFunctions: "Error: Client functions should not be imported."
196
+ },
197
+ // fixable: "code",
198
+ schema: []
199
+ },
200
+ defaultOptions: [],
201
+ create(context) {
202
+ const isServerFile = fileIsServerFile(context.filename, context.sourceCode.text);
203
+ if (!isServerFile)
204
+ return {};
205
+ return {
206
+ ImportDeclaration(node) {
207
+ const hasClientFunction = fileHasClientFunction(node);
208
+ if (hasClientFunction)
209
+ context.report({
210
+ node,
211
+ messageId: "noImportClientFunctions"
212
+ });
213
+ }
214
+ };
215
+ }
216
+ });
217
+
218
+ // pkgs/@akanjs/lint/rules/noImportExternalLibrary.ts
219
+ var import_utils2 = require("@typescript-eslint/utils");
220
+ var noImportExternalLibrary = import_utils2.ESLintUtils.RuleCreator(() => __filename)({
221
+ name: "noImportExternalLibrary",
222
+ meta: {
223
+ type: "problem",
224
+ docs: {
225
+ description: "Enforce that external libraries are not imported."
226
+ },
227
+ messages: {
228
+ noImportExternalLibrary: "Error: External libraries should not be imported."
229
+ },
230
+ // fixable: "code",
231
+ schema: []
232
+ },
233
+ defaultOptions: [],
234
+ create(context) {
235
+ const isPureImportFile = fileIsPureImportFile(context.filename);
236
+ if (!isPureImportFile)
237
+ return {};
238
+ const filePaths = context.filename.split("/");
239
+ const appName = getAppName(filePaths);
240
+ const appPath = appName ? `@${appName}` : null;
241
+ return {
242
+ ImportDeclaration(node) {
243
+ const importPaths = node.source.value.split("/");
244
+ if (!isInternalImport(importPaths, appPath))
245
+ context.report({
246
+ node,
247
+ messageId: "noImportExternalLibrary"
248
+ // fix(fixer) {
249
+ // return fixer.remove(node);
250
+ // },
251
+ });
252
+ }
253
+ };
254
+ }
255
+ });
256
+
257
+ // pkgs/@akanjs/lint/rules/nonScalarPropsRestricted.ts
258
+ var import_utils3 = require("@typescript-eslint/utils");
259
+ var allowedPropKeySet = /* @__PURE__ */ new Set(["loader", "render", "of"]);
260
+ var nonScalarPropsRestricted = import_utils3.ESLintUtils.RuleCreator(() => __filename)({
261
+ name: "nonScalarPropsRestricted",
262
+ meta: {
263
+ type: "problem",
264
+ docs: {
265
+ description: "Enforce that non-scalar props are not used."
266
+ },
267
+ messages: {
268
+ nonScalarPropsRestricted: "Error: Non-scalar props should not be used."
269
+ },
270
+ // fixable: "code",
271
+ schema: []
272
+ },
273
+ defaultOptions: [],
274
+ create(context) {
275
+ const filename = getFilename(context.filename);
276
+ const isServerFile = fileIsServerFile(context.filename, context.sourceCode.text);
277
+ if (!isServerFile || !["page.tsx", "layout.tsx"].includes(filename))
278
+ return {};
279
+ return {
280
+ JSXAttribute(node) {
281
+ if (node.value?.expression) {
282
+ const { expression, parent } = node.value;
283
+ if (expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression") {
284
+ if (!allowedPropKeySet.has(parent.name.name))
285
+ context.report({
286
+ node,
287
+ messageId: "nonScalarPropsRestricted"
288
+ });
289
+ }
209
290
  }
210
- };
211
- }
212
- });
291
+ }
292
+ };
293
+ }
294
+ });
213
295
 
214
- // pkgs/@akanjs/lint/rules/noImportExternalLibrary.ts
215
- var import_utils2 = __require("@typescript-eslint/utils");
216
- var noImportExternalLibrary = import_utils2.ESLintUtils.RuleCreator(() => __filename)({
217
- name: "noImportExternalLibrary",
218
- meta: {
219
- type: "problem",
220
- docs: {
221
- description: "Enforce that external libraries are not imported."
222
- },
223
- messages: {
224
- noImportExternalLibrary: "Error: External libraries should not be imported."
225
- },
226
- // fixable: "code",
227
- schema: []
296
+ // pkgs/@akanjs/lint/rules/useClientByFile.ts
297
+ var import_utils4 = require("@typescript-eslint/utils");
298
+ var useClientByFile = import_utils4.ESLintUtils.RuleCreator(() => __filename)({
299
+ name: "useClientByFile",
300
+ meta: {
301
+ type: "problem",
302
+ docs: {
303
+ description: "Enforce that `use client` is not used in `server` files."
304
+ },
305
+ messages: {
306
+ noUseClient: 'Error: "use client" should not be used at the top of a `server` file.',
307
+ forceUseClient: 'Error: "use client" should be used at the top of a `client` file.'
228
308
  },
229
- defaultOptions: [],
230
- create(context) {
231
- const isPureImportFile = fileIsPureImportFile(context.filename);
232
- if (!isPureImportFile)
233
- return {};
234
- const filePaths = context.filename.split("/");
235
- const appName = getAppName(filePaths);
236
- const appPath = appName ? `@${appName}` : null;
309
+ // fixable: "code",
310
+ schema: []
311
+ },
312
+ defaultOptions: [],
313
+ create(context) {
314
+ const isServerFile = fileIsServerFile(context.filename, context.sourceCode.text);
315
+ if (isServerFile === null)
316
+ return {};
317
+ if (isServerFile)
237
318
  return {
238
- ImportDeclaration(node) {
239
- const importPaths = node.source.value.split("/");
240
- if (!isInternalImport(importPaths, appPath))
319
+ Program(node) {
320
+ if (!fileHasContent(context, node))
321
+ return;
322
+ const { hasUseClient, firstLineIdx } = fileHasUseClient(context);
323
+ if (hasUseClient)
241
324
  context.report({
242
- node,
243
- messageId: "noImportExternalLibrary"
244
- // fix(fixer) {
245
- // return fixer.remove(node);
246
- // },
325
+ node: node.body[firstLineIdx],
326
+ messageId: "noUseClient"
247
327
  });
248
328
  }
249
329
  };
250
- }
251
- });
252
-
253
- // pkgs/@akanjs/lint/rules/nonScalarPropsRestricted.ts
254
- var import_utils3 = __require("@typescript-eslint/utils");
255
- var allowedPropKeySet = /* @__PURE__ */ new Set(["loader", "render", "of"]);
256
- var nonScalarPropsRestricted = import_utils3.ESLintUtils.RuleCreator(() => __filename)({
257
- name: "nonScalarPropsRestricted",
258
- meta: {
259
- type: "problem",
260
- docs: {
261
- description: "Enforce that non-scalar props are not used."
262
- },
263
- messages: {
264
- nonScalarPropsRestricted: "Error: Non-scalar props should not be used."
265
- },
266
- // fixable: "code",
267
- schema: []
268
- },
269
- defaultOptions: [],
270
- create(context) {
271
- const filename = getFilename(context.filename);
272
- const isServerFile = fileIsServerFile(context.filename, context.sourceCode.text);
273
- if (!isServerFile || !["page.tsx", "layout.tsx"].includes(filename))
274
- return {};
330
+ else
275
331
  return {
276
- JSXAttribute(node) {
277
- if (node.value?.expression) {
278
- const { expression, parent } = node.value;
279
- if (expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression") {
280
- if (!allowedPropKeySet.has(parent.name.name))
281
- context.report({
282
- node,
283
- messageId: "nonScalarPropsRestricted"
284
- });
285
- }
286
- }
332
+ Program(node) {
333
+ if (!fileHasContent(context, node))
334
+ return;
335
+ const { hasUseClient, firstLineIdx } = fileHasUseClient(context);
336
+ if (!hasUseClient)
337
+ context.report({
338
+ node: node.body[firstLineIdx],
339
+ messageId: "forceUseClient"
340
+ });
287
341
  }
288
342
  };
289
- }
290
- });
291
-
292
- // pkgs/@akanjs/lint/rules/useClientByFile.ts
293
- var import_utils4 = __require("@typescript-eslint/utils");
294
- var useClientByFile = import_utils4.ESLintUtils.RuleCreator(() => __filename)({
295
- name: "useClientByFile",
296
- meta: {
297
- type: "problem",
298
- docs: {
299
- description: "Enforce that `use client` is not used in `server` files."
300
- },
301
- messages: {
302
- noUseClient: 'Error: "use client" should not be used at the top of a `server` file.',
303
- forceUseClient: 'Error: "use client" should be used at the top of a `client` file.'
304
- },
305
- // fixable: "code",
306
- schema: []
307
- },
308
- defaultOptions: [],
309
- create(context) {
310
- const isServerFile = fileIsServerFile(context.filename, context.sourceCode.text);
311
- if (isServerFile === null)
312
- return {};
313
- if (isServerFile)
314
- return {
315
- Program(node) {
316
- if (!fileHasContent(context, node))
317
- return;
318
- const { hasUseClient, firstLineIdx } = fileHasUseClient(context);
319
- if (hasUseClient)
320
- context.report({
321
- node: node.body[firstLineIdx],
322
- messageId: "noUseClient"
323
- });
324
- }
325
- };
326
- else
327
- return {
328
- Program(node) {
329
- if (!fileHasContent(context, node))
330
- return;
331
- const { hasUseClient, firstLineIdx } = fileHasUseClient(context);
332
- if (!hasUseClient)
333
- context.report({
334
- node: node.body[firstLineIdx],
335
- messageId: "forceUseClient"
336
- });
337
- }
338
- };
339
- }
340
- });
343
+ }
344
+ });
341
345
 
342
- // pkgs/@akanjs/lint/index.ts
343
- var lint_default = {
344
- rules: {
345
- noImportExternalLibrary,
346
- noImportClientFunctions,
347
- nonScalarPropsRestricted,
348
- useClientByFile
349
- }
350
- };
351
- })();
346
+ // pkgs/@akanjs/lint/index.ts
347
+ var lint_default = {
348
+ rules: {
349
+ noImportExternalLibrary,
350
+ noImportClientFunctions,
351
+ nonScalarPropsRestricted,
352
+ useClientByFile
353
+ }
354
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/lint",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"