@valbuild/eslint-plugin 0.52.0 → 0.54.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.
@@ -92,7 +92,7 @@ var noIllegalModuleIds = {
92
92
  if (firstArg.type === "TemplateLiteral") {
93
93
  context.report({
94
94
  node: firstArg,
95
- message: "Val: val.content id should not be a template literal",
95
+ message: "Val: c.define id should not be a template literal",
96
96
  fix: function fix(fixer) {
97
97
  return fixer.replaceText(firstArg, "\"".concat(expectedValue, "\""));
98
98
  }
@@ -105,7 +105,7 @@ var noIllegalModuleIds = {
105
105
  if (rawArg) {
106
106
  context.report({
107
107
  node: firstArg,
108
- message: "Val: val.content id should match the filename. Expected: '".concat(expectedValue, "'. Found: '").concat(firstArg.value, "'"),
108
+ message: "Val: c.define id should match the filename. Expected: '".concat(expectedValue, "'. Found: '").concat(firstArg.value, "'"),
109
109
  fix: function fix(fixer) {
110
110
  return fixer.replaceText(firstArg, "".concat(rawArg).concat(expectedValue).concat(rawArg));
111
111
  }
@@ -165,18 +165,18 @@ var exportContentMustBeValid = {
165
165
  meta: {
166
166
  type: "problem",
167
167
  docs: {
168
- description: "Export val.content should only happen in .val files.",
168
+ description: "Export c.define should only happen in .val files.",
169
169
  recommended: true
170
170
  },
171
171
  messages: {
172
- "val/export-content-must-be-valid": "Val: val.content should only be exported from .val files"
172
+ "val/export-content-must-be-valid": "Val: c.define should only be exported from .val files"
173
173
  },
174
174
  schema: []
175
175
  },
176
176
  create: function create(context) {
177
177
  return {
178
178
  ExportDefaultDeclaration: function ExportDefaultDeclaration(node) {
179
- if (node.declaration && node.declaration.type === "CallExpression" && node.declaration.callee.type === "MemberExpression" && node.declaration.callee.object.type === "Identifier" && node.declaration.callee.object.name === "val" && node.declaration.callee.property.type === "Identifier" && node.declaration.callee.property.name === "content") {
179
+ if (node.declaration && node.declaration.type === "CallExpression" && node.declaration.callee.type === "MemberExpression" && node.declaration.callee.object.type === "Identifier" && node.declaration.callee.object.name === "c" && node.declaration.callee.property.type === "Identifier" && node.declaration.callee.property.name === "define") {
180
180
  var filename = context.filename || context.getFilename();
181
181
  if (!(filename !== null && filename !== void 0 && filename.endsWith(".val.ts") || filename !== null && filename !== void 0 && filename.endsWith(".val.js"))) {
182
182
  context.report({
@@ -92,7 +92,7 @@ var noIllegalModuleIds = {
92
92
  if (firstArg.type === "TemplateLiteral") {
93
93
  context.report({
94
94
  node: firstArg,
95
- message: "Val: val.content id should not be a template literal",
95
+ message: "Val: c.define id should not be a template literal",
96
96
  fix: function fix(fixer) {
97
97
  return fixer.replaceText(firstArg, "\"".concat(expectedValue, "\""));
98
98
  }
@@ -105,7 +105,7 @@ var noIllegalModuleIds = {
105
105
  if (rawArg) {
106
106
  context.report({
107
107
  node: firstArg,
108
- message: "Val: val.content id should match the filename. Expected: '".concat(expectedValue, "'. Found: '").concat(firstArg.value, "'"),
108
+ message: "Val: c.define id should match the filename. Expected: '".concat(expectedValue, "'. Found: '").concat(firstArg.value, "'"),
109
109
  fix: function fix(fixer) {
110
110
  return fixer.replaceText(firstArg, "".concat(rawArg).concat(expectedValue).concat(rawArg));
111
111
  }
@@ -165,18 +165,18 @@ var exportContentMustBeValid = {
165
165
  meta: {
166
166
  type: "problem",
167
167
  docs: {
168
- description: "Export val.content should only happen in .val files.",
168
+ description: "Export c.define should only happen in .val files.",
169
169
  recommended: true
170
170
  },
171
171
  messages: {
172
- "val/export-content-must-be-valid": "Val: val.content should only be exported from .val files"
172
+ "val/export-content-must-be-valid": "Val: c.define should only be exported from .val files"
173
173
  },
174
174
  schema: []
175
175
  },
176
176
  create: function create(context) {
177
177
  return {
178
178
  ExportDefaultDeclaration: function ExportDefaultDeclaration(node) {
179
- if (node.declaration && node.declaration.type === "CallExpression" && node.declaration.callee.type === "MemberExpression" && node.declaration.callee.object.type === "Identifier" && node.declaration.callee.object.name === "val" && node.declaration.callee.property.type === "Identifier" && node.declaration.callee.property.name === "content") {
179
+ if (node.declaration && node.declaration.type === "CallExpression" && node.declaration.callee.type === "MemberExpression" && node.declaration.callee.object.type === "Identifier" && node.declaration.callee.object.name === "c" && node.declaration.callee.property.type === "Identifier" && node.declaration.callee.property.name === "define") {
180
180
  var filename = context.filename || context.getFilename();
181
181
  if (!(filename !== null && filename !== void 0 && filename.endsWith(".val.ts") || filename !== null && filename !== void 0 && filename.endsWith(".val.js"))) {
182
182
  context.report({
@@ -84,7 +84,7 @@ var noIllegalModuleIds = {
84
84
  if (firstArg.type === "TemplateLiteral") {
85
85
  context.report({
86
86
  node: firstArg,
87
- message: "Val: val.content id should not be a template literal",
87
+ message: "Val: c.define id should not be a template literal",
88
88
  fix: function fix(fixer) {
89
89
  return fixer.replaceText(firstArg, "\"".concat(expectedValue, "\""));
90
90
  }
@@ -97,7 +97,7 @@ var noIllegalModuleIds = {
97
97
  if (rawArg) {
98
98
  context.report({
99
99
  node: firstArg,
100
- message: "Val: val.content id should match the filename. Expected: '".concat(expectedValue, "'. Found: '").concat(firstArg.value, "'"),
100
+ message: "Val: c.define id should match the filename. Expected: '".concat(expectedValue, "'. Found: '").concat(firstArg.value, "'"),
101
101
  fix: function fix(fixer) {
102
102
  return fixer.replaceText(firstArg, "".concat(rawArg).concat(expectedValue).concat(rawArg));
103
103
  }
@@ -157,18 +157,18 @@ var exportContentMustBeValid = {
157
157
  meta: {
158
158
  type: "problem",
159
159
  docs: {
160
- description: "Export val.content should only happen in .val files.",
160
+ description: "Export c.define should only happen in .val files.",
161
161
  recommended: true
162
162
  },
163
163
  messages: {
164
- "val/export-content-must-be-valid": "Val: val.content should only be exported from .val files"
164
+ "val/export-content-must-be-valid": "Val: c.define should only be exported from .val files"
165
165
  },
166
166
  schema: []
167
167
  },
168
168
  create: function create(context) {
169
169
  return {
170
170
  ExportDefaultDeclaration: function ExportDefaultDeclaration(node) {
171
- if (node.declaration && node.declaration.type === "CallExpression" && node.declaration.callee.type === "MemberExpression" && node.declaration.callee.object.type === "Identifier" && node.declaration.callee.object.name === "val" && node.declaration.callee.property.type === "Identifier" && node.declaration.callee.property.name === "content") {
171
+ if (node.declaration && node.declaration.type === "CallExpression" && node.declaration.callee.type === "MemberExpression" && node.declaration.callee.object.type === "Identifier" && node.declaration.callee.object.name === "c" && node.declaration.callee.property.type === "Identifier" && node.declaration.callee.property.name === "define") {
172
172
  var filename = context.filename || context.getFilename();
173
173
  if (!(filename !== null && filename !== void 0 && filename.endsWith(".val.ts") || filename !== null && filename !== void 0 && filename.endsWith(".val.js"))) {
174
174
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/eslint-plugin",
3
- "version": "0.52.0",
3
+ "version": "0.54.0",
4
4
  "description": "ESLint rules for val",
5
5
  "keywords": [
6
6
  "eslint",
@@ -7,12 +7,12 @@ export default {
7
7
  meta: {
8
8
  type: "problem",
9
9
  docs: {
10
- description: "Export val.content should only happen in .val files.",
10
+ description: "Export c.define should only happen in .val files.",
11
11
  recommended: true,
12
12
  },
13
13
  messages: {
14
14
  "val/export-content-must-be-valid":
15
- "Val: val.content should only be exported from .val files",
15
+ "Val: c.define should only be exported from .val files",
16
16
  },
17
17
  schema: [],
18
18
  },
@@ -24,9 +24,9 @@ export default {
24
24
  node.declaration.type === "CallExpression" &&
25
25
  node.declaration.callee.type === "MemberExpression" &&
26
26
  node.declaration.callee.object.type === "Identifier" &&
27
- node.declaration.callee.object.name === "val" &&
27
+ node.declaration.callee.object.name === "c" &&
28
28
  node.declaration.callee.property.type === "Identifier" &&
29
- node.declaration.callee.property.name === "content"
29
+ node.declaration.callee.property.name === "define"
30
30
  ) {
31
31
  const filename = context.filename || context.getFilename();
32
32
  if (
@@ -78,7 +78,7 @@ export default {
78
78
  if (firstArg.type === "TemplateLiteral") {
79
79
  context.report({
80
80
  node: firstArg,
81
- message: "Val: val.content id should not be a template literal",
81
+ message: "Val: c.define id should not be a template literal",
82
82
  fix: (fixer) => fixer.replaceText(firstArg, `"${expectedValue}"`),
83
83
  });
84
84
  }
@@ -91,7 +91,7 @@ export default {
91
91
  if (rawArg) {
92
92
  context.report({
93
93
  node: firstArg,
94
- message: `Val: val.content id should match the filename. Expected: '${expectedValue}'. Found: '${firstArg.value}'`,
94
+ message: `Val: c.define id should match the filename. Expected: '${expectedValue}'. Found: '${firstArg.value}'`,
95
95
  fix: (fixer) =>
96
96
  fixer.replaceText(
97
97
  firstArg,
@@ -29,11 +29,11 @@ describe("plugin", () => {
29
29
  });
30
30
 
31
31
  test("no illegal modules for monorepos (projects that are not at root)", async () => {
32
- const code = `import { s, val } from "../val.config";
32
+ const code = `import { s, c } from "../val.config";
33
33
 
34
34
  export const schema = s.string();
35
35
 
36
- export default val.content(
36
+ export default c.define(
37
37
  "/something",
38
38
  schema,
39
39
  "React Server components also works"
@@ -48,11 +48,11 @@ export default val.content(
48
48
  });
49
49
 
50
50
  test("no illegal modules for monorepos (projects that are not at root) - nested", async () => {
51
- const code = `import { s, val } from "../../../../val.config";
51
+ const code = `import { s, c } from "../../../../val.config";
52
52
 
53
53
  export const schema = s.string();
54
54
 
55
- export default val.content(
55
+ export default c.define(
56
56
  "/something",
57
57
  schema,
58
58
  "React Server components also works"
@@ -68,11 +68,11 @@ export default val.content(
68
68
  );
69
69
  });
70
70
  test("no illegal modules for monorepos (projects that are not at root) - src", async () => {
71
- const code = `import { s, val } from "../../../../val.config";
71
+ const code = `import { s, c } from "../../../../val.config";
72
72
 
73
73
  export const schema = s.string();
74
74
 
75
- export default val.content(
75
+ export default c.define(
76
76
  "/something",
77
77
  schema,
78
78
  "React Server components also works"
@@ -19,36 +19,36 @@ ruleTester.run("export-content-must-be-valid", rule, {
19
19
  {
20
20
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
21
21
  code: `
22
- import { val, s } from '../val.config';
22
+ import { c, s } from '../val.config';
23
23
 
24
24
  export const schema = s.string();
25
- export default val.content('/foo/test', schema, '')`,
25
+ export default c.define('/foo/test', schema, '')`,
26
26
  },
27
27
  ],
28
28
  invalid: [
29
29
  {
30
30
  filename: path.join(process.cwd(), "./foo/test.ts"),
31
31
  code: `
32
- import { val, s } from '../val.config';
32
+ import { c, s } from '../val.config';
33
33
 
34
34
  export const schema = s.string();
35
- export default val.content('/foo/test', schema, '')`,
35
+ export default c.define('/foo/test', schema, '')`,
36
36
  errors: [
37
37
  {
38
- message: "Val: val.content should only be exported from .val files",
38
+ message: "Val: c.define should only be exported from .val files",
39
39
  },
40
40
  ],
41
41
  },
42
42
  {
43
43
  filename: path.join(process.cwd(), "./foo/test.js"),
44
44
  code: `
45
- import { val, s } from '../val.config';
45
+ import { c, s } from '../val.config';
46
46
 
47
47
  export const schema = s.string();
48
- export default val.content('/foo/test', schema, '')`,
48
+ export default c.define('/foo/test', schema, '')`,
49
49
  errors: [
50
50
  {
51
- message: "Val: val.content should only be exported from .val files",
51
+ message: "Val: c.define should only be exported from .val files",
52
52
  },
53
53
  ],
54
54
  },
@@ -20,59 +20,59 @@ ruleTester.run("no-illegal-imports", rule, {
20
20
  {
21
21
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
22
22
  code: `
23
- import { val, s } from '../val.config';
23
+ import { c, s } from '../val.config';
24
24
  import { eventSchema } from './event.val';
25
25
 
26
26
  export const schema = s.array(eventSchema);
27
- export default val.content('/foo/test', schema, [])`,
27
+ export default c.define('/foo/test', schema, [])`,
28
28
  },
29
29
  {
30
30
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
31
31
  code: `
32
- import { val, s } from '../val.config.ts';
32
+ import { c, s } from '../val.config.ts';
33
33
  import { eventSchema } from './event.val.ts';
34
34
 
35
35
  export const schema = s.array(eventSchema);
36
- export default val.content('/foo/test', schema, [])`,
36
+ export default c.define('/foo/test', schema, [])`,
37
37
  },
38
38
  {
39
39
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
40
40
  code: `
41
- import { val, s } from '../val.config.ts';
41
+ import { c, s } from '../val.config.ts';
42
42
  import type { Event } from './eventSchema';
43
43
 
44
44
  export const schema = s.array(s.string());
45
45
  type Test = Event;
46
- export default val.content('/foo/test', schema, [])`,
46
+ export default c.define('/foo/test', schema, [])`,
47
47
  },
48
48
  {
49
49
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
50
50
  code: `
51
- import { val, s } from '../val.config.ts';
51
+ import { c, s } from '../val.config.ts';
52
52
  import { type Event } from './eventSchema';
53
53
 
54
54
  export const schema = s.array(s.string());
55
55
  type Test = Event;
56
- export default val.content('/foo/test', schema, [])`,
56
+ export default c.define('/foo/test', schema, [])`,
57
57
  },
58
58
  {
59
59
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
60
60
  code: `
61
- import { val, s } from '../val.config.ts';
61
+ import { c, s } from '../val.config.ts';
62
62
 
63
63
  export const schema = s.string();
64
- export default val.content('/foo/test', schema, 'String')`,
64
+ export default c.define('/foo/test', schema, 'String')`,
65
65
  },
66
66
  ],
67
67
  invalid: [
68
68
  {
69
69
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
70
70
  code: `
71
- import { val, s } from '../val.config';
71
+ import { c, s } from '../val.config';
72
72
  import { eventSchema } from './event';
73
73
 
74
74
  export const schema = s.array(eventSchema);
75
- export default val.content('/foo/test', schema, [])`,
75
+ export default c.define('/foo/test', schema, [])`,
76
76
  errors: [
77
77
  {
78
78
  message:
@@ -83,12 +83,12 @@ export default val.content('/foo/test', schema, [])`,
83
83
  {
84
84
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
85
85
  code: `
86
- import { val, s } from '../val.config';
86
+ import { c, s } from '../val.config';
87
87
  import { eventSchema, type Unused } from './event';
88
88
 
89
89
  export const schema = s.array(eventSchema);
90
90
  type Event = Unused;
91
- export default val.content('/foo/test', schema, [])`,
91
+ export default c.define('/foo/test', schema, [])`,
92
92
  errors: [
93
93
  {
94
94
  message:
@@ -20,55 +20,55 @@ ruleTester.run("no-illegal-module-ids", rule, {
20
20
  valid: [
21
21
  {
22
22
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
23
- code: `import { val, s } from '../val.config.ts';
23
+ code: `import { c, s } from '../val.config.ts';
24
24
  export const schema = s.string();
25
- export default val.content('/foo/test', schema, 'String')`,
25
+ export default c.define('/foo/test', schema, 'String')`,
26
26
  },
27
27
  ],
28
28
  invalid: [
29
29
  {
30
30
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
31
- code: `import { val, s } from '../val.config.ts';
31
+ code: `import { c, s } from '../val.config.ts';
32
32
  export const schema = s.string();
33
- export default val.content('foo', schema, 'String')`,
33
+ export default c.define('foo', schema, 'String')`,
34
34
  errors: [
35
35
  {
36
36
  message:
37
- "Val: val.content id should match the filename. Expected: '/foo/test'. Found: 'foo'",
37
+ "Val: c.define id should match the filename. Expected: '/foo/test'. Found: 'foo'",
38
38
  },
39
39
  ],
40
- output: `import { val, s } from '../val.config.ts';
40
+ output: `import { c, s } from '../val.config.ts';
41
41
  export const schema = s.string();
42
- export default val.content('/foo/test', schema, 'String')`,
42
+ export default c.define('/foo/test', schema, 'String')`,
43
43
  },
44
44
  {
45
45
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
46
- code: `import { val, s } from "../val.config.ts";
46
+ code: `import { c, s } from "../val.config.ts";
47
47
  export const schema = s.string();
48
- export default val.content("foo", schema, 'String')`,
48
+ export default c.define("foo", schema, 'String')`,
49
49
  errors: [
50
50
  {
51
51
  message:
52
- "Val: val.content id should match the filename. Expected: '/foo/test'. Found: 'foo'",
52
+ "Val: c.define id should match the filename. Expected: '/foo/test'. Found: 'foo'",
53
53
  },
54
54
  ],
55
- output: `import { val, s } from "../val.config.ts";
55
+ output: `import { c, s } from "../val.config.ts";
56
56
  export const schema = s.string();
57
- export default val.content("/foo/test", schema, 'String')`,
57
+ export default c.define("/foo/test", schema, 'String')`,
58
58
  },
59
59
  {
60
60
  filename: path.join(process.cwd(), "./foo/test.val.ts"),
61
- code: `import { val, s } from "../val.config.ts";
61
+ code: `import { c, s } from "../val.config.ts";
62
62
  export const schema = s.string();
63
- export default val.content(\`foo\`, schema, 'String')`,
63
+ export default c.define(\`foo\`, schema, 'String')`,
64
64
  errors: [
65
65
  {
66
- message: "Val: val.content id should not be a template literal",
66
+ message: "Val: c.define id should not be a template literal",
67
67
  },
68
68
  ],
69
- output: `import { val, s } from "../val.config.ts";
69
+ output: `import { c, s } from "../val.config.ts";
70
70
  export const schema = s.string();
71
- export default val.content("/foo/test", schema, 'String')`,
71
+ export default c.define("/foo/test", schema, 'String')`,
72
72
  },
73
73
  ],
74
74
  });