Skip to content

Commit

Permalink
feat!: support for eslint 8
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Updated all dependencies, removed support for ESLint < 8
The project also now uses node 14

Reviewed-by: @BurnedMarshal 
Refs: SFEQS-699
  • Loading branch information
lucacavallaro authored Apr 12, 2022
1 parent 7464c8c commit 92cdf4f
Show file tree
Hide file tree
Showing 13 changed files with 884 additions and 945 deletions.
46 changes: 23 additions & 23 deletions .devops/azure-templates/setup-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
# 3. install node dependencies

parameters:
- name: 'cache_version_id'
type: string
default: $(CACHE_VERSION_ID)
- name: "cache_version_id"
type: string
default: $(CACHE_VERSION_ID)

# the branch, tag or commit to deploy
- name: "gitReference"
type: string
default: "$(Build.SourceVersion)"

# the branch, tag or commit to deploy
- name: 'gitReference'
type: string
default: '$(Build.SourceVersion)'

steps:
- checkout: self
displayName: 'Checkout'
- checkout: self
displayName: "Checkout"

# This is needed because the pipeline may point to a different commit than expected
# The common case is when the previous stage pushed another commit
- ${{ if ne(parameters.gitReference, variables['Build.SourceVersion']) }}:
- script: |
git fetch && git checkout ${{ parameters.gitReference }}
displayName: 'Checkout reference'
# This is needed because the pipeline may point to a different commit than expected
# The common case is when the previous stage pushed another commit
- ${{ if ne(parameters.gitReference, variables['Build.SourceVersion']) }}:
- script: |
git fetch && git checkout ${{ parameters.gitReference }}
displayName: "Checkout reference"
- task: UseNode@1
inputs:
version: $(NODE_VERSION)
displayName: 'Set up Node.js'
- task: UseNode@1
inputs:
version: $(NODE_VERSION)
displayName: "Set up Node.js"

- script: |
yarn install --frozen-lockfile --no-progress --non-interactive --network-concurrency 1
displayName: 'Install node modules'
- script: |
yarn install --frozen-lockfile --no-progress --non-interactive --network-concurrency 1
displayName: "Install node modules"
27 changes: 13 additions & 14 deletions .devops/code-review-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
# Azure DevOps pipeline to build, check source codes and run tests.
#
# To make Danger JS run on a pull request you need to add the following pipeline
# variable and set it with a GitHub access token (scope public_repo); otherwise
# set its value to 'skip' without marking it secret:
# To make Danger JS run on a pull request you need to add the following pipeline
# variable and set it with a GitHub access token (scope public_repo); otherwise
# set its value to 'skip' without marking it secret:
# - DANGER_GITHUB_API_TOKEN
#
#

variables:
NODE_VERSION: '10.14.1'
NODE_VERSION: "14.18.1"
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn

# Automatically triggered on PR
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#pr-trigger
trigger: none

pool:
vmImage: 'ubuntu-latest'
vmImage: "ubuntu-latest"

stages:
- stage: Static_analysis
dependsOn: []
jobs:
- job: danger
condition:
condition: and(
succeeded(),
and(
succeeded(),
and(
eq(variables['Build.Reason'], 'PullRequest'),
ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip')
)
eq(variables['Build.Reason'], 'PullRequest'),
ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip')
)
)
steps:
- template: azure-templates/setup-project.yml
- bash: |
yarn danger ci
env:
DANGER_GITHUB_API_TOKEN: '$(DANGER_GITHUB_API_TOKEN)'
displayName: 'Danger CI'
DANGER_GITHUB_API_TOKEN: "$(DANGER_GITHUB_API_TOKEN)"
displayName: "Danger CI"
72 changes: 35 additions & 37 deletions .devops/deploy-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# GIT_USERNAME - when bumping the package version, is the name we author the commit with
# GITHUB_CONNECTION - name of the Github service connection used to create a new release; be sure that the related user has appopriate right
# NPM_CONNECTION - name of the NPM service connection used to publish the package; be sure that the related user has appopriate right
#
#

variables:
NODE_VERSION: '10.14.1'
NODE_VERSION: "14.18.1"
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn

parameters:
- name: 'RELEASE_SEMVER'
displayName: 'When packing a release, define the version bump to apply'
- name: "RELEASE_SEMVER"
displayName: "When packing a release, define the version bump to apply"
type: string
values:
- major
Expand All @@ -27,52 +27,50 @@ trigger: none
pr: none

pool:
vmImage: 'ubuntu-latest'
vmImage: "ubuntu-latest"

resources:
repositories:
- repository: pagopaCommons
type: github
name: pagopa/azure-pipeline-templates
ref: refs/tags/v4
endpoint: 'pagopa'
endpoint: "pagopa"

stages:

