DEV: Don't lint core files when target == plugins (#10259)

DEV: Don’t lint core files when target == plugins (#10259)

  • DEV: Don’t lint core files when target == plugins
  • Prettier the plugin/*.js files
  • Update eslintignore/prettierignore
  • Add eslint-plugin-ember and eslint-plugin-node
  • Properly lint all js files in all plugins
  • LINT: run prettier on test/*.js files
  • DEV: Run prettier checks on test/*.js files
  • ESLint plugins’ assets/javascripts and test/javascripts directories only
diff --git a/.eslintignore b/.eslintignore
index e877e00..f0d962b 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -8,7 +8,7 @@ lib/javascripts/locale/
 lib/javascripts/messageformat.js
 lib/highlight_js/
 plugins/**/lib/javascripts/locale
-public/javascripts/
+public/
 vendor/
 test/javascripts/test_helper.js
 test/javascripts/fixtures
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1febe56..b4a15c0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -136,27 +136,48 @@ jobs:
           bin/rake parallel:create
           bin/rake parallel:migrate
 
-      - name: Rubocop
-        if: env.BUILD_TYPE == 'LINT'
+      - name: Rubocop (core and core plugins)
+        if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
         run: bundle exec rubocop .
 
-      - name: ESLint
-        if: env.BUILD_TYPE == 'LINT'
+      - name: Rubocop (all plugins)
+        if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS'
+        run: bundle exec rubocop plugins
+
+      - name: ESLint (core)
+        if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
+        run: yarn eslint app/assets/javascripts test/javascripts
+
+      - name: ESLint (core plugins)
+        if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
         run: |
-          yarn eslint app/assets/javascripts test/javascripts
-          yarn eslint --global I18n --ext .es6 plugins
+          yarn eslint plugins/**/assets/javascripts plugins/**/test/javascripts
+          yarn eslint --global I18n --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts
 
-      - name: Core Prettier
+      - name: ESLint (all plugins)
+        if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS'
+        run: |
+          yarn eslint plugins/**/assets/javascripts plugins/**/test/javascripts
+          yarn eslint --global I18n --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts
+
+      - name: Prettier (core and core plugins)
         if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
         run: |
           yarn prettier -v
-          yarn prettier --list-different "app/assets/stylesheets/**/*.scss" "app/assets/javascripts/**/*.{js,es6}" "test/javascripts/**/*.{js,es6}"
-
-      - name: Plugin Prettier
+          yarn prettier --list-different \
+            "app/assets/stylesheets/**/*.scss" \
+            "app/assets/javascripts/**/*.{js,es6}" \
+            "test/javascripts/**/*.{js,es6}" \
+            "plugins/**/assets/stylesheets/**/*.scss" \
+            "plugins/**/assets/javascripts/**/*.{js,es6}"
+
+      - name: Prettier (all plugins)
         if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS'
         run: |
           yarn prettier -v
-          yarn prettier --list-different "plugins/**/assets/stylesheets/**/*.scss" "plugins/**/assets/javascripts/**/*.{js,es6}"
+          yarn prettier --list-different \
+            "plugins/**/assets/stylesheets/**/*.scss" \
+            "plugins/**/assets/javascripts/**/*.{js,es6}"
 
       - name: Core English locale
         if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
diff --git a/.prettierignore b/.prettierignore
index 019b7b8..b97584a 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -5,3 +5,21 @@ package.json
 config/locales/**/*.yml
 !config/locales/**/*.en*.yml
 script/import_scripts/**/*.yml
+
+app/assets/javascripts/env.js
+app/assets/javascripts/main_include_admin.js
+app/assets/javascripts/vendor.js
+app/assets/javascripts/locales/i18n.js
+app/assets/javascripts/ember-addons/
+app/assets/javascripts/discourse/lib/autosize.js
+lib/javascripts/locale/
+lib/javascripts/messageformat.js
+lib/highlight_js/
+plugins/**/lib/javascripts/locale
+public/
+vendor/
+test/javascripts/test_helper.js
+test/javascripts/fixtures
+test/javascripts/helpers/assertions.js
+node_modules/
+dist/
diff --git a/package.json b/package.json
index 22890f3..e17f8bb 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,8 @@
     "ember-template-lint": "^2.5.2",
     "eslint-config-discourse": "latest",
     "eslint-plugin-discourse-ember": "latest",
+    "eslint-plugin-ember": "^7.7.1",
+    "eslint-plugin-node": "^10.0.0",
     "lodash-cli": "https://github.com/lodash-archive/lodash-cli.git",
     "pretender": "^1.6",
     "puppeteer": "1.20",
diff --git a/yarn.lock b/yarn.lock
index 64bc583..7fdf765 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -100,6 +100,11 @@
     exec-sh "^0.3.2"
     minimist "^1.2.0"
 
+"@ember-data/rfc395-data@^0.0.4":
+  version "0.0.4"
+  resolved "https://registry.yarnpkg.com/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz#ecb86efdf5d7733a76ff14ea651a1b0ed1f8a843"
+  integrity sha512-tGRdvgC9/QMQSuSuJV45xoyhI0Pzjm7A9o/MVVA3HakXIImJbbzx/k/6dO9CUEQXIyS2y0fW6C1XaYOG7rY0FQ==
+
 "@fortawesome/fontawesome-free@5.11.2":
   version "5.11.2"
   resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.11.2.tgz#8644bc25b19475779a7b7c1fc104bc0a794f4465"
@@ -917,6 +922,19 @@ doctrine@^2.1.0:
   dependencies:
     esutils "^2.0.2"
 
+dot-case@^3.0.3:
+  version "3.0.3"
+  resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.3.tgz#21d3b52efaaba2ea5fda875bb1aa8124521cf4aa"
+  integrity sha512-7hwEmg6RiSQfm/GwPL4AAWXKy3YNNZA3oFv2Pdiey0mwkRCPZ9x6SZbkLcn8Ma5PYeVokzoD4Twv2n7LKp5WeA==
+  dependencies:
+    no-case "^3.0.3"
+    tslib "^1.10.0"
+
+ember-rfc176-data@^0.3.12:
+  version "0.3.13"
+  resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.13.tgz#ed1712a26e65fec703655f35410414aa1982cf3b"
+  integrity sha512-m9JbwQlT6PjY7x/T8HslnXP7Sz9bx/pz3FrNfNi2NesJnbNISly0Lix6NV1fhfo46572cpq4jrM+/6yYlMefTQ==
+
 ember-template-lint@^2.5.2:
   version "2.8.0"
   resolved "https://registry.yarnpkg.com/ember-template-lint/-/ember-template-lint-2.8.0.tgz#01ddc6daf9c8497fe5cfcc55cde25f203a7d8bd3"
@@ -1002,6 +1020,23 @@ eslint-plugin-discourse-ember@latest:
   dependencies:
     requireindex "~1.1.0"
 
+eslint-plugin-ember@^7.7.1:
+  version "7.13.0"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-ember/-/eslint-plugin-ember-7.13.0.tgz#a1df7794f06cdc6e1b8acfe6c59db5cf861f53dc"
+  integrity sha512-qIbw4uP0qUJoiWF4+7MTJWqwEN86RGmBNId0cwSoHoVNWtcw50R1ajYgxM1Q5FVUdoisVeSl9lKVRh5zkDFl+g==
+  dependencies:
+    "@ember-data/rfc395-data" "^0.0.4"
+    ember-rfc176-data "^0.3.12"
+    snake-case "^3.0.3"
+
+eslint-plugin-es@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-2.0.0.tgz#0f5f5da5f18aa21989feebe8a73eadefb3432976"
+  integrity sha512-f6fceVtg27BR02EYnBhgWLFQfK6bN4Ll0nQFrBHOlCsAyxeZkn0NHns5O0YZOPrV1B3ramd6cgFwaoFLcSkwEQ==
+  dependencies:
+    eslint-utils "^1.4.2"
+    regexpp "^3.0.0"
+
 eslint-plugin-lodash@^6.0.0:
   version "6.0.0"
   resolved "https://registry.yarnpkg.com/eslint-plugin-lodash/-/eslint-plugin-lodash-6.0.0.tgz#70fa487ab632e62627ecf01ad3e85c228e3ab9d3"
@@ -1009,6 +1044,18 @@ eslint-plugin-lodash@^6.0.0:
   dependencies:
     lodash "^4.17.15"
 
+eslint-plugin-node@^10.0.0:
+  version "10.0.0"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-10.0.0.tgz#fd1adbc7a300cf7eb6ac55cf4b0b6fc6e577f5a6"
+  integrity sha512-1CSyM/QCjs6PXaT18+zuAXsjXGIGo5Rw630rSKwokSs2jrYURQc4R5JZpoanNCqwNmepg+0eZ9L7YiRUJb8jiQ==
+  dependencies:
+    eslint-plugin-es "^2.0.0"
+    eslint-utils "^1.4.2"
+    ignore "^5.1.1"
+    minimatch "^3.0.4"
+    resolve "^1.10.1"
+    semver "^6.1.0"
+
 eslint-scope@3.7.1:
   version "3.7.1"
   resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
@@ -1025,11 +1072,23 @@ eslint-scope@^3.7.1:
     esrecurse "^4.1.0"
     estraverse "^4.1.1"
 
+eslint-utils@^1.4.2:
+  version "1.4.3"
+  resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f"
+  integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==

[... diff too long, it was truncated ...]

GitHub sha: d684d5fb

1 Like

This commit appears in #10259 which was merged by CvX.