From d684d5fba4e6c33e0253a9ff14f2aac48530ef74 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 25 Aug 2020 11:40:40 +0200 Subject: [PATCH] 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 --- .eslintignore | 2 +- .github/workflows/ci.yml | 43 +++++++++++----- .prettierignore | 18 +++++++ package.json | 2 + yarn.lock | 104 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 156 insertions(+), 13 deletions(-) diff --git a/.eslintignore b/.eslintignore index e877e0062b6..f0d962bb0f4 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 1febe5632a1..b4a15c0fb1b 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' - run: | - yarn eslint app/assets/javascripts test/javascripts - yarn eslint --global I18n --ext .es6 plugins + - name: Rubocop (all plugins) + if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'PLUGINS' + run: bundle exec rubocop plugins - - name: Core Prettier + - 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 plugins/**/assets/javascripts plugins/**/test/javascripts + yarn eslint --global I18n --ext .es6 plugins/**/assets/javascripts plugins/**/test/javascripts + + - 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}" + 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: Plugin Prettier + - 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 019b7b87a0b..b97584a5f29 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 22890f390cd..e17f8bbb70f 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 64bc5839b73..7fdf765503d 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== + dependencies: + eslint-visitor-keys "^1.1.0" + eslint-visitor-keys@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== +eslint-visitor-keys@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== + eslint@^4.19: version "4.19.1" resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300" @@ -1537,6 +1596,11 @@ ignore@^3.3.3: resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug== +ignore@^5.1.1: + version "5.1.8" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" + integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== + ignore@^5.1.4: version "5.1.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.6.tgz#643194ad4bf2712f37852e386b6998eff0db2106" @@ -1941,6 +2005,13 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" +lower-case@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.1.tgz#39eeb36e396115cc05e29422eaea9e692c9408c7" + integrity sha512-LiWgfDLLb1dwbFQZsSglpRj+1ctGnayXz3Uv0/WO8n558JycT5fg6zkNcnW0G68Nn0aEldTFeEfmjCfmqry/rQ== + dependencies: + tslib "^1.10.0" + lru-cache@^4.0.1: version "4.1.5" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" @@ -2175,6 +2246,14 @@ nise@^4.0.1: just-extend "^4.0.2" path-to-regexp "^1.7.0" +no-case@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.3.tgz#c21b434c1ffe48b39087e86cfb4d2582e9df18f8" + integrity sha512-ehY/mVQCf9BL0gKfsJBvFJen+1V//U+0HQMPrWct40ixE4jnv0bfvxDbWtAHL9EcaPEOJHVVYKoQn1TlZUB8Tw== + dependencies: + lower-case "^2.0.1" + tslib "^1.10.0" + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -2469,6 +2548,11 @@ regexpp@^1.0.1: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab" integrity sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw== +regexpp@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" + integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -2532,7 +2616,7 @@ resolve@1.5.0: dependencies: path-parse "^1.0.5" -resolve@^1.17.0: +resolve@^1.10.1, resolve@^1.17.0: version "1.17.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== @@ -2665,6 +2749,11 @@ semver@^5.3.0, semver@^5.5.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== +semver@^6.1.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" @@ -2727,6 +2816,14 @@ slice-ansi@1.0.0: dependencies: is-fullwidth-code-point "^2.0.0" +snake-case@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.3.tgz#c598b822ab443fcbb145ae8a82c5e43526d5bbee" + integrity sha512-WM1sIXEO+rsAHBKjGf/6R1HBBcgbncKS08d2Aqec/mrDSpU80SiOU41hO7ny6DToHSyrlwTYzQBIK1FPSx4Y3Q== + dependencies: + dot-case "^3.0.3" + tslib "^1.10.0" + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -2965,6 +3062,11 @@ trim-right@^1.0.1: resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= +tslib@^1.10.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"