Skip to content

Commit

Permalink
feat #38 - Add eslint and fix lint errors & warnings (#39)
Browse files Browse the repository at this point in the history
* Feat #38 - Add typescript Eslint plugins & .eslintrc.js
  • Loading branch information
sam-dassana authored Aug 11, 2020
1 parent 1a86b54 commit 5b70e24
Show file tree
Hide file tree
Showing 13 changed files with 492 additions and 273 deletions.
68 changes: 68 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended' // Uses the recommended rules from the @typescript-eslint/eslint-plugin
],
globals: {
console: true,
localStorage: true,
module: true,
window: true
},
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
ecmaFeatures: {
jsx: true,
modules: true
},
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json'
},
plugins: ['react', '@typescript-eslint'],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars-experimental': 'warn',
'comma-dangle': ['warn', 'never'],
'comma-spacing': ['warn', { after: true, before: false }],
'key-spacing': [
'warn',
{
afterColon: true,
beforeColon: false
}
],
'no-duplicate-imports': 'error',
'no-useless-computed-key': 'warn',
'quote-props': ['warn', 'as-needed'],
quotes: ['warn', 'single'],
'react/display-name': 'off',
'react/jsx-sort-props': 'warn',
semi: ['warn', 'never'],
'semi-spacing': ['warn', { after: true, before: false }],
'sort-imports': [
'warn',
{
ignoreCase: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple']
}
],
'sort-keys': ['warn', 'asc'],
'space-in-parens': ['warn', 'never']
},
settings: {
react: {
version: 'detect'
}
}
}
25 changes: 25 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Node.js CI

on: pull_request

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
always-auth: true
node-version: '12.x'
registry-url: https://npm.pkg.github.com/
scope: '@dassana-io'
- name: Run install, lint, test, and build
run: |
npm install
npm run lint
npm test
npm run build
env:
CI: true
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ Responsible for web components to be shared by microfrontends

**Storybook**

Run `npm start` or `npm run storybook`
1. Run `npm start` or `npm run storybook`

**Tests**

Run `npm run test`
1. Run `npm run test` to run all tests.
2. Run `npm run test-watch` to run all tests in watch mode.
3. Run `npm run test-coverage` to check test coverage.

**Linting and Code Formatting**

1. Run `npm run lint` to run linter and fix lint errors.
2. Run `prettier --write .` to format code.
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
collectCoverageFrom: ['lib/**/*.{ts,tsx,js,jsx}'],
coverageDirectory: 'coverage',
preset: 'ts-jest',
testEnvironment: 'node'
}
Loading

0 comments on commit 5b70e24

Please sign in to comment.