Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint Configuration, Danger and CI Pipeline and more... #1

Merged
merged 11 commits into from Jul 22, 2022

Conversation

jacopocarlini
Copy link
Contributor

@jacopocarlini jacopocarlini commented Jul 18, 2022

List of Changes

  • Create CI Pipeline
  • added github actions
  • added eslint configuration

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@jacopocarlini
Copy link
Contributor Author

jacopocarlini commented Jul 18, 2022

Warnings
⚠️

Changes were made to package.json, but not to yarn.lock.
Perhaps you need to run yarn install?

⚠️ This PR changes a total of 17419 LOCs, that is more than a reasonable size of 250. Consider splitting the pull request into smaller ones.
⚠️ Please include a Pivotal story at the beginning of the PR title (see below).

uuid

Used in package.json
Author: Unknown Description: RFC4122 (v1, v4, and v5) UUIDs
License: MIT Homepage: https://github.com/uuidjs/uuid#readme
Keywords: uuid, guid and rfc4122
Updated: 23 days ago Created: over 11 years ago
Releases: 34 Maintainers: 2
This README is too long to show.

ts-node

Used in package.json
Author: Blake Embrey Description: TypeScript execution environment and REPL for node.js, with source map support
License: MIT Homepage: https://typestrong.org/ts-node
Keywords: typescript, node, runtime, environment, ts and compiler
Updated: 7 days ago Created: almost 7 years ago
Releases: 126 Maintainers: 2
Direct Dependencies: @cspotcode/source-map-support, @tsconfig/node10, @tsconfig/node12, @tsconfig/node14, @tsconfig/node16, acorn, acorn-walk, arg, create-require, diff, make-error, v8-compile-cache-lib, yn
This README is too long to show.

prettier

Used in package.json
Author: James Long Description: Prettier is an opinionated code formatter
License: MIT Homepage: https://prettier.io
Updated: 27 days ago Created: over 5 years ago
Releases: 115 Maintainers: 11
README

Prettier Banner

Opinionated Code Formatter

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML
Your favorite language?

Github Actions Build Status Github Actions Build Status Github Actions Build Status Codecov Coverage Status Blazing Fast
npm version weekly downloads from npm code style: prettier Follow Prettier on Twitter

Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

Input

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Output

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne()
);

Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!


Documentation

Install ·
Options ·
CLI ·
API

Playground


Badge

Show the world you're using Prettiercode style: prettier

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Contributing

See CONTRIBUTING.md.

io-ts

Used in package.json
Author: Giulio Canti Description: TypeScript runtime type system for IO decoding/encoding
License: MIT Homepage: https://github.com/gcanti/io-ts
Keywords: typescript, runtime, decoder, encoder and schema
Updated: about 1 month ago Created: over 5 years ago
Releases: 115 Maintainers: 1
Direct Dependencies:
README

build status
dependency status
npm downloads

Installation

To install the stable version

npm i io-ts fp-ts

Note. fp-ts is a peer dependency for io-ts

Usage

Stable features

Experimental features (version 2.2+)

Experimental features (*) are published in order to get early feedback from the community, see these tracking issues for further discussions and enhancements.

(*) A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.

fp-ts

Used in package.json
Author: Giulio Canti Description: Functional programming in TypeScript
License: MIT Homepage: https://github.com/gcanti/fp-ts
Keywords: typescript, algebraic-data-types and functional-programming
Updated: about 1 month ago Created: over 5 years ago
Releases: 204 Maintainers: 1
Direct Dependencies:

eslint-plugin-prettier

Used in package.json
Author: Teddy Katz Description: Runs prettier as an eslint rule
License: MIT Homepage: https://github.com/prettier/eslint-plugin-prettier#readme
Keywords: eslint, eslintplugin, eslint-plugin and prettier
Updated: 21 days ago Created: over 5 years ago
Releases: 31 Maintainers: 6
Direct Dependencies: prettier-linter-helpers
README

eslint-plugin-prettier Build Status

Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.

If your desired formatting does not match Prettier’s output, you should use a different tool such as prettier-eslint instead.

Please read Integrating with linters before installing.

Sample

error: Insert `,` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:22:25:
  20 | import {
  21 |   observeActiveEditorsDebounced,
> 22 |   editorChangesDebounced
     |                         ^
  23 | } from './debounced';;
  24 |
  25 | import {observableFromSubscribeFunction} from '../commons-node/event';


error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:23:21:
  21 |   observeActiveEditorsDebounced,
  22 |   editorChangesDebounced
> 23 | } from './debounced';;
     |                     ^
  24 |
  25 | import {observableFromSubscribeFunction} from '../commons-node/event';
  26 | import {cacheWhileSubscribed} from '../commons-node/observable';


2 errors found.