# Create a relase
# Activated when ONE OF these are met:
# - is on branch master
# - is on branch master
# - is a tag in the form v{version}-RELEASE
- stage: Release
condition:
condition: and(
succeeded(),
or(
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
and(
succeeded(),
or(
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
and(
startsWith(variables['Build.SourceBranch'], 'refs/tags'),
endsWith(variables['Build.SourceBranch'], '-RELEASE')
)
)
startsWith(variables['Build.SourceBranch'], 'refs/tags'),
endsWith(variables['Build.SourceBranch'], '-RELEASE')
)
)
)
jobs:
- job: make_release
steps:
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- template: templates/node-github-release/template.yaml@pagopaCommons
parameters:
semver: '${{ parameters.RELEASE_SEMVER }}'
gitEmail: $(GIT_EMAIL)
gitUsername: $(GIT_USERNAME)
gitHubConnection: $(GITHUB_CONNECTION)
nodeVersion: $(NODE_VERSION)
pkg_cache_version_id: $(CACHE_VERSION_ID)
pkg_cache_folder: $(YARN_CACHE_FOLDER)
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- template: templates/node-github-release/template.yaml@pagopaCommons
parameters:
semver: "${{ parameters.RELEASE_SEMVER }}"
gitEmail: $(GIT_EMAIL)
gitUsername: $(GIT_USERNAME)
gitHubConnection: $(GITHUB_CONNECTION)
nodeVersion: $(NODE_VERSION)
pkg_cache_version_id: $(CACHE_VERSION_ID)
pkg_cache_folder: $(YARN_CACHE_FOLDER)

- ${{ if ne(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- script: |
echo "We assume this reference to be a valid release: $(Build.SourceBranch). Therefore, there is no need to bundle a new release."
displayName: 'Skip release bundle'
- ${{ if ne(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- script: |
echo "We assume this reference to be a valid release: $(Build.SourceBranch). Therefore, there is no need to bundle a new release."
displayName: "Skip release bundle"
# Prepare Artifact
- stage: Prepare_artifact
Expand All @@ -92,16 +90,16 @@ stages:

- task: CopyFiles@2
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
TargetFolder: '$(System.DefaultWorkingDirectory)/bundle'
SourceFolder: "$(System.DefaultWorkingDirectory)"
TargetFolder: "$(System.DefaultWorkingDirectory)/bundle"
# The list of files to be considered is determined by the "files" entry in package.json
Contents: |
README.md
CHANGELOG.md
package.json
*.js
displayName: 'Copy bundle files'
displayName: "Copy bundle files"

- publish: $(System.DefaultWorkingDirectory)/bundle
artifact: Bundle

Expand All @@ -118,9 +116,9 @@ stages:
artifact: Bundle

- task: Npm@1
inputs:
inputs:
command: custom
customCommand: publish --access public
customEndpoint: $(NPM_CONNECTION)
verbose: true
workingDir: '$(Pipeline.Workspace)/Bundle'
workingDir: "$(Pipeline.Workspace)/Bundle"
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.18.1
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.18.1
6 changes: 3 additions & 3 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
trailingComma: 'none',
arrowParens: 'avoid',
trailingComma: "none",
arrowParens: "avoid",
semi: true,
trailingComma: 'all',
trailingComma: "all",
singleQuote: false,
printWidth: 120,
tabWidth: 2,
Expand Down
3 changes: 1 addition & 2 deletions Dangerfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

// import custom DangerJS rules
// see http://danger.systems/js
// see https://github.com/teamdigitale/danger-plugin-digitalcitizenship/
const checkDangers = require('danger-plugin-digitalcitizenship').default;
const checkDangers = require("danger-plugin-digitalcitizenship").default;

checkDangers();
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This package provide the following ESLint custom rules for Typescript projects.
This repository replace [italia-tslint-rules](https://github.com/pagopa/io-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
Expand Down Expand Up @@ -47,10 +48,12 @@ use-primitive-type
```

This list has been produced following these steps:

1. Follow [TSLint to ESLint migration guide](https://code.visualstudio.com/api/advanced-topics/tslint-eslint-migration) on the project [io-backend](https://github.com/pagopa/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
Expand Down Expand Up @@ -97,4 +100,4 @@ If you need to disable ESLint for some files create `.eslintignore` file with th

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

Run `yarn lint-autofix` to refactorize the code automatically with all the auto-fixable ESLint rules.
Run `yarn lint-autofix` to refactorize the code automatically with all the auto-fixable ESLint rules.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "@pagopa/eslint-config",
"version": "1.3.1",
"version": "2.0.0",
"main": "strong.js",
"repository": "[email protected]:pagopa/eslint-rules.git",
"license": "MIT",
"scripts": {
"format": "prettier --write ."
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/eslint-plugin-tslint": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-extra-rules": "^0.0.0-development",
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-functional": "^2.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.6.1",
"eslint-plugin-no-credentials": "^2.0.9",
"eslint-plugin-prefer-arrow": "^1.2.2",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-sonarjs": "^0.5.0",
"prettier": "^2.1.2"
"eslint-plugin-functional": "^4.2.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.0.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-sonarjs": "^0.13.0",
"prettier": "^2.6.2"
},
"devDependencies": {
"danger": "^10.0.0",
"danger-plugin-digitalcitizenship": "*",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
"typescript": "^4.6.3"
}
}
14 changes: 7 additions & 7 deletions react.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-disable */
module.exports = {
extends: './recommended.js',
plugins: ['react'],
extends: "./recommended.js",
plugins: ["react"],
rules: {
'react/prop-types': 'off',
'react/display-name': 'off',
'react/jsx-key': 'error',
'react/jsx-no-bind': ['error', { allowArrowFunctions: true }],
"react/prop-types": "off",
"react/display-name": "off",
"react/jsx-key": "error",
"react/jsx-no-bind": ["error", { allowArrowFunctions: true }],
},
settings: {
react: {
version: 'detect',
version: "detect",
},
},
};
Loading

0 comments on commit 92cdf4f

Please sign in to comment.