@discourse/lint-configs 2.2.2 → 2.3.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.
- package/eslint-rules/discourse-common-imports.mjs +80 -0
- package/eslint.mjs +12 -1
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
meta: {
|
|
3
|
+
type: "suggestion",
|
|
4
|
+
docs: {
|
|
5
|
+
description:
|
|
6
|
+
"disallow imports from 'discourse-common' and replace with modern equivalents",
|
|
7
|
+
category: "Best Practices",
|
|
8
|
+
recommended: false,
|
|
9
|
+
},
|
|
10
|
+
fixable: "code",
|
|
11
|
+
schema: [], // no options
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
ImportDeclaration(node) {
|
|
16
|
+
const modulePath = node.source.value.toLowerCase();
|
|
17
|
+
if (MAPPINGS[modulePath]) {
|
|
18
|
+
const newModule = MAPPINGS[modulePath];
|
|
19
|
+
context.report({
|
|
20
|
+
node,
|
|
21
|
+
message: `Importing ${modulePath} is no longer allowed. Use ${newModule} instead.`,
|
|
22
|
+
fix(fixer) {
|
|
23
|
+
return fixer.replaceText(node.source, `"${newModule}"`);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const MAPPINGS = {
|
|
33
|
+
"discourse-common/helpers/base-path": "discourse/helpers/base-path",
|
|
34
|
+
"discourse-common/helpers/base-url": "discourse/helpers/base-url",
|
|
35
|
+
"discourse-common/helpers/bound-i18n": "discourse/helpers/bound-i18n",
|
|
36
|
+
"discourse-common/helpers/component-for-collection":
|
|
37
|
+
"discourse/helpers/component-for-collection",
|
|
38
|
+
"discourse-common/helpers/component-for-row":
|
|
39
|
+
"discourse/helpers/component-for-row",
|
|
40
|
+
"discourse-common/helpers/d-icon": "discourse/helpers/d-icon",
|
|
41
|
+
"discourse-common/helpers/fa-icon": "discourse/helpers/fa-icon",
|
|
42
|
+
"discourse-common/helpers/get-url": "discourse/helpers/get-url",
|
|
43
|
+
"discourse-common/helpers/html-safe": "discourse/helpers/html-safe",
|
|
44
|
+
"discourse-common/helpers/i18n-yes-no": "discourse/helpers/i18n-yes-no",
|
|
45
|
+
// "discourse-common/helpers/i18n": "discourse/helpers/i18n", // This one is handled by i18n-import-location
|
|
46
|
+
"discourse-common/lib/attribute-hook": "discourse/lib/attribute-hook",
|
|
47
|
+
"discourse-common/lib/avatar-utils": "discourse/lib/avatar-utils",
|
|
48
|
+
"discourse-common/lib/case-converter": "discourse/lib/case-converter",
|
|
49
|
+
"discourse-common/lib/debounce": "discourse/lib/debounce",
|
|
50
|
+
"discourse-common/lib/deprecated": "discourse/lib/deprecated",
|
|
51
|
+
"discourse-common/lib/discourse-template-map":
|
|
52
|
+
"discourse/lib/discourse-template-map",
|
|
53
|
+
"discourse-common/lib/dom-from-string": "discourse/lib/dom-from-string",
|
|
54
|
+
"discourse-common/lib/escape": "discourse/lib/escape",
|
|
55
|
+
"discourse-common/lib/get-owner": "discourse/lib/get-owner",
|
|
56
|
+
"discourse-common/lib/get-url": "discourse/lib/get-url",
|
|
57
|
+
"discourse-common/lib/helpers": "discourse/lib/helpers",
|
|
58
|
+
"discourse-common/lib/icon-library": "discourse/lib/icon-library",
|
|
59
|
+
"discourse-common/lib/later": "discourse/lib/later",
|
|
60
|
+
"discourse-common/lib/loader-shim": "discourse/lib/loader-shim",
|
|
61
|
+
"discourse-common/lib/object": "discourse/lib/object",
|
|
62
|
+
"discourse-common/lib/popular-themes": "discourse/lib/popular-themes",
|
|
63
|
+
"discourse-common/lib/raw-handlebars-helpers":
|
|
64
|
+
"discourse/lib/raw-handlebars-helpers",
|
|
65
|
+
"discourse-common/lib/raw-handlebars": "discourse/lib/raw-handlebars",
|
|
66
|
+
"discourse-common/lib/raw-templates": "discourse/lib/raw-templates",
|
|
67
|
+
"discourse-common/lib/suffix-trie": "discourse/lib/suffix-trie",
|
|
68
|
+
"discourse-common/utils/decorator-alias": "discourse/lib/decorator-alias",
|
|
69
|
+
"discourse-common/utils/decorators": "discourse/lib/decorators",
|
|
70
|
+
"discourse-common/utils/dom-utils": "discourse/lib/dom-utils",
|
|
71
|
+
"discourse-common/utils/escape-regexp": "discourse/lib/escape-regexp",
|
|
72
|
+
"discourse-common/utils/extract-value": "discourse/lib/extract-value",
|
|
73
|
+
"discourse-common/utils/handle-descriptor": "discourse/lib/handle-descriptor",
|
|
74
|
+
"discourse-common/utils/is-descriptor": "discourse/lib/is-descriptor",
|
|
75
|
+
"discourse-common/utils/macro-alias": "discourse/lib/macro-alias",
|
|
76
|
+
"discourse-common/utils/multi-cache": "discourse/lib/multi-cache",
|
|
77
|
+
"discourse-common/deprecation-workflow": "discourse/deprecation-workflow",
|
|
78
|
+
"discourse-common/resolver": "discourse/resolver",
|
|
79
|
+
"discourse-common/config/environment": "discourse/lib/environment",
|
|
80
|
+
};
|
package/eslint.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createConfigItem } from "@babel/core";
|
|
1
2
|
import BabelParser from "@babel/eslint-parser";
|
|
2
3
|
import PluginProposalDecorators from "@babel/plugin-proposal-decorators";
|
|
3
4
|
import js from "@eslint/js";
|
|
@@ -12,6 +13,7 @@ import SimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
|
12
13
|
import SortClassMembers from "eslint-plugin-sort-class-members";
|
|
13
14
|
import globals from "globals";
|
|
14
15
|
import deprecatedLookups from "./eslint-rules/deprecated-lookups.mjs";
|
|
16
|
+
import discourseCommonImports from "./eslint-rules/discourse-common-imports.mjs";
|
|
15
17
|
import i18nImport from "./eslint-rules/i18n-import-location.mjs";
|
|
16
18
|
import i18nT from "./eslint-rules/i18n-t.mjs";
|
|
17
19
|
import noSimpleQueryselector from "./eslint-rules/no-simple-queryselector.mjs";
|
|
@@ -32,7 +34,13 @@ export default [
|
|
|
32
34
|
parserOptions: {
|
|
33
35
|
requireConfigFile: false,
|
|
34
36
|
babelOptions: {
|
|
35
|
-
plugins: [
|
|
37
|
+
plugins: [
|
|
38
|
+
createConfigItem([
|
|
39
|
+
PluginProposalDecorators,
|
|
40
|
+
{ legacy: true },
|
|
41
|
+
"@babel/plugin-proposal-decorators",
|
|
42
|
+
]),
|
|
43
|
+
],
|
|
36
44
|
},
|
|
37
45
|
},
|
|
38
46
|
|
|
@@ -100,6 +108,7 @@ export default [
|
|
|
100
108
|
"service-inject-import": serviceInjectImport,
|
|
101
109
|
"no-simple-queryselector": noSimpleQueryselector,
|
|
102
110
|
"deprecated-lookups": deprecatedLookups,
|
|
111
|
+
"discourse-common-imports": discourseCommonImports,
|
|
103
112
|
},
|
|
104
113
|
},
|
|
105
114
|
},
|
|
@@ -282,6 +291,8 @@ export default [
|
|
|
282
291
|
"discourse/service-inject-import": ["error"],
|
|
283
292
|
"discourse/no-simple-queryselector": ["error"],
|
|
284
293
|
"discourse/deprecated-lookups": ["error"],
|
|
294
|
+
// TODO: enable by default once 98fa42f2 is widely available
|
|
295
|
+
// "discourse/discourse-common-imports": ["error"],
|
|
285
296
|
},
|
|
286
297
|
},
|
|
287
298
|
{
|