./node_modules/.bin/eslint --format codeframe pkg/commons-atom/ActiveEditorRegistry.js (code from nuclide).

Installation

npm install --save-dev eslint-plugin-prettier
npm install --save-dev --save-exact prettier

eslint-plugin-prettier does not install Prettier or ESLint for you. You must install these yourself.

Then, in your .eslintrc.json:

{
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error"
  }
}

Recommended Configuration

This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect potential bugs. (If another active ESLint rule disagrees with prettier about how code should be formatted, it will be impossible to avoid lint errors.) You can use eslint-config-prettier to disable all formatting-related ESLint rules.

This plugin ships with a plugin:prettier/recommended config that sets up both the plugin and eslint-config-prettier in one go.

  1. In addition to the above installation instructions, install eslint-config-prettier:

    npm install --save-dev eslint-config-prettier
  2. Then you need to add plugin:prettier/recommended as the last extension in your .eslintrc.json:

    {
      "extends": ["plugin:prettier/recommended"]
    }

    You can then set Prettier's own options inside a .prettierrc file.

Exactly what does plugin:prettier/recommended do? Well, this is what it expands to:

{
  "extends": ["prettier"],
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error",
    "arrow-body-style": "off",
    "prefer-arrow-callback": "off"
  }
}
  • "extends": ["prettier"] enables the config from eslint-config-prettier, which turns off some ESLint rules that conflict with Prettier.
  • "plugins": ["prettier"] registers this plugin.
  • "prettier/prettier": "error" turns on the rule provided by this plugin, which runs Prettier from within ESLint.
  • "arrow-body-style": "off" and "prefer-arrow-callback": "off" turns off two ESLint core rules that unfortunately are problematic with this plugin – see the next section.

Svelte support

We recommend to use eslint-plugin-svelte instead of eslint-plugin-svelte3 because eslint-plugin-svelte has a correct eslint-svelte-parser instead of hacking, when use with eslint-plugin-svelte3, eslint-plugin-prettier will just ignore the text passed by eslint-plugin-svelte3, because the text they has been modified.

arrow-body-style and prefer-arrow-callback issue

If you use arrow-body-style or prefer-arrow-callback together with the prettier/prettier rule from this plugin, you can in some cases end up with invalid code due to a bug in ESLint’s autofix – see issue #65.

For this reason, it’s recommended to turn off these rules. The plugin:prettier/recommended config does that for you.

You can still use these rules together with this plugin if you want, because the bug does not occur all the time. But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.

If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the prettier/prettier rule and running eslint --fix and prettier --write separately.

Options

Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as prettier-atom and prettier-vscode will read .prettierrc, but won't read settings from ESLint, which can lead to an inconsistent experience.

  • The first option:

    • An object representing options that will be passed into prettier. Example:

      {
        "prettier/prettier": ["error", { "singleQuote": true, "parser": "flow" }]
      }

      NB: This option will merge and override any config set with .prettierrc files

  • The second option:

    • An object with the following options

      • usePrettierrc: Enables loading of the Prettier configuration file, (default: true). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration.

        {
          "prettier/prettier": [
            "error",
            {},
            {
              "usePrettierrc": false
            }
          ]
        }
      • fileInfoOptions: Options that are passed to prettier.getFileInfo to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located in node_modules directories.

        {
          "prettier/prettier": [
            "error",
            {},
            {
              "fileInfoOptions": {
                "withNodeModules": true
              }
            }
          ]
        }
  • The rule is auto fixable -- if you run eslint with the --fix flag, your code will be formatted according to prettier style.


Contributing

See CONTRIBUTING.md

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT

eslint-config-prettier

Used in package.json
Author: Simon Lydell Description: Turns off all rules that are unnecessary or might conflict with Prettier.
License: MIT Homepage: https://github.com/prettier/eslint-config-prettier#readme
Keywords: eslint, eslintconfig and prettier
Updated: about 1 month ago Created: over 5 years ago
Releases: 65 Maintainers: 2
README

eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with [Prettier].

This lets you use your favorite shareable config without letting its stylistic choices get in the way when using Prettier.

Note that this config only turns rules off, so it only makes sense using it together with some other config.

➡️ Full readme

danger

Used in package.json
Author: Orta Therox Description: Unit tests for Team Culture
License: MIT Homepage: https://github.com/danger/danger-js#readme
Keywords: danger and ci
Updated: 16 days ago Created: about 6 years ago
Releases: 297 Maintainers: 3
Direct Dependencies: @octokit/rest, async-retry, chalk, commander, core-js, debug, fast-json-patch, get-stdin, gitlab, http-proxy-agent, https-proxy-agent, hyperlinker, json5, jsonpointer, jsonwebtoken, lodash.find, lodash.includes, lodash.isobject, lodash.keys, lodash.mapvalues, lodash.memoize, memfs-or-file-map-to-github-branch, micromatch, node-cleanup, node-fetch, override-require, p-limit, parse-diff, parse-git-config, parse-github-url, parse-link-header, pinpoint, prettyjson, readline-sync, regenerator-runtime, require-from-string, supports-hyperlinks
README


