Skip to content

Commit

Permalink
linters.start
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminaAiren committed Jun 1, 2022
1 parent 6b2c5d2 commit f7d389b
Show file tree
Hide file tree
Showing 11 changed files with 742 additions and 23 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
246 changes: 246 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
'extends': [
'next/core-web-vitals',
'eslint:recommended',
'plugin:react/recommended',
'plugin:regexp/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: [
'es5',
'react',
'regexp',
'@typescript-eslint',
'react-hooks',
'jsx-a11y',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
pragma: 'React',
version: 'detect',
},
},
rules: {
'@typescript-eslint/array-type': [ 'error', {
'default': 'generic',
readonly: 'generic',
} ],
'@typescript-eslint/brace-style': [ 'error', '1tbs' ],
'@typescript-eslint/consistent-type-imports': [ 'error' ],
'@typescript-eslint/indent': [ 'error', 2 ],
'@typescript-eslint/member-delimiter-style': [ 'error' ],
'@typescript-eslint/naming-convention': [ 'error',
{
selector: 'default',
format: [ 'camelCase' ],
leadingUnderscore: 'allow',
trailingUnderscore: 'forbid',
},
{
selector: 'class',
format: [ 'PascalCase' ],
},
{
selector: 'enum',
format: [ 'PascalCase', 'UPPER_CASE' ],
},
{
selector: 'enumMember',
format: [ 'camelCase', 'PascalCase', 'UPPER_CASE' ],
},
{
selector: 'function',
format: [ 'camelCase', 'PascalCase' ],
},
{
selector: 'interface',
format: [ 'PascalCase' ],
},
{
selector: 'method',
format: [ 'camelCase', 'snake_case', 'UPPER_CASE' ],
leadingUnderscore: 'allow',
},
{
selector: 'parameter',
format: [ 'camelCase', 'PascalCase' ],
leadingUnderscore: 'allow',
},
{
selector: 'property',
format: null,
},
{
selector: 'typeAlias',
format: [ 'PascalCase' ],
},
{
selector: 'typeParameter',
format: [ 'PascalCase', 'UPPER_CASE' ],
},
{
selector: 'variable',
format: [ 'camelCase', 'PascalCase', 'UPPER_CASE' ],
leadingUnderscore: 'allow',
},
],
'@typescript-eslint/no-duplicate-imports': [ 'error' ],
'@typescript-eslint/no-empty-function': [ 'off' ],
'@typescript-eslint/no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-useless-constructor': [ 'error' ],
'@typescript-eslint/type-annotation-spacing': 'error',

// отключены в пользу @typescript-eslint
'brace-style': 'off',
camelcase: 'off',
indent: 'off',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'no-useless-constructor': 'off',

'array-bracket-spacing': [ 'error', 'always' ],
'arrow-spacing': [ 'error', { before: true, after: true } ],
'comma-dangle': [ 'error', 'always-multiline' ],
'comma-spacing': [ 'error' ],
'comma-style': [ 'error', 'last' ],
curly: [ 'error', 'all' ],
'eol-last': 'error',
eqeqeq: [ 'error', 'allow-null' ],
'id-match': [ 'error', '^[\\w$]+$' ],
'jsx-quotes': [ 'error', 'prefer-double' ],
'key-spacing': [ 'error', {
beforeColon: false,
afterColon: true,
} ],
'keyword-spacing': 'error',
'linebreak-style': [ 'error', 'unix' ],
'lines-around-comment': [ 'error', {
beforeBlockComment: true,
allowBlockStart: true,
} ],
'max-len': [ 'error', 160, 4 ],
'no-console': 'error',
'no-empty': [ 'error', { allowEmptyCatch: true } ],
'no-implicit-coercion': [ 'error', {
number: true,
'boolean': true,
string: true,
} ],
'no-mixed-operators': [ 'error', {
groups: [
[ '&&', '||' ],
],
} ],
'no-mixed-spaces-and-tabs': 'error',
'no-multiple-empty-lines': [ 'error', {
max: 1,
maxEOF: 0,
maxBOF: 0,
} ],
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-nested-ternary': 'error',
'no-trailing-spaces': 'error',
'no-spaced-func': 'error',
'no-with': 'error',
'object-curly-spacing': [ 'error', 'always' ],
'object-shorthand': 'off',
'one-var': [ 'error', 'never' ],
'operator-linebreak': [ 'error', 'after' ],
'prefer-const': 'error',
'quote-props': [ 'error', 'as-needed', {
keywords: true,
numbers: true,
} ],
quotes: [ 'error', 'single', {
allowTemplateLiterals: true,
} ],
'space-before-function-paren': [ 'error', 'never' ],
'space-before-blocks': [ 'error', 'always' ],
'space-in-parens': [ 'error', 'never' ],
'space-infix-ops': 'error',
'space-unary-ops': 'off',
'template-curly-spacing': [ 'error', 'always' ],
'wrap-iife': [ 'error', 'inside' ],

'react/jsx-key': 'error',
'react/jsx-no-bind': [ 'error', {
ignoreRefs: true,
} ],
'react/jsx-curly-brace-presence': [ 'error', {
props: 'never',
children: 'never',
} ],
'react/jsx-curly-spacing': [ 'error', {
when: 'always',
children: true,
spacing: {
objectLiterals: 'never',
},
} ],
'react/jsx-equals-spacing': [ 'error', 'never' ],
'react/jsx-fragments': [ 'error', 'syntax' ],
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-target-blank': 'off',
'react/jsx-no-useless-fragment': 'error',
'react/jsx-tag-spacing': [ 'error', {
afterOpening: 'never',
beforeSelfClosing: 'never',
closingSlash: 'never',
} ],
'react/jsx-wrap-multilines': [ 'error', {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
'return': 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line',
} ],
'react/no-access-state-in-setstate': 'error',
'react/no-deprecated': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-find-dom-node': 'off',
'react/no-redundant-should-component-update': 'error',
'react/no-render-return-value': 'error',
'react/no-string-refs': 'off',
'react/no-unknown-property': 'error',
'react/no-unused-state': 'error',
'react/require-optimization': [ 'error' ],
'react/void-dom-elements-no-children': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',

'regexp/confusing-quantifier': 'error',
'regexp/control-character-escape': 'error',
'regexp/negation': 'error',
'regexp/no-dupe-disjunctions': 'error',
'regexp/no-empty-alternative': 'error',
'regexp/no-empty-capturing-group': 'error',
'regexp/no-lazy-ends': 'error',
'regexp/no-obscure-range': [ 'error', {
allowed: [ 'alphanumeric', 'А-Я', 'а-я' ],
} ],
'regexp/no-optional-assertion': 'error',
'regexp/no-unused-capturing-group': [ 'error', {
fixable: true,
} ],
'regexp/no-useless-character-class': 'error',
'regexp/no-useless-dollar-replacements': 'error',
},
};
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ yarn-error.log*

