Skip to content

Commit

Permalink
Typescript eslint (#527)
Browse files Browse the repository at this point in the history
* configure eslint for typescript

* one config to rule them all

* update stuff
  • Loading branch information
vnys committed Nov 13, 2020
1 parent 5941ca5 commit 6c3d18f
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 176 deletions.
128 changes: 128 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'prettier',
'prettier/react',
'plugin:react/recommended',
'plugin:testing-library/react',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:jsx-a11y/recommended',
],
plugins: ['prettier', 'testing-library'],
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 11,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
node: true,
},
settings: {
react: {
version: 'detect',
},
},
globals: {
test: true,
expect: true,
},
rules: {
'prettier/prettier': ['error'],
'no-unused-vars': [
'error',
{
varsIgnorePattern: '^React$',
},
],
'import/no-default-export': ['error'],
'import/newline-after-import': ['error'],
'import/prefer-default-export': ['off'],
'no-underscore-dangle': ['off'],
'no-use-before-define': ['off'],
'import/no-unresolved': ['off'],
'react/require-default-props': [
'error',
{
forbidDefaultForRequired: true,
},
],
'react/jsx-boolean-value': [
'error',
'never',
{
always: [],
},
],
'react/jsx-pascal-case': ['error'],
'react/no-danger': ['warn'],
'react/prefer-stateless-function': [
'error',
{
ignorePureComponents: true,
},
],
'react/jsx-filename-extension': [
'error',
{
extensions: ['.jsx'],
},
],
'react/no-unused-prop-types': ['error'],
'react/no-array-index-key': ['error'],
'react/no-typos': ['error'],
'react/destructuring-assignment': ['error', 'always'],
'jsx-a11y/accessible-emoji': ['warn'],
'jsx-a11y/control-has-associated-label': ['warn'],
'jsx-a11y/label-has-associated-control': [
'warn',
{
labelComponents: [],
labelAttributes: [],
controlComponents: [],
assert: 'either',
depth: 25,
},
],
},
overrides: [
{
files: ['**/*.jsx'],
},
{
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
},
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier/@typescript-eslint',
],
files: ['**/*.ts', '**/*.tsx'],
rules: {
'react/prop-types': 'off',
'react/jsx-filename-extension': [
'error',
{
extensions: ['.jsx', '.tsx'],
},
],
/* set rules to warn */
'@typescript-eslint/no-explicit-any': 1,
'@typescript-eslint/no-unsafe-assignment': 1,
'@typescript-eslint/no-unsafe-member-access': 1,
'@typescript-eslint/no-unsafe-call': 1,
'@typescript-eslint/no-unsafe-return': 1,
'@typescript-eslint/restrict-plus-operands': 1,
},
},
],
}
100 changes: 0 additions & 100 deletions .eslintrc.yaml

This file was deleted.

18 changes: 8 additions & 10 deletions libraries/core-react/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
name: eds-react-$(Build.BuildId)

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

trigger:
batch: "true"
batch: 'true'
branches:
include:
- develop
Expand All @@ -32,11 +32,11 @@ pr:
steps:
- task: NodeTool@0
inputs:
versionSpec: "14.x"
displayName: "Install Node.js"
versionSpec: '14.x'
displayName: 'Install Node.js'

- script: npm install -g pnpm@next
displayName: "Install pnpm"
displayName: 'Install pnpm'

- script: >-
pnpm
Expand All @@ -45,14 +45,12 @@ steps:
--filter ./libraries/icons
--filter ./libraries/core-react
install
displayName: "Install dependencies"
displayName: 'Install dependencies'
- script: pnpm --filter ./libraries/core-react test
displayName: "Run tests"
displayName: 'Run tests'

- script: >-
./node_modules/eslint/bin/eslint.js
./libraries/core-react
--ext jsx
--ext js
displayName: "Run eslint"
displayName: 'Run eslint'
17 changes: 1 addition & 16 deletions libraries/core-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": ["dom", "es2015"],
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"sourceMap": false,
"allowJs": true,
"checkJs": true,
"noEmit": true,
"jsx": "react"

//"declaration": true,
},
"extends": "../../tsconfig.base.json",
"include": ["./src"],
"exclude": ["node_modules"]
}
17 changes: 8 additions & 9 deletions libraries/icons/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: eds-icons-$(Build.BuildId)

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

trigger:
batch: "true"
batch: 'true'
branches:
include:
- develop
Expand All @@ -27,24 +27,23 @@ pr:
steps:
- task: NodeTool@0
inputs:
versionSpec: "14.x"
displayName: "Install Node.js"
versionSpec: '14.x'
displayName: 'Install Node.js'

- script: npm install -g pnpm@next
displayName: "Install pnpm"
displayName: 'Install pnpm'

- script: >-
pnpm
--filter eds
--filter ./libraries/icons
install
displayName: "Install dependencies"
displayName: 'Install dependencies'
- script: pnpm --filter ./libraries/icons run build
displayName: "Run build"
displayName: 'Run build'

- script: >-
./node_modules/eslint/bin/eslint.js
./libraries/icons
--ext js
displayName: "Run eslint"
displayName: 'Run eslint'
15 changes: 1 addition & 14 deletions libraries/icons/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": ["dom", "es2015"],
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"sourceMap": false,
"allowJs": true,
"checkJs": true,
"noEmit": true,
"jsx": "react"
},
"extends": "../../tsconfig.base.json",
"include": ["index.ts"],
"exclude": ["node_modules"]
}
Loading

0 comments on commit 6c3d18f

Please sign in to comment.