Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Created a eslint base config and extend from this in each package #4038

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions eslint-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": [
"eslint:recommended",
"prettier"
],
"env": {
"es6": true,
"node": true
},
"rules": {
"no-console": [
2,
{
"allow": ["warn", "error"]
}
]
}
}
38 changes: 38 additions & 0 deletions eslint-overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
hasan-ozaynaci marked this conversation as resolved.
Show resolved Hide resolved
"overrides": [
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "risxss"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/indent": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-unused-vars": [
2,
{
"argsIgnorePattern": "^_"
}
],
"no-restricted-imports": [
"error",
{
"name": "next/link",
"message": "Please use the custom ~/utils/link instead"
}
]
}
}
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"nuke": "yarn workspaces foreach run nuke && npx rimraf node_modules",
"typecheck": "yarn workspaces foreach run typecheck",
"lint": "yarn workspaces foreach run lint",
"lint:fix": "yarn workspaces foreach run lint --fix",
Copy link
Contributor

Choose a reason for hiding this comment

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

🙌

"format": "yarn workspaces foreach run format",
"dev": "yarn workspace @corona-dashboard/app dev",
"download": "yarn workspace @corona-dashboard/app download",
Expand Down
47 changes: 6 additions & 41 deletions packages/app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
"../../eslint-config"
],
"settings": {
"react": {
"version": "detect"
}
},
"env": {
"es6": true,
"browser": true,
"node": true
"browser": true
},
"parserOptions": {
"ecmaVersion": 2020,
Expand All @@ -25,24 +22,14 @@
"rules": {
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
"react/prop-types": 0,
"no-console": [
2,
{
"allow": ["warn", "error"]
}
]
"react/prop-types": 0
},
"overrides": [
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "risxss"],
"extends": [
"eslint:recommended",
"../../eslint-overrides",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
"plugin:react-hooks/recommended"
],
"files": ["*.ts", "*.tsx"],
"rules": {
Expand All @@ -54,29 +41,7 @@
],
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
"react/prop-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/indent": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-unused-vars": [
2,
{
"argsIgnorePattern": "^_"
}
],
"no-restricted-imports": [
"error",
{
"name": "next/link",
"message": "Please use the custom ~/utils/link instead"
}
]
"react/prop-types": 0
}
}
]
Expand Down
18 changes: 18 additions & 0 deletions packages/cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": [
"../../eslint-config"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"overrides": [
{
"extends": ["../../eslint-overrides"],
"files": ["*.ts", "*.tsx"],
"rules": {
"no-console": 0
}
}
]
}
6 changes: 5 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test": "echo 'No tests available for @corona-dashboard/cli'",
"test:ci": "echo 'No tests available for @corona-dashboard/cli'",
"format": "prettier --write \"src/**/*.{js,ts,tsx}\" \"*.{js,json,md,yml}\"",
"lint": "echo 'No linter configured for @corona-dashboard/cli'",
"lint": "eslint .",
"typecheck": "tsc --pretty --noEmit",
"calculate-boundingboxes": "yarn workspace @corona-dashboard/common build && ts-node src/scripts/calculate-bounding-box-municipalities.ts",
"validate-json": "yarn run validate-json-all",
Expand All @@ -43,6 +43,10 @@
"@types/node": "^16.11.11",
"@types/semver": "^7.3.9",
"@types/topojson-client": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"ts-node": "^10.4.0",
"typescript": "^4.4.4"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/schema/create-validate-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function disableFeatureFlagMetrics(schema: any, features: Feature[]) {
export function createValidateFunction(
schemaOrFilename: string | object,
schemaBasePath: string,
skipFeatureDisable: boolean = false
skipFeatureDisable = false
) {
const schema =
typeof schemaOrFilename === 'string'
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/schema/custom-validations/choropleth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ function validateCommonPropertyEquality(
}

function getCommonProperties(left: UnknownObject, right: UnknownObject) {
return Object.keys(left).filter((key) => right.hasOwnProperty(key));
return Object.keys(left).filter((key) =>
Object.prototype.hasOwnProperty.call(right, key)
);
}

function getCommonDataProperties(
Expand All @@ -130,6 +132,8 @@ function getCommonDataProperties(
.filter(([, values]) => typeof values === 'object')
.map(([key]) => key)
.filter(
(key) => right.hasOwnProperty(key) && !excludedProperties.includes(key)
(key) =>
Object.prototype.hasOwnProperty.call(right, key) &&
!excludedProperties.includes(key)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const fileHeader = `/** This file was generated by a CLI package script
return acc;
}

let bbox = turf.bbox(region.geometry);
const bbox = turf.bbox(region.geometry);
/**
* Enlarge the bounding slightly because the map is rendered in a larger boundingbox
* than just the safetyregion. (some surrounding municipals are also visible).
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/scripts/validate-json-single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if (!fs.existsSync(path.join(jsonBasePath, jsonFileName))) {
}

const schemaBasePath = path.join(schemaDirectory, schemaName);
let rootSchema = metricName
const rootSchema = metricName
? loadStrippedSchema(metricName, schemaBasePath)
: '__index.json';

Expand Down
4 changes: 1 addition & 3 deletions packages/cms/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
"plugin:react-hooks/recommended"
],
"settings": {
"react": {
Expand Down
75 changes: 8 additions & 67 deletions packages/common/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,77 +1,18 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
],
"settings": {
"react": {
"version": "16.13.1"
}
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"extends": ["../../eslint-config"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
"react/prop-types": 0,
"no-console": [
2,
{
"allow": ["warn", "error"]
}
]
"sourceType": "module"
},
"overrides": [
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
"../../eslint-overrides"
],
"files": ["*.ts", "*.tsx"],
"rules": {
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
"react/prop-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/indent": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-unused-vars": [
2,
{
"argsIgnorePattern": "^_"
}
],
"no-restricted-imports": [
"error",
{
"name": "next/link",
"message": "Please use the custom ~/utils/link instead"
}
]
}
"files": [
"*.ts",
"*.tsx"
]
}
]
}
}
Loading