# typescript
*.tsbuildinfo

.eslintcache
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"prepare": "husky install"
},
"dependencies": {
"@chakra-ui/react": "^2.1.2",
Expand All @@ -21,8 +22,16 @@
"@types/node": "17.0.36",
"@types/react": "18.0.9",
"@types/react-dom": "18.0.5",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"eslint": "8.16.0",
"eslint-config-next": "12.1.6",
"eslint-plugin-es5": "^1.5.0",
"eslint-plugin-regexp": "^1.7.0",
"husky": "^8.0.0",
"lint-staged": ">=10",
"typescript": "4.7.2"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": "eslint --cache --fix"
}
}
9 changes: 5 additions & 4 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { AppProps } from 'next/app'
import {ChakraProvider} from '@chakra-ui/react';
import React from 'react';
import type { AppProps } from 'next/app';
import { ChakraProvider } from '@chakra-ui/react';

function MyApp({ Component, pageProps }: AppProps) {
return (
<ChakraProvider>
<Component {...pageProps} />
<Component { ...pageProps }/>
</ChakraProvider>
)
);
}

export default MyApp
4 changes: 2 additions & 2 deletions pages/api/hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import type { NextApiRequest, NextApiResponse } from 'next'

type Data = {
name: string
name: string;
}

export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
res: NextApiResponse<Data>,
) {
res.status(200).json({ name: 'John Doe' })
}
13 changes: 7 additions & 6 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { NextPage } from 'next'
import {Center} from '@chakra-ui/react';
import React from 'react';
import type { NextPage } from 'next';
import { Center } from '@chakra-ui/react';

const Home: NextPage = () => {
return (
<Center w='100%' h='100vh'>
Home Page
<Center w="100%" h="100vh">
Home Page
</Center>
)
}
);
};

export default Home
Loading

0 comments on commit f7d389b

Please sign in to comment.