mirror of
https://github.com/go-gitea/gitea.git
synced 2026-01-16 17:10:36 +00:00
Migrate to import.meta.env and clean up types and eslint (#36362)
`import.meta.env` is supported in both vitest and webpack [as of recent](https://github.com/webpack/webpack/pull/19996), so replace all previous use of `process.env` with it. Current usage is limited to test files, I've also verified it works in actual frontend code. `webpack/module` is added to typescript types which includes the definition for `import.meta.env`. I've also made the eslint globals more precise. Finally, `__webpack_public_path__` is removed from our type definitions because `webpack/module` also provides it.
This commit is contained in:
@@ -32,10 +32,6 @@ export default defineConfig([
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parser: typescriptParser,
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
@@ -363,7 +359,7 @@ export default defineConfig([
|
||||
'import-x/no-self-import': [2],
|
||||
'import-x/no-unassigned-import': [0],
|
||||
'import-x/no-unresolved': [2, {commonjs: true, ignore: ['\\?.+$']}],
|
||||
// 'import-x/no-unused-modules': [2, {unusedExports: true}], // not compatible with eslint 9
|
||||
'import-x/no-unused-modules': [0], // incompatible with eslint 9
|
||||
'import-x/no-useless-path-segments': [2, {commonjs: true}],
|
||||
'import-x/no-webpack-loader-syntax': [2],
|
||||
'import-x/order': [0],
|
||||
@@ -990,38 +986,19 @@ export default defineConfig([
|
||||
'vitest/valid-title': [2],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['web_src/js/types.ts'],
|
||||
rules: {
|
||||
'import-x/no-unused-modules': [0],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.d.ts'],
|
||||
rules: {
|
||||
'import-x/no-unused-modules': [0],
|
||||
'@typescript-eslint/consistent-type-definitions': [0],
|
||||
'@typescript-eslint/consistent-type-imports': [0],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.config.*'],
|
||||
rules: {
|
||||
'import-x/no-unused-modules': [0],
|
||||
},
|
||||
files: ['*', 'tools/**/*'],
|
||||
languageOptions: {globals: globals.node},
|
||||
},
|
||||
{
|
||||
files: ['web_src/**/*', 'docs/**/*'],
|
||||
languageOptions: {globals: globals.browser},
|
||||
},
|
||||
{
|
||||
files: ['web_src/**/*'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
__webpack_public_path__: true,
|
||||
process: false, // https://github.com/webpack/webpack/issues/15833
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user