Skip to content

Commit

Permalink
add prettier and have it format all fleet application code (#625)
Browse files Browse the repository at this point in the history
* add prettier and have it format all js code except website:
:

* trying running prettier check in CI

* fix runs on in CI

* change CI job name

* fix prettier erros and fix CI
  • Loading branch information
ghernandez345 authored Apr 12, 2021
1 parent df5fa7f commit efb35b5
Show file tree
Hide file tree
Showing 631 changed files with 31,153 additions and 29,916 deletions.
88 changes: 44 additions & 44 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
var path = require('path');
var path = require("path");

module.exports = {
extends: [
'airbnb',
'plugin:jest/recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:cypress/recommended',
],
parser: '@typescript-eslint/parser',
plugins: [
'jest',
'react',
'@typescript-eslint',
"airbnb",
"plugin:jest/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:cypress/recommended",
"plugin:prettier/recommended",
],
parser: "@typescript-eslint/parser",
plugins: ["jest", "react", "@typescript-eslint"],
env: {
node: true,
mocha: true,
browser: true,
'jest/globals': true,
"jest/globals": true,
},
globals: {
expect: false,
describe: false,
},
rules: {
camelcase: 'off',
'consistent-return': 1,
'arrow-body-style': 0,
'max-len': 0,
'no-unused-expressions': 0,
'no-console': 0,
'space-before-function-paren': 0,
'react/prefer-stateless-function': 0,
'react/no-multi-comp': 0,
'react/no-unused-prop-types': [1, { customValidators: [], skipShapeProps: true }],
'react/require-default-props': 0, // TODO set default props and enable this check
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
'no-param-reassign': 0,
'new-cap': 0,
'import/no-unresolved': [2, { caseSensitive: false }],
'linebreak-style': 0,
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/extensions': 0,
'import/no-extraneous-dependencies': 0,
'no-underscore-dangle': 0,
'jsx-a11y/no-static-element-interactions': 'off',
camelcase: "off",
"consistent-return": 1,
"arrow-body-style": 0,
"max-len": 0,
"no-unused-expressions": 0,
"no-console": 0,
"space-before-function-paren": 0,
"react/prefer-stateless-function": 0,
"react/no-multi-comp": 0,
"react/no-unused-prop-types": [
1,
{ customValidators: [], skipShapeProps: true },
],
"react/require-default-props": 0, // TODO set default props and enable this check
"react/jsx-filename-extension": [1, { extensions: [".jsx", ".tsx"] }],
"no-param-reassign": 0,
"new-cap": 0,
"import/no-unresolved": [2, { caseSensitive: false }],
"linebreak-style": 0,
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/extensions": 0,
"import/no-extraneous-dependencies": 0,
"no-underscore-dangle": 0,
"jsx-a11y/no-static-element-interactions": "off",

// note you must disable the base rule as it can report incorrect errors. more info here:
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],

// turn off and override to not run this on js and jsx files. More info here:
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md#configuring-in-a-mixed-jsts-codebase
'@typescript-eslint/explicit-module-boundary-types': 'off',
"@typescript-eslint/explicit-module-boundary-types": "off",

// There is a bug with these rules in our version of jsx-a11y plugin (5.1.1)
// To upgrade our version of the plugin we would need to make more changes
// with eslint-config-airbnb, so we will just turn off for now.
'jsx-a11y/heading-has-content': 'off',
'jsx-a11y/anchor-has-content': 'off',
"jsx-a11y/heading-has-content": "off",
"jsx-a11y/anchor-has-content": "off",
},
overrides: [
{
files: ['*.ts', '*.tsx'],
files: ["*.ts", "*.tsx"],
rules: {
// Set to warn for now at the beginning to make migration easier
// but want to change this to error when we can.
'@typescript-eslint/explicit-module-boundary-types': ['warn'],
"@typescript-eslint/explicit-module-boundary-types": ["warn"],
},
},
],
settings: {
'import/resolver': {
"import/resolver": {
webpack: {
config: path.join(__dirname, 'webpack.config.js'),
config: path.join(__dirname, "webpack.config.js"),
},
},
},
Expand Down
43 changes: 34 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ jobs:
${{ runner.os }}-modules-
# It seems faster not to cache Go dependencies

- name: Install JS Dependencies
run: make deps-js

- name: Install Go Dependencies
run: make deps-go

# Pre-starting dependencies here means they are ready to go when we need them.
# Pre-starting dependencies here means they are ready to go when we need them.
- name: Start Infra Dependencies
# Use & to background this
run: docker-compose up -d mysql_test redis mailhog saml_idp &

- name: Build Fleet
run: |
export PATH=$PATH:~/go/bin
Expand All @@ -51,7 +51,7 @@ jobs:
make e2e-setup
yarn cypress run --config video=false
test-js:
strategy:
matrix:
Expand Down Expand Up @@ -106,7 +106,33 @@ jobs:
- name: Run JS Linting
run: |
make lint-js
check-prettier:
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: JS Dependency Cache
uses: actions/cache@v2
with:
path: |
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-
- name: Install JS Dependencies
run: make deps-js

- name: Run prettier formatting check
run: |
yarn prettier:check
test-go:
strategy:
Expand All @@ -122,15 +148,15 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

# Pre-starting dependencies here means they are ready to go when we need them.
# Pre-starting dependencies here means they are ready to go when we need them.
- name: Start Infra Dependencies
# Use & to background this
run: docker-compose up -d mysql_test redis &

# It seems faster not to cache Go dependencies
- name: Install Go Dependencies
run: make deps-go

- name: Generate static files
run: |
export PATH=$PATH:~/go/bin
Expand Down Expand Up @@ -158,4 +184,3 @@ jobs:
- name: Run Go Linting
run: |
make lint-go
34 changes: 34 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# markdown
*.md

# output directories
build
vendor
node_modules

# generated artifacts
assets/bundle*.*
assets/*@*.svg
assets/*@*.png
assets/*@*.eot
assets/*@*.woff
assets/*@*.woff2
assets/*@*.ttf
frontend/templates/react.tmpl
bindata.go
server/bindata/generated.go
*.cover
*.test
*.log

# typescript generated test files
tmp/

# editors
.vscode
.idea

# Cypress e2e testing
cypress/screenshots
cypress/videos
cypress/downloads
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
120 changes: 0 additions & 120 deletions .sass-lint.yml

This file was deleted.

Loading

0 comments on commit efb35b5

Please sign in to comment.