Formalize your Pull Request etiquette.

What is Danger JS?VisionHelping OutPlugin Development

What is Danger JS?

Danger runs after your CI, automating your team's conventions surrounding code review.

This provides another logical step in your process, through which Danger can help lint your rote tasks in daily code
review.

You can use Danger to codify your team's norms, leaving humans to think about harder problems.

Danger JS works with GitHub, BitBucket Server, BitBucket Cloud for code review, then with: Travis CI, GitLab CI,
Semaphore, Circle CI, GitHub Actions, Jenkins, Docker Cloud, Bamboo, Bitrise, surf-build, Codeship, Drone, Buildkite,
Nevercode, buddybuild, Buddy.works, TeamCity, Visual Studio Team Services, Screwdriver, Concourse, Netlify, CodeBuild,
Codefresh, AppCenter, BitBucket Pipelines, Cirrus CI, Codemagic or Xcode Cloud.

npm
Build Status
Build Status
Join the community on Spectrum

For example?

You can:

  • Enforce CHANGELOGs
  • Enforce links to Trello/JIRA in PR/MR bodies
  • Enforce using descriptive labels
  • Look out for common anti-patterns
  • Highlight interesting build artifacts
  • Give warnings when specific files change

Danger provides the glue to let you build out the rules specific to your team's culture, offering useful metadata and
a comprehensive plugin system to share common issues.

Getting Started

Alright. So, actually, you may be in the wrong place. From here on in, this README is going to be for people who are
interested in working on and improving on Danger JS.

We keep all of the end-user documentation at http://danger.systems/js.

Some quick links to get you started:

This thing is broken, I should help improve it!

Awesommmmee. Everything you need is down below. You can also refer to CONTRIBUTING file where you'll
find the same information listed below.

git clone https://github.com/danger/danger-js.git
cd danger-js

# if you don't have yarn installed
npm install -g yarn

yarn install

You can then verify your install by running the tests, and the linters:

yarn test
yarn lint

The fixers for both tslint and prettier will be applied when you commit, and on a push your code will be verified that
it compiles.

You can run your dev copy of danger against a PR by running:

yarn build; node --inspect distribution/commands/danger-pr.js https://github.com/danger/danger-js/pull/817

How does Danger JS work?

Check the architecture doc.

What is the TODO?

Check the issues, I try and keep my short term perspective there. Long term is in the VISION.md.

Releasing a new version of Danger

Following this commit as a model:

  • Checkout the main branch. Ensure your working tree is clean, and make sure you have the latest changes by running
    git pull.
  • Publish - npm run release -- patch --ci.

🚢

License, Contributor's Guidelines and Code of Conduct

We try to keep as much discussion as possible in GitHub issues, but also have a pretty inactive Slack --- if you'd like
an invite, ping @Orta a DM on Twitter with your email. It's mostly interesting if you want
to stay on top of Danger without all the emails from GitHub.

This project is open source under the MIT license, which means you have full access to the source code and can modify
it to fit your own needs but don't have access to deploy.

This project subscribes to the Moya Contributors Guidelines which TLDR: means
we give out push access easily and often.

Contributors subscribe to the Contributor Code of Conduct based on
the Contributor Covenant version 1.3.0.

@types/uuid

Used in package.json
Author: Unknown Description: TypeScript definitions for uuid
License: MIT Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid
Updated: about 1 month ago Created: about 6 years ago
Releases: 40 Maintainers: 1
README

Installation

npm install --save @types/uuid

Summary

