Travis 测试因 eslint 而失败

我有两个插件在 Travis 测试中失败了。看起来它们里面没有任何 ES6 文件,所以 ESLint 觉得被冷落了吗?

运行 linters/prettyfiers
eslint yarn run v1.22.5
$ /var/www/discourse/node_modules/.bin/eslint -v
v6.8.0
Done in 0.32s.
prettier yarn run v1.22.5
$ /var/www/discourse/node_modules/.bin/prettier -v
2.1.1
Done in 0.28s.
[2020-09-07 01:34:21] bundle exec rubocop --parallel plugins/discourse-allow-pm-to-staff
检查 2 个文件
..
已检查 2 个文件,未发现违规
[2020-09-07 01:34:22] bundle exec ruby script/i18n_lint.rb plugins/discourse-allow-pm-to-staff/config/locales/{client,server}.en.yml
[2020-09-07 01:34:23] yarn eslint --global I18n --ext .es6 plugins/discourse-allow-pm-to-staff
yarn run v1.22.5
$ /var/www/discourse/node_modules/.bin/eslint --global I18n --ext .es6 plugins/discourse-allow-pm-to-staff
哎呀!出错了!: (
ESLint: 6.8.0.
未找到匹配模式 "plugins/discourse-allow-pm-to-staff" 的文件。
请检查模式中是否有拼写错误。
错误:命令执行失败,退出代码为 2。
有关此命令的文档,请访问 https://yarnpkg.com/en/docs/cli/run
列出 discourse-allow-pm-to-staff 中的 prettier 违规:

1 个赞

是的,eslint 不喜欢无所事事。这样做让它感觉更有用。

mkdir -p assets/javascripts/discourse
touch assets/javascripts/discourse/eslint.js.es6
git add assets/javascripts/discourse/eslint.js.es6
git commit -m 'try to make eslint not feel left out'
git push

不过,我认为这才是真正的解决方案:

https://github.com/discourse/discourse/compare/master...pfaffman:patch-5

1 个赞

啊,但你怎么能在 eslint 不报错的情况下提交 PR 呢? :wink:

1 个赞

我对这里发生的事几乎一窍不通,差点没听懂你的笑话!

1 个赞

是的,我前几天已经为 GitHub Actions 推送了这个修复:

基本上,新的 eslint 在匹配不到任何内容时不再喜欢这样。我也借此机会简化了命令,同样会应用到我们的 rake 任务中,不用担心。

7 个赞

这应该能解决问题:

请告诉我结果如何 :+1:

4 个赞
2 files inspected, no offenses detected
[2020-09-10 18:43:13] bundle exec ruby script/i18n_lint.rb plugins/discourse-topic-default-tag/config/locales/{client,server}.en.yml
[2020-09-10 18:43:13] yarn eslint --global I18n --ext .es6 plugins/discourse-topic-default-tag
yarn run v1.22.5
$ /var/www/discourse/node_modules/.bin/eslint --global I18n --ext .es6 plugins/discourse-topic-default-tag
Oops! Something went wrong! :(
ESLint: 6.8.0.
No files matching the pattern "plugins/discourse-topic-default-tag" were found.
Please check for typing mistakes in the pattern.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Listing prettier offenses in discourse-topic-default-tag:

哎呀,是我的错。

哦对,它确实使用了 discourse-plugin-ci 相关组件,如果你查看代码就会看到:

而我的提交尚未出现在 tests-passed 中

3 个赞

此主题在最后一次回复后 2 天自动关闭。不再允许新回复。