@discourse/lint-configs 2.38.0 → 2.39.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.
@@ -0,0 +1,38 @@
1
+ import path from "node:path";
2
+
3
+ function isTestFile(filename) {
4
+ return /tests?\/(javascripts\/)?(acceptance|integration|unit)/.test(filename);
5
+ }
6
+
7
+ function hasTestSuffix(filename) {
8
+ return path.parse(filename).name.endsWith("-test");
9
+ }
10
+
11
+ export default {
12
+ meta: {
13
+ type: "problem",
14
+ docs: {
15
+ description: "Require test filenames to end with `-test`.",
16
+ },
17
+ schema: [], // no options
18
+ },
19
+
20
+ create(context) {
21
+ return {
22
+ Program(node) {
23
+ const filename = context.getFilename();
24
+
25
+ if (!isTestFile(filename)) {
26
+ return;
27
+ }
28
+
29
+ if (!hasTestSuffix(filename)) {
30
+ context.report({
31
+ node,
32
+ message: "Test filenames must end with `-test`.",
33
+ });
34
+ }
35
+ },
36
+ };
37
+ },
38
+ };
package/eslint.mjs CHANGED
@@ -29,6 +29,7 @@ import noUnusedServices from "./eslint-rules/no-unused-services.mjs";
29
29
  import pluginApiNoVersion from "./eslint-rules/plugin-api-no-version.mjs";
30
30
  import serviceInjectImport from "./eslint-rules/service-inject-import.mjs";
31
31
  import templateTagNoSelfThis from "./eslint-rules/template-tag-no-self-this.mjs";
32
+ import testFilenameSuffix from "./eslint-rules/test-filename-suffix.mjs";
32
33
  import themeImports from "./eslint-rules/theme-imports.mjs";
33
34
  import truthHelpersImports from "./eslint-rules/truth-helpers-imports.mjs";
34
35
 
@@ -140,6 +141,7 @@ export default [
140
141
  "no-route-template": noRouteTemplate,
141
142
  "template-tag-no-self-this": templateTagNoSelfThis,
142
143
  "moved-packages-import-paths": movedPackagesImportPaths,
144
+ "test-filename-suffix": testFilenameSuffix,
143
145
  },
144
146
  },
145
147
  },
@@ -207,6 +209,7 @@ export default [
207
209
  "ember/no-unnecessary-index-route": "off", // the assumption made in this rule doesn't seem to be true in discourse router
208
210
  "ember/no-unnecessary-service-injection-argument": "error",
209
211
  "ember/no-replace-test-comments": "error",
212
+ "qunit/no-identical-names": "off", // the rule doesn't consider that tests might be in different `acceptance` modules
210
213
  "sort-class-members/sort-class-members": [
211
214
  "error",
212
215
  {
@@ -305,6 +308,7 @@ export default [
305
308
  "discourse/template-tag-no-self-this": ["error"],
306
309
  "discourse/no-route-template": ["error"],
307
310
  "discourse/moved-packages-import-paths": ["error"],
311
+ "discourse/test-filename-suffix": ["error"],
308
312
  },
309
313
  },
310
314
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discourse/lint-configs",
3
- "version": "2.38.0",
3
+ "version": "2.39.0",
4
4
  "description": "Shareable lint configs for Discourse core, plugins, and themes",
5
5
  "author": "Discourse",
6
6
  "license": "MIT",