Skip to content

Commit 9fd0ce8

Browse files
committed
Update build and configuration files
- Modernize ESLint configuration with new flat config format - Update Rollup build configuration for better output - Refine TypeScript compiler options for stricter type checking - Add path alias configuration to Vitest - Update .gitignore for better file exclusion
1 parent b7d191e commit 9fd0ce8

5 files changed

Lines changed: 102 additions & 156 deletions

File tree

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.DS_Store
2-
.claude/
3-
CLAUDE.md
2+
.vscode/
43
cache/
54
coverage/
65
dist/
7-
node_modules/
6+
node_modules/

eslint.config.js

Lines changed: 73 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,214 +1,149 @@
1-
// @ts-check
21
import { defineConfig } from 'eslint/config';
2+
import eslint from '@eslint/js';
33
import tseslint from 'typescript-eslint';
4+
import stylistic from '@stylistic/eslint-plugin';
45

56
export default defineConfig(
6-
tseslint.configs.strict,
7-
tseslint.configs.stylistic,
7+
eslint.configs.recommended,
8+
tseslint.configs.strictTypeChecked,
9+
tseslint.configs.stylisticTypeChecked,
10+
{
11+
ignores: ["**/*.js", "coverage", "dist", "docs"]
12+
},
813
{
914
files: ['**/*.ts'],
15+
plugins: {
16+
'@stylistic': stylistic
17+
},
1018
languageOptions: {
1119
ecmaVersion: 2021,
1220
sourceType: 'module',
1321
globals: {
1422
process: true
1523
},
1624
parserOptions: {
17-
project: './tsconfig.json',
18-
tsconfigRootDir: import.meta.dirname
25+
projectService: true
1926
}
2027
},
2128
rules: {
2229
'@typescript-eslint/no-extraneous-class': 'off',
23-
'@typescript-eslint/no-unused-vars': ['error', { 'caughtErrors': 'none' }],
24-
'@typescript-eslint/unified-signatures': ['error', { 'ignoreDifferentlyNamedParameters': true }],
25-
'array-bracket-spacing': ['warn', 'never'],
26-
'array-callback-return': 'error',
27-
'constructor-super': 'error',
28-
'for-direction': 'error',
29-
'getter-return': 'error',
30-
'no-async-promise-executor': 'error',
31-
'no-class-assign': 'error',
32-
'no-compare-neg-zero': 'error',
33-
'no-cond-assign': 'error',
34-
'no-const-assign': 'error',
35-
'no-constant-binary-expression': 'error',
36-
'no-constant-condition': 'error',
37-
'no-constructor-return': 'error',
38-
'no-control-regex': 'error',
39-
'no-debugger': 'error',
40-
'no-dupe-args': 'error',
41-
'no-dupe-class-members': 'error',
42-
'no-dupe-else-if': 'error',
43-
'no-dupe-keys': 'error',
44-
'no-duplicate-case': 'error',
45-
'no-empty-character-class': 'error',
46-
'no-empty-pattern': 'error',
47-
'no-ex-assign': 'error',
48-
'no-fallthrough': 'error',
49-
'no-func-assign': 'error',
50-
'no-import-assign': 'error',
51-
'no-inner-declarations': 'error',
52-
'no-invalid-regexp': 'error',
53-
'no-irregular-whitespace': 'error',
54-
'no-loss-of-precision': 'error',
55-
'no-misleading-character-class': 'error',
56-
'no-new-native-nonconstructor': 'error',
57-
'no-new-symbol': 'error',
58-
'no-obj-calls': 'error',
59-
'no-self-assign': 'error',
60-
'no-self-compare': 'error',
61-
'no-setter-return': 'error',
62-
'no-sparse-arrays': 'error',
63-
'no-template-curly-in-string': 'error',
64-
'no-this-before-super': 'error',
65-
'no-undef': 'error',
66-
'no-unexpected-multiline': 'error',
67-
'no-unmodified-loop-condition': 'error',
68-
'no-unreachable': 'error',
69-
'no-unreachable-loop': 'error',
70-
'no-unsafe-finally': 'error',
71-
'no-unsafe-negation': 'error',
72-
'no-unsafe-optional-chaining': 'error',
73-
'no-unused-private-class-members': 'error',
74-
'no-use-before-define': 'error',
75-
'no-useless-backreference': 'error',
76-
'require-atomic-updates': 'error',
77-
'use-isnan': 'error',
78-
'valid-typeof': 'error',
30+
7931
'accessor-pairs': 'error',
32+
'array-callback-return': 'error',
8033
'block-scoped-var': 'error',
8134
'consistent-return': 'error',
8235
'curly': 'error',
8336
'default-case-last': 'error',
84-
'dot-notation': 'error',
8537
'eqeqeq': ['error', 'smart'],
8638
'func-name-matching': 'error',
87-
'func-style': ['error', 'expression', { 'overrides': { 'namedExports': 'ignore' } }],
39+
'func-style': ['error', 'expression', { overrides: { namedExports: 'ignore' } }],
8840
'grouped-accessor-pairs': 'error',
89-
'id-denylist': 'error',
90-
'id-match': 'error',
9141
'max-depth': 'error',
9242
'max-nested-callbacks': 'error',
9343
'new-cap': 'error',
94-
'no-array-constructor': 'error',
9544
'no-caller': 'error',
96-
'no-delete-var': 'error',
45+
'no-constructor-return': 'error',
9746
'no-div-regex': 'error',
9847
'no-else-return': 'error',
9948
'no-empty-static-block': 'error',
10049
'no-eval': 'error',
10150
'no-extend-native': 'error',
10251
'no-extra-bind': 'error',
103-
'no-extra-boolean-cast': 'error',
10452
'no-extra-label': 'error',
105-
'no-extra-semi': 'error',
106-
'no-floating-decimal': 'error',
107-
'no-global-assign': 'error',
10853
'no-implicit-globals': 'error',
10954
'no-implied-eval': 'error',
11055
'no-iterator': 'error',
11156
'no-label-var': 'error',
11257
'no-labels': 'error',
11358
'no-lone-blocks': 'error',
11459
'no-lonely-if': 'error',
115-
'no-loop-func': 'error',
116-
'no-multi-assign': ['error', { 'ignoreNonDeclaration': true }],
60+
'no-multi-assign': ['error', { ignoreNonDeclaration: true }],
11761
'no-multi-str': 'error',
11862
'no-negated-condition': 'error',
11963
'no-new': 'error',
12064
'no-new-func': 'error',
121-
'no-new-object': 'error',
12265
'no-new-wrappers': 'error',
123-
'no-nonoctal-decimal-escape': 'error',
124-
'no-octal': 'error',
66+
'no-object-constructor': 'error',
12567
'no-octal-escape': 'error',
12668
'no-proto': 'error',
127-
'no-regex-spaces': 'error',
128-
'no-restricted-exports': 'error',
129-
'no-restricted-globals': 'error',
130-
'no-restricted-imports': 'error',
131-
'no-restricted-properties': 'error',
132-
'no-restricted-syntax': 'error',
13369
'no-return-assign': 'error',
134-
'no-return-await': 'error',
13570
'no-script-url': 'error',
71+
'no-self-compare': 'error',
13672
'no-sequences': 'error',
137-
'no-shadow': 'error',
13873
'no-shadow-restricted-names': 'error',
139-
'no-throw-literal': 'error',
74+
'no-template-curly-in-string': 'error',
14075
'no-undef-init': 'error',
76+
'no-unmodified-loop-condition': 'error',
14177
'no-unneeded-ternary': 'error',
142-
'no-unused-expressions': 'error',
143-
'no-unused-labels': 'error',
78+
'no-unreachable-loop': 'error',
14479
'no-useless-call': 'error',
145-
'no-useless-catch': 'error',
14680
'no-useless-computed-key': 'error',
14781
'no-useless-concat': 'error',
148-
'no-useless-escape': 'error',
14982
'no-useless-rename': 'error',
15083
'no-useless-return': 'error',
15184
'no-void': 'error',
152-
'no-warning-comments': 'warn',
153-
'no-with': 'error',
85+
'no-warning-comments': 'error',
15486
'operator-assignment': 'error',
155-
'prefer-const': 'error',
15687
'prefer-exponentiation-operator': 'error',
15788
'prefer-numeric-literals': 'error',
15889
'prefer-object-has-own': 'error',
15990
'prefer-object-spread': 'error',
160-
'prefer-promise-reject-errors': ['error', { 'allowEmptyReject': true }],
91+
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
16192
'prefer-regex-literals': 'error',
16293
'prefer-rest-params': 'error',
16394
'prefer-spread': 'error',
16495
'radix': 'error',
165-
'require-await': 'error',
166-
'require-yield': 'error',
96+
'require-atomic-updates': 'error',
16797
'symbol-description': 'error',
98+
'unicode-bom': 'error',
16899
'yoda': 'error',
169-
'arrow-spacing': 'warn',
170-
'block-spacing': 'warn',
171-
'comma-dangle': 'warn',
172-
'comma-spacing': 'warn',
173-
'comma-style': 'warn',
174-
'computed-property-spacing': 'warn',
175-
'dot-location': ['warn', 'property'],
176-
'eol-last': 'warn',
177-
'func-call-spacing': 'warn',
178-
'generator-star-spacing': 'warn',
179-
'implicit-arrow-linebreak': 'warn',
180-
'indent': ['warn', 2, { 'ignoreComments': true }],
181-
'jsx-quotes': 'warn',
182-
'key-spacing': 'warn',
183-
'keyword-spacing': 'warn',
184-
'linebreak-style': 'warn',
185-
'lines-between-class-members': 'warn',
186-
'new-parens': 'warn',
187-
'no-extra-parens': ['warn', 'functions'],
188-
'no-mixed-spaces-and-tabs': 'warn',
189-
'no-multi-spaces': ['warn', { 'ignoreEOLComments': true }],
190-
'no-tabs': 'warn',
191-
'no-trailing-spaces': 'warn',
192-
'no-whitespace-before-property': 'warn',
193-
'nonblock-statement-body-position': 'warn',
194-
'object-curly-newline': 'warn',
195-
'object-curly-spacing': ['warn', 'always'],
196-
'padding-line-between-statements': 'warn',
197-
'quotes': ['warn', 'single'],
198-
'rest-spread-spacing': 'warn',
199-
'semi': 'warn',
200-
'semi-spacing': 'warn',
201-
'semi-style': 'warn',
202-
'space-before-blocks': 'warn',
203-
'space-in-parens': 'warn',
204-
'space-infix-ops': 'warn',
205-
'space-unary-ops': 'warn',
206-
'switch-colon-spacing': 'warn',
207-
'template-curly-spacing': 'warn',
208-
'template-tag-spacing': 'warn',
209-
'unicode-bom': 'warn',
210-
'wrap-iife': ['warn', 'any'],
211-
'yield-star-spacing': 'warn'
100+
101+
'@stylistic/array-bracket-spacing': ['warn', 'never'],
102+
'@stylistic/arrow-spacing': 'warn',
103+
'@stylistic/block-spacing': 'warn',
104+
'@stylistic/comma-dangle': 'warn',
105+
'@stylistic/comma-spacing': 'warn',
106+
'@stylistic/comma-style': 'warn',
107+
'@stylistic/computed-property-spacing': 'warn',
108+
'@stylistic/dot-location': ['warn', 'property'],
109+
'@stylistic/eol-last': 'warn',
110+
'@stylistic/function-call-spacing': 'warn',
111+
'@stylistic/generator-star-spacing': 'warn',
112+
'@stylistic/implicit-arrow-linebreak': 'warn',
113+
'@stylistic/indent': ['warn', 2, { ignoreComments: true }],
114+
'@stylistic/jsx-quotes': 'warn',
115+
'@stylistic/key-spacing': 'warn',
116+
'@stylistic/keyword-spacing': 'warn',
117+
'@stylistic/linebreak-style': 'warn',
118+
'@stylistic/lines-between-class-members': 'warn',
119+
'@stylistic/member-delimiter-style': ['warn', { multiline: { delimiter: 'semi', requireLast: true }, singleline: { delimiter: 'semi', requireLast: false } }],
120+
'@stylistic/new-parens': 'warn',
121+
'@stylistic/no-extra-parens': ['warn', 'functions'],
122+
'@stylistic/no-extra-semi': 'warn',
123+
'@stylistic/no-floating-decimal': 'warn',
124+
'@stylistic/no-mixed-spaces-and-tabs': 'warn',
125+
'@stylistic/no-multi-spaces': ['warn', { ignoreEOLComments: true }],
126+
'@stylistic/no-tabs': 'warn',
127+
'@stylistic/no-trailing-spaces': 'warn',
128+
'@stylistic/no-whitespace-before-property': 'warn',
129+
'@stylistic/nonblock-statement-body-position': 'warn',
130+
'@stylistic/object-curly-newline': 'warn',
131+
'@stylistic/object-curly-spacing': ['warn', 'always'],
132+
'@stylistic/padding-line-between-statements': 'warn',
133+
'@stylistic/quotes': ['warn', 'single'],
134+
'@stylistic/rest-spread-spacing': 'warn',
135+
'@stylistic/semi': 'warn',
136+
'@stylistic/semi-spacing': 'warn',
137+
'@stylistic/semi-style': 'warn',
138+
'@stylistic/space-before-blocks': 'warn',
139+
'@stylistic/space-in-parens': 'warn',
140+
'@stylistic/space-infix-ops': 'warn',
141+
'@stylistic/space-unary-ops': 'warn',
142+
'@stylistic/switch-colon-spacing': 'warn',
143+
'@stylistic/template-curly-spacing': 'warn',
144+
'@stylistic/template-tag-spacing': 'warn',
145+
'@stylistic/wrap-iife': ['warn', 'any'],
146+
'@stylistic/yield-star-spacing': 'warn'
212147
}
213148
}
214149
);

