Replace dangerfile with eslint plugins

We currently use dangerfile only for jasmine fdescribe/fit tests and
Angular onPush checks.

Both can be replaced by eslint plugins.
pull/9487/head
Oliver Günther 3 years ago
parent 9f5ce6cb9a
commit 02bd8ef9c2
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 4
      .github/workflows/eslint-core.yml
  2. 5
      .github/workflows/rubocop-core.yml
  3. 11
      .github/workflows/test-core.yml
  4. 24
      Dangerfile
  5. 3
      Gemfile
  6. 1
      Gemfile.lock
  7. 15
      frontend/.eslintrc.js
  8. 12
      frontend/package-lock.json
  9. 6
      frontend/package.json
  10. 46
      script/ci/dangerfile.sh

@ -1,4 +1,4 @@
name: Core/eslint
name: "Core/Frontend-Linting"
on:
pull_request:
branches:
@ -10,7 +10,7 @@ on:
jobs:
eslint:
name: runner / eslint
name: eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

@ -1,4 +1,5 @@
name: Core/rubocop
name: "Core/Backend-Linting"
on:
pull_request:
branches:
@ -9,7 +10,7 @@ on:
jobs:
rubocop:
name: runner / rubocop
name: rubocop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

@ -15,17 +15,6 @@ on:
- 'help/**'
jobs:
danger:
if: github.repository == 'opf/openproject'
runs-on: [ubuntu-latest]
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50
- uses: danger/danger@master
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
units:
name: Units
if: github.repository == 'opf/openproject'

@ -1,24 +0,0 @@
# Fail if jasmine specs contain fdescribe or fit
fail("jasmine fdescribe/fit left in tests") if `grep --include '*.spec.ts' -rP 'fdescribe\\(|fit\\(' frontend/src/`.length > 1
# Search for modified components not being made OnPush
git.modified_files
.select { |path| path.include?('frontend') && path.end_with?('.ts') }
.each do |path|
next unless File.readable?(path)
lines = File.readlines (path)
# Ignore non component files
component_line = lines.grep(/@Component/)[0]
next unless component_line
# Check for missing onPush
unless lines.grep(/changeDetection:\s+ChangeDetectionStrategy.OnPush/).length > 0
warn(
"Please use `ChangeDetectionStrategy.OnPush` for this component",
file: path,
line: lines.index(component_line) || 0
)
end
end

@ -282,9 +282,6 @@ group :development, :test do
gem 'pry-rescue', '~> 1.5.2'
gem 'pry-stack_explorer', '~> 0.6.0'
# Dangerfile scanner on CI and locally
gem 'danger', '~> 8.3.1'
# Brakeman scanner
gem 'brakeman', '~> 5.0.0'
gem 'danger-brakeman'

@ -983,7 +983,6 @@ DEPENDENCIES
costs!
daemons
dalli (~> 2.7.10)
danger (~> 8.3.1)
danger-brakeman
dashboards!
database_cleaner (~> 2.0)

@ -14,6 +14,8 @@ module.exports = {
},
plugins: [
"@typescript-eslint",
"change-detection-strategy",
"jasmine",
],
overrides: [
{
@ -47,6 +49,9 @@ module.exports = {
{ "type": "element", "prefix": "op", "style": "kebab-case" }
],
// Warn when new components are being created without OnPush
"change-detection-strategy/on-push": "error",
"no-console": [
"error",
{
@ -122,6 +127,16 @@ module.exports = {
* recommended set provided by the @angular-eslint project would go here.
*/
}
},
{
files: ["*.spec.ts"],
extends: ["plugin:jasmine/recommended"],
rules: {
/**
* Any template/HTML related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*/
}
}
],
};

@ -6974,6 +6974,12 @@
}
}
},
"eslint-plugin-change-detection-strategy": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-change-detection-strategy/-/eslint-plugin-change-detection-strategy-0.1.1.tgz",
"integrity": "sha512-v+/wuP+dnSnofAxRP+2tIvHuu4SnGryiUtTtpPDa7KX5RthIx+EWS7X7VFKmbnNpkj5YM3DU3VajGNjOVHqZ0g==",
"dev": true
},
"eslint-plugin-import": {
"version": "2.22.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz",
@ -7007,6 +7013,12 @@
}
}
},
"eslint-plugin-jasmine": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-jasmine/-/eslint-plugin-jasmine-4.1.2.tgz",
"integrity": "sha512-Jr52EBi6Ql5WVDvRCKBID9kRD6/CaObvCWmgHpqobczX2Mzt8/QMu9vpgx6q/O5jyQ9CIGrKaEbPuEfHRf8guw==",
"dev": true
},
"eslint-plugin-jsx-a11y": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.4.1.tgz",

@ -15,11 +15,11 @@
"@html-eslint/eslint-plugin": "^0.11.0",
"@html-eslint/parser": "^0.11.0",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@types/jasmine": "~3.6.0",
"@types/chart.js": "^2.9.20",
"@types/codemirror": "0.0.87",
"@types/dragula": "^3.7.0",
"@types/hammerjs": "^2.0.36",
"@types/jasmine": "~3.6.0",
"@types/jquery": "^3.3.33",
"@types/jqueryui": "^1.12.10",
"@types/lodash": "^4.14.149",
@ -27,9 +27,9 @@
"@types/mousetrap": "^1.6.3",
"@types/pako": "^1.0.1",
"@types/resize-observer-browser": "^0.1.4",
"@types/swagger-ui": "^3.47.0",
"@types/urijs": "^1.19.6",
"@types/webpack-env": "^1.16.0",
"@types/swagger-ui": "^3.47.0",
"@typescript-eslint/eslint-plugin": "4.23.0",
"@typescript-eslint/parser": "4.23.0",
"browserslist": "^4.9.1",
@ -37,7 +37,9 @@
"eslint": "^7.26.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-plugin-change-detection-strategy": "^0.1.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jasmine": "^4.1.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",

@ -1,46 +0,0 @@
#!/bin/bash
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
set -e
run() {
echo $1;
eval $1;
echo $2;
eval $2;
}
if [ -z "$DANGER_GITHUB_API_TOKEN" ]; then
echo "WARNING: Missing Dangerfile token. Dangerfile cannot be executed without it!"
else
run "./bin/danger --fail-on-errors=true"
fi
Loading…
Cancel
Save