This package contains type definitions for uuid (https://github.com/uuidjs/uuid).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid.

Additional Details

  • Last updated: Thu, 06 Jan 2022 07:31:27 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Oliver Hoffmann, Felipe Ochoa, Chris Barth, Linus Unnebäck, and Christoph Tavan.

@pagopa/eslint-config

Used in package.json
Author: Unknown Description: This package provide the following ESLint custom rules for Typescript projects.
License: MIT Homepage: https://github.com/pagopa/eslint-rules#readme
Updated: 3 months ago Created: over 1 year ago
Releases: 7 Maintainers: 4
README

PagoPA ESLint config

This package provide the following ESLint custom rules for Typescript projects.

  • recommendend
  • react
  • strong

This repository replace italia-tslint-rules after TSLint deprecation.

The following TSLint rules (included inside italia-tslint-rules) are not supported for eslint at the moment and are missing in this package:

bool-param-default
max-union-size
no-accessor-field-mismatch
no-array-delete // Mitigated by no-delete
no-case-with-or
no-dead-store
no-duplicate-in-composite
no-empty-array
no-extra-semicolon // Mitigated by prettier
no-empty-destructuring // Mititgated by no-empty-pattern
no-gratuitous-expressions
no-hardcoded-credentials
no-ignored-initial-value // Mitigated by no-param-reassign, no-let
no-in-misuse
no-inferred-empty-object-type
no-invalid-await // Mititgated by await-thenable
no-invariant-return
no-misleading-array-reverse // Mitigated by immutable-data
no-misspelled-operator // Mitigated by prettier
no-nested-switch
no-nested-template-literals
no-statements-same-line // Mitigated by prettier
no-try-promise
no-tslint-disable-all
no-unconditional-jump
no-undefined-argument
no-unenclosed-multiline-block // Mitigated by prettier
no-unthrown-error
no-unused-array // Mitigated by no-unused-vars
no-useless-increment
no-useless-intersection
prefer-promise-shorthand
promise-must-complete
use-primitive-type

This list has been produced following these steps:

  1. Follow TSLint to ESLint migration guide on the project io-backend
  2. Running npx tslint-to-eslint-config that produces a list of TSLint rules not available for ESLint (77 rules at the moment)
  3. Manually check each one for an alternative ESLint rules/plugins
  4. Verify each alternative ESLint rule/plugin on a testing file

Usage

Installation and Configuration

To use this package install as devDependecy inside any typescript project with

yarn install -D @pagopa/eslint-config

Create on the project an .eslintrc.js file with the following content

module.exports = {
  "extends": [
    "@pagopa/eslint-config/strong",
  ],
  "rules": {
    // Any project level custom rule
  }
}

Add inside the package.json file a lint and optionally a lint-autofix script as:

"scripts": {
  "lint": "eslint . -c .eslintrc.js --ext .ts,.tsx",
  "lint-autofix": "eslint . -c .eslintrc.js --ext .ts,.tsx --fix",
  ...
}

Migration from TSLint

Remove from the package.json every tslint reference:

  • tslint
  • italia-tslint-rules

Replace all the // tslint:disable-next-line with the proper // eslint-disable-next-line comment. If are present some // tslint:disable replace it with /* eslint-disable */ at the top of the file.

If you need to disable ESLint for some files create .eslintignore file with the list of folders or files that must be excluded from lint process. Copy the exclusion from tslint.json linterOptions.exclude

Delete all tslint related files (es. tslint.json).

Run yarn lint-autofix to refactorize the code automatically with all the auto-fixable ESLint rules.

@pagopa/danger-custom-rules

Used in package.json
Author: Federico Feroldi Description: Shared rules for DangerJS, used in the Digital Citizenship projects
License: MIT Homepage: https://github.com/pagopa/danger-plugin-digitalcitizenship#readme
Updated: 4 months ago Created: over 1 year ago
Releases: 2 Maintainers: 4
README

Custom DangerJS rules plugin

Custom rules over Danger CI automation.

Features

  • Cross-link with PivotalTracker stories, based on PR title
  • Warn when a PR has no description
  • Perform sanity checks on yarn.lock
  • Warn if npm-related files are added (as we use yarn)

New dependencies added: @pagopa/danger-custom-rules, @pagopa/eslint-config, @types/uuid, danger, eslint-config-prettier, eslint-plugin-prettier, fp-ts, io-ts, prettier, ts-node and uuid.

Example of PR titles that include pivotal stories:

  • single story: [#123456] my PR title
  • multiple stories: [#123456,#123457,#123458] my PR title

Generated by 🚫 dangerJS against d7de536

@jacopocarlini jacopocarlini self-assigned this Jul 18, 2022
@jacopocarlini jacopocarlini added the enhancement New feature or request label Jul 18, 2022
@jacopocarlini jacopocarlini requested review from a team, aomegax and giovanniberti and removed request for a team July 18, 2022 15:01
@jacopocarlini jacopocarlini changed the title Ci pipeline Lint Configuratio, Danger and CI Pipeline Jul 20, 2022
@jacopocarlini jacopocarlini changed the title Lint Configuratio, Danger and CI Pipeline Lint Configuration, Danger and CI Pipeline Jul 20, 2022
@jacopocarlini jacopocarlini changed the title Lint Configuration, Danger and CI Pipeline Lint Configuration, Danger and CI Pipeline and more... Jul 20, 2022
Copy link
Contributor

@pasqualespica pasqualespica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good add apispec folder too

Donation/index.ts Outdated Show resolved Hide resolved
Donation/index.ts Show resolved Hide resolved
@jacopocarlini jacopocarlini merged commit f989e3d into main Jul 22, 2022
@jacopocarlini jacopocarlini deleted the ci-pipeline branch August 2, 2022 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants