@discourse/lint-configs 1.0.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/.eslintrc.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./eslintrc.cjs");
@@ -0,0 +1 @@
1
+ pnpm-lock.yaml
@@ -0,0 +1,17 @@
1
+ module.exports = {
2
+ plugins: ["prettier-plugin-ember-template-tag"],
3
+ overrides: [
4
+ {
5
+ files: "*.gjs",
6
+ options: {
7
+ parser: "ember-template-tag",
8
+ },
9
+ },
10
+ {
11
+ files: "*.gts",
12
+ options: {
13
+ parser: "ember-template-tag",
14
+ },
15
+ },
16
+ ],
17
+ };
@@ -0,0 +1,13 @@
1
+ const eslint = require("./eslintrc.cjs");
2
+
3
+ const config = { ...eslint };
4
+ config.ignorePatterns = ["javascripts/vendor/*"];
5
+ config.overrides.push({
6
+ files: ["*.js", "*.gjs"],
7
+ globals: {
8
+ settings: "readonly",
9
+ themePrefix: "readonly",
10
+ },
11
+ });
12
+
13
+ module.exports = config;
package/eslintrc.cjs ADDED
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+
3
+ /* eslint-env node */
4
+
5
+ // Copied from "ember-template-imports/lib/utils"
6
+ const TEMPLATE_TAG_PLACEHOLDER = "__GLIMMER_TEMPLATE";
7
+
8
+ module.exports = {
9
+ root: true,
10
+ parser: "@babel/eslint-parser",
11
+ env: {
12
+ browser: true,
13
+ builtin: true,
14
+ es6: true,
15
+ node: true,
16
+ },
17
+ parserOptions: {
18
+ ecmaVersion: 2018,
19
+ sourceType: "module",
20
+ requireConfigFile: false,
21
+ babelOptions: {
22
+ plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]],
23
+ },
24
+ },
25
+ plugins: [
26
+ "ember",
27
+ "sort-class-members",
28
+ "decorator-position",
29
+ "simple-import-sort",
30
+ ],
31
+ globals: {
32
+ _: "off",
33
+ $: "readonly",
34
+ acceptance: "off",
35
+ asyncRender: "off",
36
+ Blob: "readonly",
37
+ bootbox: "off",
38
+ click: "off",
39
+ count: "off",
40
+ currentPath: "off",
41
+ currentRouteName: "off",
42
+ currentURL: "off",
43
+ currentUser: "off",
44
+ define: "readonly",
45
+ Discourse: "off",
46
+ Ember: "off",
47
+ exists: "off",
48
+ File: "readonly",
49
+ fillIn: "off",
50
+ find: "off",
51
+ getSettledState: "off",
52
+ globalThis: "readonly",
53
+ hasModule: "off",
54
+ invisible: "off",
55
+ jQuery: "off",
56
+ keyboardHelper: "off",
57
+ keyEvent: "off",
58
+ moduleFor: "off",
59
+ moment: "readonly",
60
+ pauseTest: "readonly",
61
+ Pretender: "off",
62
+ Promise: "readonly",
63
+ query: "off",
64
+ queryAll: "off",
65
+ QUnit: "off",
66
+ require: "readonly",
67
+ requirejs: "readonly",
68
+ sandbox: "off",
69
+ sinon: "off",
70
+ test: "off",
71
+ testDone: "off",
72
+ testStart: "off",
73
+ triggerEvent: "off",
74
+ visible: "off",
75
+ visit: "off",
76
+ waitUntil: "off",
77
+ },
78
+ rules: {
79
+ "block-scoped-var": 2,
80
+ "dot-notation": 0,
81
+ eqeqeq: [2, "allow-null"],
82
+ "guard-for-in": 2,
83
+ "no-alert": 2,
84
+ "no-bitwise": 2,
85
+ "no-caller": 2,
86
+ "no-cond-assign": 0,
87
+ "no-console": 2,
88
+ "no-debugger": 2,
89
+ "no-empty": 0,
90
+ "no-eval": 2,
91
+ "no-extend-native": 2,
92
+ "no-extra-parens": 0,
93
+ "no-inner-declarations": 2,
94
+ "no-irregular-whitespace": 2,
95
+ "no-iterator": 2,
96
+ "no-loop-func": 2,
97
+ "no-mixed-spaces-and-tabs": 2,
98
+ "no-multi-str": 2,
99
+ "no-new": 2,
100
+ "no-plusplus": 0,
101
+ "no-proto": 2,
102
+ "no-script-url": 2,
103
+ "no-sequences": 2,
104
+ "no-shadow": 2,
105
+ "no-this-before-super": 2,
106
+ "no-trailing-spaces": 2,
107
+ "no-undef": 2,
108
+ "no-unused-vars": 2,
109
+ "no-with": 2,
110
+ "no-var": 2,
111
+ radix: 2,
112
+ semi: 2,
113
+ strict: 0,
114
+ "valid-typeof": 2,
115
+ "wrap-iife": [2, "inside"],
116
+ curly: 2,
117
+ "no-duplicate-imports": 2,
118
+ "object-shorthand": ["error", "properties"],
119
+ "no-dupe-class-members": 2,
120
+ "sort-class-members/sort-class-members": [
121
+ 2,
122
+ {
123
+ order: [
124
+ "[static-properties]",
125
+ "[static-methods]",
126
+ "[injected-services]",
127
+ "[injected-controllers]",
128
+ "[tracked-properties]",
129
+ "[properties]",
130
+ "[private-properties]",
131
+ "constructor",
132
+ "[everything-else]",
133
+ "[template-tag]",
134
+ ],
135
+ groups: {
136
+ // https://github.com/ember-cli/eslint-plugin-ember/issues/1896
137
+ // This only sort of works: in addition to the issues mentioned
138
+ // above, it doesn't seem to reliably enforce the order, e.g.
139
+ // [injected-services] -> <template> -> [injected-services]
140
+ // doesn't seem to trigger the error. That being said, it does
141
+ // work sometimes and this is needed to avoid emitting errors
142
+ // in the limited cases where it does work.
143
+ "template-tag": [
144
+ { type: "property", name: `/${TEMPLATE_TAG_PLACEHOLDER}/` },
145
+ ],
146
+ "injected-services": [
147
+ { groupByDecorator: "service", type: "property" },
148
+ ],
149
+ "injected-controllers": [
150
+ { groupByDecorator: "controller", type: "property" },
151
+ ],
152
+ "tracked-properties": [
153
+ { groupByDecorator: "tracked", type: "property" },
154
+ ],
155
+ "private-properties": [
156
+ { type: "property", private: true },
157
+ { type: "property", name: "/_.+/" },
158
+ ],
159
+ },
160
+ accessorPairPositioning: "getThenSet",
161
+ stopAfterFirstProblem: false,
162
+ },
163
+ ],
164
+ "decorator-position/decorator-position": ["error", { printWidth: 80 }],
165
+ "simple-import-sort/imports": [
166
+ "error",
167
+ {
168
+ groups: [
169
+ [
170
+ // Ember/glimmer
171
+ "^@glimmer/",
172
+ "^@ember/",
173
+ // Any other packages ('longest match wins')
174
+ "",
175
+ // Internal
176
+ "^discourse/",
177
+ "^discourse-common/",
178
+ "^discourse-.+",
179
+ "^admin/",
180
+ "^wizard/",
181
+ "^I18n$",
182
+ "^select-kit/",
183
+ "^float-kit/",
184
+ "^truth-helpers/",
185
+ // Plugins
186
+ "^discourse/plugins/",
187
+ // Relative
188
+ "^\\.\\./",
189
+ "^\\./",
190
+ ],
191
+ ],
192
+ },
193
+ ],
194
+ },
195
+
196
+ // https://github.com/ember-cli/eslint-plugin-ember/issues/1895
197
+ // We may eventually be able to drop this by extending the base
198
+ // config from eslint-plugin-ember. In the meantime, this
199
+ overrides: [
200
+ {
201
+ files: ["**/*.gjs", "**/*.gts"],
202
+ processor: "ember/<template>",
203
+ globals: {
204
+ [TEMPLATE_TAG_PLACEHOLDER]: "readonly",
205
+ },
206
+ },
207
+ ],
208
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@discourse/lint-configs",
3
+ "version": "1.0.0",
4
+ "description": "Shareable lint configs for Discourse core, plugins, and themes",
5
+ "author": "Discourse",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "discourse"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/discourse/eslint-config-discourse.git"
13
+ },
14
+ "homepage": "https://github.com/discourse/eslint-config-discourse#readme",
15
+ "type": "module",
16
+ "exports": {
17
+ "./eslint": {
18
+ "require": "./eslintrc.cjs"
19
+ },
20
+ "./eslint-theme": {
21
+ "require": "./eslint-theme.cjs"
22
+ },
23
+ "./prettier": {
24
+ "require": "./.prettierrc.cjs"
25
+ },
26
+ "./template-lint": {
27
+ "require": "./template-lint.config.cjs"
28
+ }
29
+ },
30
+ "scripts": {
31
+ "lint": "eslint --no-error-on-unmatched-pattern **/*.cjs **/*.js && pnpm prettier --check .",
32
+ "test": "cd ../test && node test.js"
33
+ },
34
+ "dependencies": {
35
+ "@babel/core": "^7.23.2",
36
+ "@babel/eslint-parser": "^7.22.15",
37
+ "@babel/plugin-proposal-decorators": "^7.23.2",
38
+ "ember-template-lint": "^5.11.2",
39
+ "eslint": "^8.51.0",
40
+ "eslint-plugin-decorator-position": "^5.0.2",
41
+ "eslint-plugin-ember": "^11.11.1",
42
+ "eslint-plugin-simple-import-sort": "^10.0.0",
43
+ "eslint-plugin-sort-class-members": "^1.19.0",
44
+ "globals": "^13.23.0",
45
+ "prettier": "^2.8.8",
46
+ "prettier-plugin-ember-template-tag": "^0.3.2"
47
+ },
48
+ "peerDependencies": {
49
+ "ember-template-lint": "^5.11.2",
50
+ "eslint": "^8.51.0",
51
+ "prettier": "^2.8.8"
52
+ }
53
+ }
@@ -0,0 +1,33 @@
1
+ module.exports = {
2
+ extends: ["recommended", "stylistic"],
3
+ rules: {
4
+ "no-positive-tabindex": false,
5
+ "no-autofocus-attribute": false,
6
+ "require-mandatory-role-attributes": false,
7
+ "require-media-caption": false,
8
+
9
+ // GJS compatibility
10
+ "modifier-name-case": false,
11
+
12
+ // Pending
13
+ "require-presentational-children": false,
14
+ "no-duplicate-landmark-elements": false,
15
+ "no-passed-in-event-handlers": false,
16
+ "no-inline-styles": false,
17
+ "no-link-to-tagname": false,
18
+ "no-implicit-this": false,
19
+ "require-valid-alt-text": false,
20
+ "link-href-attributes": false,
21
+ "no-curly-component-invocation": false,
22
+ "no-link-to-positional-params": false,
23
+ "require-input-label": false,
24
+ "no-route-action": false,
25
+ "no-action": false,
26
+
27
+ // Prettier compatibility
28
+ "eol-last": false,
29
+ "self-closing-void-elements": false,
30
+ "block-indentation": false,
31
+ quotes: false,
32
+ },
33
+ };