Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMGCIP-179: Configure linters #31

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
126 changes: 124 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,128 @@
{
"extends": ["next/core-web-vitals", "prettier"],
"root": true,
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:react-hooks/recommended"
],
"ignorePatterns": ["node_modules", "src/__generated__", "build", "coverage"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"project": "./tsconfig.json",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["@typescript-eslint", "eslint-plugin-import", "unused-imports", "import"],
"rules": {
"@next/next/no-img-element": 0
"@next/next/no-img-element": "off",
"@typescript-eslint/array-type": [
"error",
{
"default": "array-simple"
}
],
"@typescript-eslint/consistent-return": "warn",
"@typescript-eslint/no-empty-function": [
"warn",
{
"allow": ["arrowFunctions"]
}
],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-implied-eval": "error",
"@typescript-eslint/no-mixed-enums": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/only-throw-error": "error",
"@typescript-eslint/prefer-enum-initializers": "warn",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/unified-signatures": "error",
"complexity": [
"warn",
{
"max": 5
}
],
"consistent-return": "off",
"import/no-unresolved": "error",
"import/order": [
"error",
{
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"groups": ["external", "internal"],
"newlines-between": "always",
"pathGroups": [
{
"pattern": "react",
"group": "external",
"position": "before"
},
{
"pattern": "@/**",
"group": "internal",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["react"]
}
],
"max-depth": ["warn", 2],
"max-lines": ["warn", 200],
"max-nested-callbacks": ["warn", 3],
"max-params": ["warn", 3],
"max-statements-per-line": [
"warn",
{
"max": 1
}
],
"newline-before-return": "error",
"no-case-declarations": "warn",
"no-else-return": "error",
"no-magic-numbers": [
"warn",
{
"detectObjects": false,
"enforceConst": true,
"ignore": [-1, 0, 1, 2, 10, 100],
"ignoreArrayIndexes": true
}
],
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 1
}
],
"no-nested-ternary": "error",
"no-return-await": "off",
"no-throw-literal": "off",
"no-unneeded-ternary": "error",
"no-warning-comments": "warn",
"one-var-declaration-per-line": ["warn", "always"],
"react/display-name": "warn",
"react/sort-comp": "warn",
"sort-keys": "warn",
"unused-imports/no-unused-imports": "error"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
}
}
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ yarn-error.log*
next-env.d.ts

.vercel

# JetBrains IDE
/.idea

# VS Code
/.vscode

# VS
/.vs
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore 3rd party dependencies
node_modules/

# Ignore generated code
src/__generated__/

# Ignore artifacts:
build
coverage
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"semi": true
"trailingComma": "all"
}
8 changes: 4 additions & 4 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CodegenConfig } from "@graphql-codegen/cli";
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
Expand All @@ -15,10 +15,10 @@ const config: CodegenConfig = {
plugins: ["typescript-operations", "typed-document-node"],
},
},*/
documents: ["src/components/**/*.gql"],
documents: ['src/components/**/*.gql'],
generates: {
"src/__generated__/": {
preset: "client-preset",
'src/__generated__/': {
preset: 'client-preset',
},
},
};
Expand Down
16 changes: 8 additions & 8 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* https://jestjs.io/docs/configuration
*/

import type { Config } from "jest";
import nextJest from "next/jest.js";
import type { Config } from 'jest';
import nextJest from 'next/jest.js';

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
dir: './',
});

const config: Config = {
Expand Down Expand Up @@ -39,7 +39,7 @@ const config: Config = {
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
coverageProvider: 'v8',

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
Expand Down Expand Up @@ -97,7 +97,7 @@ const config: Config = {

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
'^@/(.*)$': '<rootDir>/src/$1',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand Down Expand Up @@ -142,7 +142,7 @@ const config: Config = {
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: ["./setupTests.ts"],
setupFiles: ['./setupTests.ts'],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
Expand All @@ -154,7 +154,7 @@ const config: Config = {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "jsdom",
testEnvironment: 'jsdom',

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand Down Expand Up @@ -211,7 +211,7 @@ const jestConfigWithOverrides = async () => {
res.moduleNameMapper = {
// We cannot depend on the exact key used by Next.js
// so we inject an SVG key higher up on the mapping tree
"\\.svg": "<rootDir>/src/mocks/svgrMock.ts",
'\\.svg': '<rootDir>/src/mocks/svgrMock.ts',
...res.moduleNameMapper,
};

Expand Down
7 changes: 2 additions & 5 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const config = {
'*.{js,jsx,ts,tsx}':[
'eslint --fix --max-warnings 0',
'prettier --write'
],
'*.{js,jsx,ts,tsx}': ['eslint --fix --max-warnings 20', 'prettier --write'],
'*.{json,scss,css}': ['prettier --write'],
}
};

export default config;
Loading
Loading