@snyggt/base 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +11 -0
- package/eslint/node.mjs +139 -0
- package/eslint/react.mjs +38 -0
- package/jest/jest-preset.mjs +12 -0
- package/package.json +48 -0
- package/prettier/index.mjs +10 -0
- package/templates/eslint.config.mjs +3 -0
- package/templates/jest.config.mjs +3 -0
- package/templates/tsconfig.json +3 -0
- package/typescript/tsconfig.json +22 -0
- package/typescript/tsconfig.prod.json +17 -0
package/README.md
ADDED
package/eslint/node.mjs
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
import eslint from '@eslint/js'
|
2
|
+
import tseslint from 'typescript-eslint'
|
3
|
+
import eslintConfigPrettier from 'eslint-config-prettier'
|
4
|
+
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'
|
5
|
+
import jestPlugin from 'eslint-plugin-jest'
|
6
|
+
|
7
|
+
export const defaultEsTsConfigs = [
|
8
|
+
eslint.configs.recommended,
|
9
|
+
...tseslint.configs.recommended,
|
10
|
+
eslintConfigPrettier,
|
11
|
+
eslintPluginPrettier,
|
12
|
+
].map(config => ({
|
13
|
+
...config,
|
14
|
+
files: ['**/*.ts', '**/*.tsx'],
|
15
|
+
}))
|
16
|
+
|
17
|
+
const ignoredFolders = [
|
18
|
+
'dist',
|
19
|
+
'.dist',
|
20
|
+
'bin',
|
21
|
+
'.bin',
|
22
|
+
'cdk.out',
|
23
|
+
'storybook-static',
|
24
|
+
'.storybook',
|
25
|
+
'.next',
|
26
|
+
]
|
27
|
+
export const defaultIgnoreDist = {
|
28
|
+
ignores: ignoredFolders.flatMap(folder => [`**/${folder}/**`, folder]),
|
29
|
+
}
|
30
|
+
|
31
|
+
export const defaultTsLanguageConfig = {
|
32
|
+
files: ['**/*.ts', '**/*.tsx'],
|
33
|
+
plugins: {
|
34
|
+
'@typescript-eslint': tseslint.plugin,
|
35
|
+
jest: jestPlugin,
|
36
|
+
},
|
37
|
+
languageOptions: {
|
38
|
+
parserOptions: {
|
39
|
+
projectService: { allowDefaultProject: ['*.js', '*.mjs'] },
|
40
|
+
ecmaFeatures: {
|
41
|
+
jsx: true,
|
42
|
+
},
|
43
|
+
allowImportExportEverywhere: true,
|
44
|
+
},
|
45
|
+
ecmaVersion: 2022,
|
46
|
+
sourceType: 'module',
|
47
|
+
globals: {
|
48
|
+
node: true,
|
49
|
+
commonjs: true,
|
50
|
+
es6: true,
|
51
|
+
browser: true,
|
52
|
+
jest: true,
|
53
|
+
},
|
54
|
+
},
|
55
|
+
}
|
56
|
+
|
57
|
+
export const defaultJsLanguageConfig = {
|
58
|
+
files: ['**/*.js'],
|
59
|
+
languageOptions: {
|
60
|
+
parserOptions: {
|
61
|
+
allowImportExportEverywhere: true,
|
62
|
+
},
|
63
|
+
sourceType: 'commonjs',
|
64
|
+
globals: {
|
65
|
+
node: true,
|
66
|
+
commonjs: true,
|
67
|
+
browser: true,
|
68
|
+
jest: true,
|
69
|
+
},
|
70
|
+
},
|
71
|
+
}
|
72
|
+
|
73
|
+
const defaultOverrideRules = {
|
74
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
75
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
76
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
77
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
78
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
79
|
+
'@typescript-eslint/no-empty-function': [
|
80
|
+
'error',
|
81
|
+
{ allow: ['functions', 'arrowFunctions'] },
|
82
|
+
],
|
83
|
+
|
84
|
+
'@typescript-eslint/no-unused-vars': [
|
85
|
+
'error',
|
86
|
+
{
|
87
|
+
args: 'all',
|
88
|
+
argsIgnorePattern: '^_',
|
89
|
+
caughtErrors: 'all',
|
90
|
+
caughtErrorsIgnorePattern: '^_',
|
91
|
+
destructuredArrayIgnorePattern: '^_',
|
92
|
+
varsIgnorePattern: '^_',
|
93
|
+
ignoreRestSiblings: true,
|
94
|
+
},
|
95
|
+
],
|
96
|
+
'@/quotes': [
|
97
|
+
'error',
|
98
|
+
'single',
|
99
|
+
{ allowTemplateLiterals: false, avoidEscape: true },
|
100
|
+
],
|
101
|
+
'no-unsafe-negation': 'off',
|
102
|
+
'no-var': 'error',
|
103
|
+
'prefer-const': 'error',
|
104
|
+
'prefer-rest-params': 'error',
|
105
|
+
'prefer-spread': 'error',
|
106
|
+
}
|
107
|
+
|
108
|
+
export const defaultRuleOverrides = {
|
109
|
+
files: ['**/*.ts', '**/*.tsx'],
|
110
|
+
rules: defaultOverrideRules,
|
111
|
+
}
|
112
|
+
|
113
|
+
export const defaultDisableTypecheckOnJs = {
|
114
|
+
...tseslint.configs.disableTypeChecked,
|
115
|
+
files: ['**/*.js', '**/*.mjs'],
|
116
|
+
rules: { ...tseslint.configs.disableTypeChecked.rules },
|
117
|
+
}
|
118
|
+
|
119
|
+
export const defaultJestRules = {
|
120
|
+
...jestPlugin.configs['flat/recommended'],
|
121
|
+
files: ['test/*.test.ts', '**/*.test.ts', 'test/*.test.tsx', '**/*.test.tsx'],
|
122
|
+
rules: {
|
123
|
+
...jestPlugin.configs['flat/recommended'].rules,
|
124
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
125
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
126
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
127
|
+
'@typescript-eslint/no-require-imports': 'off',
|
128
|
+
},
|
129
|
+
}
|
130
|
+
|
131
|
+
export default tseslint.config(
|
132
|
+
defaultIgnoreDist,
|
133
|
+
...defaultEsTsConfigs,
|
134
|
+
defaultJsLanguageConfig,
|
135
|
+
defaultTsLanguageConfig,
|
136
|
+
defaultRuleOverrides,
|
137
|
+
defaultDisableTypecheckOnJs,
|
138
|
+
defaultJestRules,
|
139
|
+
)
|
package/eslint/react.mjs
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
import nodeBase, { defaultRuleOverrides } from './node.mjs'
|
2
|
+
import tseslint from 'typescript-eslint'
|
3
|
+
import pluginReactHooks from 'eslint-plugin-react-hooks'
|
4
|
+
import reactPlugin from 'eslint-plugin-react'
|
5
|
+
|
6
|
+
export const defaultReactLint = {
|
7
|
+
files: ['**/*.ts', '**/*.tsx'],
|
8
|
+
plugins: {
|
9
|
+
'react-hooks': pluginReactHooks,
|
10
|
+
},
|
11
|
+
rules: {
|
12
|
+
...pluginReactHooks.configs.recommended.rules,
|
13
|
+
...defaultRuleOverrides.rules,
|
14
|
+
'react/react-in-jsx-scope': 'off',
|
15
|
+
'react/prop-types': 'off',
|
16
|
+
},
|
17
|
+
}
|
18
|
+
|
19
|
+
export const defaultReactPlugin = {
|
20
|
+
files: ['**/*.ts', '**/*.tsx'],
|
21
|
+
plugins: {
|
22
|
+
react: reactPlugin,
|
23
|
+
},
|
24
|
+
rules: {
|
25
|
+
...reactPlugin.configs['jsx-runtime'].rules,
|
26
|
+
},
|
27
|
+
settings: {
|
28
|
+
react: {
|
29
|
+
version: 'detect',
|
30
|
+
},
|
31
|
+
},
|
32
|
+
}
|
33
|
+
|
34
|
+
export default tseslint.config(
|
35
|
+
...nodeBase,
|
36
|
+
defaultReactLint,
|
37
|
+
defaultReactPlugin
|
38
|
+
)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export default {
|
2
|
+
testEnvironment: 'node',
|
3
|
+
transform: { '^.+\\.tsx?$': ['ts-jest', {}] },
|
4
|
+
modulePaths: ['src', 'src/lib'],
|
5
|
+
testPathIgnorePatterns: [
|
6
|
+
'<rootDir>/.next/',
|
7
|
+
'<rootDir>/dist/',
|
8
|
+
'<rootDir>/node_modules/',
|
9
|
+
'<rootDir>/node_modules/.pnpm',
|
10
|
+
],
|
11
|
+
prettierPath: null,
|
12
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
{
|
2
|
+
"name": "@snyggt/base",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "Base configurations",
|
5
|
+
"main": "index.js",
|
6
|
+
"files": [
|
7
|
+
"prettier",
|
8
|
+
"eslint",
|
9
|
+
"jest",
|
10
|
+
"typescript",
|
11
|
+
"templates"
|
12
|
+
],
|
13
|
+
"exports": {
|
14
|
+
"./eslint/node": "./eslint/node.mjs",
|
15
|
+
"./eslint/react": "./eslint/react.mjs",
|
16
|
+
"./prettier": "./prettier/index.mjs",
|
17
|
+
"./jest": "./jest/jest-preset.mjs",
|
18
|
+
"./ts-base": "./typescript/tsconfig.json",
|
19
|
+
"./ts-prod": "./typescript/tsconfig.prod.json"
|
20
|
+
},
|
21
|
+
"keywords": [],
|
22
|
+
"author": "",
|
23
|
+
"license": "ISC",
|
24
|
+
"peerDependencies": {
|
25
|
+
"jest": "29.7.x",
|
26
|
+
"typescript": "5.6.x",
|
27
|
+
"eslint": "9.13.x",
|
28
|
+
"prettier": "3.3.x"
|
29
|
+
},
|
30
|
+
"prettier": "@snyggt/base/prettier",
|
31
|
+
"dependencies": {
|
32
|
+
"@babel/preset-typescript": "7.26.0",
|
33
|
+
"@eslint/js": "9.13.0",
|
34
|
+
"@types/jest": "29.5.14",
|
35
|
+
"@types/node": "22.8.4",
|
36
|
+
"eslint-config-prettier": "9.1.0",
|
37
|
+
"eslint-plugin-jest": "28.8.3",
|
38
|
+
"eslint-plugin-prettier": "5.2.1",
|
39
|
+
"eslint-plugin-react": "^7.37.2",
|
40
|
+
"eslint-plugin-react-hooks": "5.1.0-beta-26f2496093-20240514",
|
41
|
+
"hello-world-npm": "^1.1.1",
|
42
|
+
"jest": "29.7.0",
|
43
|
+
"ts-jest": "29.2.5",
|
44
|
+
"typescript": "5.6.3",
|
45
|
+
"typescript-eslint": "8.11.0"
|
46
|
+
},
|
47
|
+
"packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387"
|
48
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "es2022",
|
4
|
+
"module": "CommonJS",
|
5
|
+
"outDir": "${configDir}/dist",
|
6
|
+
"declaration": true,
|
7
|
+
"emitDeclarationOnly": true,
|
8
|
+
"esModuleInterop": true,
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
10
|
+
"strict": true,
|
11
|
+
"skipLibCheck": true,
|
12
|
+
"paths": {
|
13
|
+
"*": ["${configDir}/src/*", "${configDir}/src/lib/*"]
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"include": ["${configDir}/**/*.ts", "${configDir}/**/*.tsx"],
|
17
|
+
"exclude": [
|
18
|
+
"${configDir}/**/dist**",
|
19
|
+
"${configDir}/**/tmp/**",
|
20
|
+
"${configDir}/**/node_modules**"
|
21
|
+
]
|
22
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"extends": "./tsconfig.json",
|
3
|
+
"compilerOptions": {
|
4
|
+
"outDir": "${configDir}/dist",
|
5
|
+
"esModuleInterop": true,
|
6
|
+
"resolveJsonModule": true,
|
7
|
+
"emitDeclarationOnly": true,
|
8
|
+
"declaration": true,
|
9
|
+
"allowJs": true
|
10
|
+
},
|
11
|
+
"exclude": ["${configDir}/**/dist**", "${configDir}/**/*.test.ts"],
|
12
|
+
"include": [
|
13
|
+
"${configDir}/**/*.ts",
|
14
|
+
"${configDir}/**/*.tsx",
|
15
|
+
"${configDir}/**/*.sh"
|
16
|
+
]
|
17
|
+
}
|