rollup.config.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
import alias from '@rollup/plugin-alias';
12
import esbuild from 'rollup-plugin-esbuild';
23
import terser from '@rollup/plugin-terser';
34
import { dts } from 'rollup-plugin-dts';
45
import { globSync } from 'glob';
6+
import { dirname, resolve } from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
9+
const outputDir = (input: string) => input.replace(/^src/g, 'dist').replace(/\/[^/]*$/g, '');
10+
const replacePath = (input: string) => input.replace(/(^src\/|\.ts$)/g, '');
511

612
const ts = () => {
713
const plugins = [
14+
alias({ entries: [{ find: '@', replacement: resolve(dirname(fileURLToPath(import.meta.url)), 'src') }] }),
815
esbuild({ minify: false, target: 'es2021' }),
916
terser()
1017
];
@@ -20,17 +27,18 @@ const ts = () => {
2027
return [
2128
config('src/index.ts', 'dist'),
2229
config('src/plugin.ts', 'dist'),
23-
globSync('src/numerals/**/*.ts').map(input => config(input, 'dist/numerals')),
24-
globSync('src/locales/**/*.ts').map(input => config(input, 'dist/locales')),
25-
globSync('src/plugins/**/*.ts').map(input => config(input, 'dist/plugins')),
26-
config(Object.fromEntries(
27-
globSync('src/timezones/**/*.ts').map(input => [input.replace(/(^src\/|\.ts$)/g, ''), input])
28-
), 'dist')
30+
config(Object.fromEntries(globSync('src/numerals/**/*.ts').map(input => [replacePath(input), input])), 'dist'),
31+
globSync('src/locales/**/*.ts').map(input => config(input, outputDir(input))),
32+
globSync('src/plugins/**/*.ts').map(input => config(input, outputDir(input))),
33+
config(Object.fromEntries(globSync('src/timezones/**/*.ts').map(input => [replacePath(input), input])), 'dist')
2934
].flat();
3035
};
3136

3237
const types = () => {
33-
const plugins = [dts()];
38+
const plugins = [
39+
alias({ entries: [{ find: '@', replacement: resolve(dirname(fileURLToPath(import.meta.url)), 'src') }] }),
40+
dts()
41+
];
3442
const config = (input: string | Record<string, string>, outputDir: string) => ({
3543
input,
3644
output: { dir: outputDir },
@@ -40,12 +48,10 @@ const types = () => {
4048
return [
4149
config('src/index.ts', 'dist'),
4250
config('src/plugin.ts', 'dist'),
43-
globSync('src/plugins/**/*.ts').map(input => config(input, 'dist/plugins')),
44-
globSync('src/locales/**/*.ts').map(input => config(input, 'dist/locales')),
45-
globSync('src/numerals/**/*.ts').map(input => config(input, 'dist/numerals')),
46-
config(Object.fromEntries(
47-
globSync('src/timezones/**/*.ts').map(input => [input.replace(/(^src\/|\.ts$)/g, ''), input])
48-
), 'dist')
51+
config(Object.fromEntries(globSync('src/numerals/**/*.ts').map(input => [replacePath(input), input])), 'dist'),
52+
globSync('src/locales/**/*.ts').map(input => config(input, outputDir(input))),
53+
globSync('src/plugins/**/*.ts').map(input => config(input, outputDir(input))),
54+
config(Object.fromEntries(globSync('src/timezones/**/*.ts').map(input => [replacePath(input), input])), 'dist')
4955
].flat();
5056
};
5157

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"module": "ESNext", /* Specify what module code is generated. */
2929
// "rootDir": "./", /* Specify the root folder within your source files. */
3030
"moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */
31-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
31+
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32+
"paths": { "@/*": ["./src/*"] }, /* Specify a set of entries that re-map imports to additional lookup locations. */
3333
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
3434
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
3535
// "types": [], /* Specify type package names to be included without being referenced in a source file. */

vitest.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { defineConfig } from 'vitest/config';
2+
import { resolve } from 'path';
23

34
export default defineConfig({
45
esbuild: {
56
target: 'es2021',
67
sourcemap: true
78
},
9+
resolve: {
10+
alias: {
11+
'@': resolve(__dirname, './src')
12+
}
13+
},
814
test: {
915
coverage: {
1016
exclude: ['src/**/*.d.ts'],

0 commit comments

Comments
 (0)