Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
morewings committed May 12, 2024
1 parent e891f4c commit 5cb59a4
Show file tree
Hide file tree
Showing 34 changed files with 1,034 additions and 437 deletions.
134 changes: 101 additions & 33 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
module.exports = {
root: true,
env: {browser: true, es2020: true, node: true, jest: true},
parserOptions: {
ecmaVersion: 'latest',
// eslint-disable-next-line no-undef
tsconfigRootDir: __dirname,
sourceType: 'module',
},
settings: {
react: {
version: 'detect',
},
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'next/core-web-vitals',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'next/core-web-vitals',
'plugin:ssr-friendly/recommended',
'plugin:prettier/recommended'
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['prettier', '@typescript-eslint', 'ssr-friendly'],
plugins: ['import', 'prettier', '@typescript-eslint', 'ssr-friendly'],
rules: {
/**
* Allow empty arrow functions `() => {}`, while keeping other empty functions restricted
* @see https://eslint.org/docs/latest/rules/no-empty-function#allow-arrowfunctions
*/
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
'@typescript-eslint/no-empty-function': ['error', {allow: ['arrowFunctions']}],
'@typescript-eslint/ban-ts-comment': 1,
'no-const-assign': 'error',
/** Restrict imports from devDependencies since they are not included in library build. peerDependencies are ok */
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
peerDependencies: true
}
peerDependencies: true,
},
],
/**
* Enforce import order with empty lines between import group
Expand All @@ -39,20 +47,15 @@ module.exports = {
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index']
],
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
pathGroups: [
{
pattern: '@/**',
group: 'internal'
}
group: 'internal',
},
],
'newlines-between': 'always'
}
'newlines-between': 'always',
},
],
/**
* Disallow combined module and type imports like this `import React, {FC} from 'react'`.
Expand All @@ -61,14 +64,79 @@ module.exports = {
*/
'@typescript-eslint/consistent-type-imports': 'error',
'import/no-cycle': 'error',
'prettier/prettier': ['error', {
semi: true,
singleQuote: true,
jsxSingleQuote: false,
trailingComma: 'none',
bracketSpacing: true,
jsxBracketSameLine: true,
arrowParens: 'avoid'
}]
}
'prettier/prettier': [
'error',
{
semi: true,
singleQuote: true,
jsxSingleQuote: false,
trailingComma: 'es5',
bracketSpacing: false,
jsxBracketSameLine: true,
arrowParens: 'avoid',
},
],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
/**
* Allow unused variables with names stating with '_'
* @see https://eslint.org/docs/latest/rules/no-unused-vars
* @see https://typescript-eslint.io/rules/no-unused-vars/
*/
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
args: 'after-used',
},
],
},
overrides: [
/* Allow require imports for internal scripts */
{
files: ['*.js', '*.cjs'],
rules: {
'@typescript-eslint/no-var-requires': 0,
},
},
/* Allow devDependencies imports for tests and config files */
{
files: [
'**/*.spec.*',
'**/testUtils/*.*',
'**/*.js',
'**/*.cjs',
'**/setupTests.ts',
],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
peerDependencies: true,
},
],
},
},
/* Disable `template` directory imports for all files */
{
files: ['./src/**/*.*'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/templates/**'],
message: 'Imports from templates directory are forbidden.',
},
],
},
],
},
}
],
};

4 changes: 0 additions & 4 deletions .eslintrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This template is for Next based web applications using Redux.

Tba

## Features

- Supports **Typescript**.
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"start": "next start",
"lint:code": "eslint src/ --ext .js,.jsx,.ts,.tsx",
"fix:code": "run-s 'lint:code --fix'",
"lint:style": "stylelint 'src/**/*.{ts,tsx}'",
"fix:style": "stylelint 'src/**/*.{ts,tsx}' --fix",
"lint:style": "stylelint 'src/**/*.css'",
"fix:style": "stylelint 'src/**/*.css' --fix",
"lint:tsc": "tsc --pretty --noEmit",
"prepare": "is-ci || husky install"
},
Expand All @@ -30,11 +30,14 @@
"@types/react-dom": "18.2.15",
"@types/uniqid": "5.3.4",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "^7.8.0",
"eslint": "8.53.0",
"eslint-config-next": "13.5.6",
"eslint-config-prettier": "8.10.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-ssr-friendly": "1.2.0",
"husky": "8.0.3",
Expand Down
Loading

0 comments on commit 5cb59a4

Please sign in to comment.