Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INTERNAL] Migrate project to TypeScript #588

Draft
wants to merge 69 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c10d92f
refactor: Modify deps & configurations
d3xter666 Aug 23, 2024
0958a31
refactor: Rename lib/ to src/
d3xter666 Aug 23, 2024
6b3b182
refactor: Do files rename to *.ts extensions
d3xter666 Aug 23, 2024
ff190d9
fix: Auto fix some of the ESLint issues
d3xter666 Aug 23, 2024
9d840f1
refactor: Ignore generated code
d3xter666 Aug 23, 2024
53dbae3
refactor: Migrate Resource.ts
d3xter666 Aug 23, 2024
a79e795
fix: ESLint
d3xter666 Aug 23, 2024
70cd760
fix: Add dep types
d3xter666 Aug 23, 2024
2271848
refactor: Migrate traceSummary.ts
d3xter666 Aug 23, 2024
0be01b7
refactor: Migrate Trace.ts
d3xter666 Aug 23, 2024
6b71d00
refactor: Migrate AbstractReader
d3xter666 Aug 23, 2024
47da2fc
refactor: Migrate AbstractReaderWriter
d3xter666 Aug 23, 2024
b2bde05
refactor: Migrate the AbstractAdaptor
d3xter666 Aug 26, 2024
509fbd5
refactor: Migrate FileSystem.js
d3xter666 Aug 26, 2024
2c63c10
refactor: Resource
d3xter666 Aug 26, 2024
c00f930
fix: Provide graceful-fs definitions
d3xter666 Aug 26, 2024
412af82
refactor: Migrate Memory.ts
d3xter666 Aug 26, 2024
92f2f5c
refactor: Migrate collections
d3xter666 Aug 26, 2024
5bb2a97
fix: Some cleanups
d3xter666 Aug 26, 2024
6320c4c
refactor: Migrate fsInterface
d3xter666 Aug 27, 2024
37600e0
refactor: Migrate ReaderCollection
d3xter666 Aug 27, 2024
e6a86db
refactor: Migrate ResourceFacade
d3xter666 Aug 27, 2024
c8630a7
refactor: Migrate resourceFactory
d3xter666 Aug 27, 2024
67c6328
refactor: Migrate ResourceTagCollection
d3xter666 Aug 27, 2024
00ab25f
refactor(Filter.ts): Add datatypes to arguments/properties
maxreichmann Aug 27, 2024
fb7dfab
refactor: WriterCollection
d3xter666 Aug 27, 2024
e507ae4
fix: resourceFactory filter params type
d3xter666 Aug 27, 2024
882dfcd
fix: Tests
d3xter666 Aug 27, 2024
7796366
refactor: Clear build files
d3xter666 Aug 27, 2024
81511a8
refactor: Migrate tests' module references
d3xter666 Aug 27, 2024
261711a
refactor: Align configurations
d3xter666 Aug 27, 2024
ea72bf5
refactor: Add ResourceInterface
maxreichmann Aug 27, 2024
3e9384b
refactor: Fix ESLint error
maxreichmann Aug 27, 2024
e53118e
fix: Tests
d3xter666 Aug 27, 2024
9e808f1
refactor: Resource
d3xter666 Aug 27, 2024
0949eb2
refactor: Correct export modules from package.json
d3xter666 Aug 27, 2024
ca23972
fix: Tests
d3xter666 Aug 27, 2024
ccc80f5
fix: Update .gitignore
d3xter666 Aug 27, 2024
6f7706a
fix: Make tests work
d3xter666 Aug 27, 2024
825976d
refactor(.nycrc.json): Fix indent
RandomByte Aug 27, 2024
2b34270
refactor: Fix some ESLint errors
maxreichmann Aug 28, 2024
1f7ee9b
[INTERNAL] TypeScript: Add test/expected to eslint ignore list
RandomByte Aug 28, 2024
28fb265
refactor: Autofix JSDoc findings
d3xter666 Aug 28, 2024
3b0a90b
fix: Autofix eslint findings
d3xter666 Aug 28, 2024
7b0f96e
fix: Broken interface
d3xter666 Aug 28, 2024
55f21c9
fix: Add JSDoc descriptions
d3xter666 Aug 28, 2024
d2407c8
fix: Add JSDoc descriptions
d3xter666 Aug 28, 2024
d1fac86
fix: Add JSDoc descriptions
d3xter666 Aug 28, 2024
49fd1d1
refactor: Migrate Resource to ResourceInterface
d3xter666 Aug 28, 2024
a14b351
refactor: AbstractAdapter test
d3xter666 Aug 28, 2024
b2ad4be
refactor: Migrate ResourceTagCollection tests
d3xter666 Aug 28, 2024
1c9a881
refactor: ResourceFacade tests
d3xter666 Aug 28, 2024
f3b667d
refactor: Migrate Resource test
d3xter666 Aug 28, 2024
beb96ff
refactor: AbstractReaderWriter tests
d3xter666 Aug 28, 2024
fcb0b31
refactor: Remove module aliases
d3xter666 Aug 28, 2024
24604dd
fix: Tests
d3xter666 Aug 28, 2024
c1ec81d
fix: JSDoc generation script
d3xter666 Aug 28, 2024
5276119
fix: tsc build issues
d3xter666 Aug 28, 2024
494d711
[INTERNAL] TypeScript: Emit types
RandomByte Aug 28, 2024
f9431e4
refactor: Switch jsdoc generation to typedoc
d3xter666 Aug 28, 2024
d21d2ec
fix: Resolve merge conflicts
d3xter666 Aug 28, 2024
4ee03fa
[INTERNAL] TypeScript/ESLint: Allow missing jsdoc, require consistend…
RandomByte Aug 28, 2024
a3963f3
refactor: Fix ESLint errors in /test/lib/
maxreichmann Aug 29, 2024
c5a02c0
refactor: Update package-lock.json
maxreichmann Aug 29, 2024
3edf12c
fix: TS build issues
d3xter666 Aug 29, 2024
00d11d4
fix: ESLint findings
d3xter666 Aug 29, 2024
aedd08f
fix: Match return types
d3xter666 Aug 29, 2024
42cdf09
refactor: Lower thresholds for coverage
d3xter666 Aug 29, 2024
3da822d
fix: Remove redundant dependencies & fix depcheck
d3xter666 Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ build/Release
node_modules
jspm_packages

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

Expand All @@ -60,3 +63,7 @@ deploy_key
# Custom directories
test/tmp/
jsdocs/

# Generated code
lib/
!test/lib/
30 changes: 30 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"reporter": ["lcov", "text", "text-summary"],
"include": ["src/**"],
"check-coverage": true,
"statements": 90,
"branches": 85,
"functions": 90,
"lines": 90,
"watermarks": {
"statements": [
70,
90
],
"branches": [
70,
90
],
"functions": [
70,
90
],
"lines": [
70,
90
]
},
"cache": true,
"all": true
}
21 changes: 21 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Calculate nodeArguments based on the Node version
const nodeArguments = [
"--import=tsx/esm",
"--no-warnings=ExperimentalWarning",
];

export default {
extensions: {
ts: "module",
},
files: [
"test/lib/**/*.ts",
],
watchMode: {
ignoreChanges: [
"test/tmp/**",
],
},
nodeArguments,
workerThreads: false,
};
230 changes: 139 additions & 91 deletions eslint.common.config.js
Original file line number Diff line number Diff line change
@@ -1,99 +1,147 @@
import jsdoc from "eslint-plugin-jsdoc";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import stylistic from "@stylistic/eslint-plugin";
import ava from "eslint-plugin-ava";
import globals from "globals";
import js from "@eslint/js";
import google from "eslint-config-google";

export default [{
ignores: [ // Common ignore patterns across all tooling repos
"**/coverage/",
"test/tmp/",
"test/expected/",
"test/fixtures/",
"**/docs/",
"**/jsdocs/",
],
}, js.configs.recommended, google, ava.configs["flat/recommended"], {
name: "Common ESLint config used for all tooling repos",
import jsdoc from "eslint-plugin-jsdoc";

plugins: {
jsdoc,
},
export default tseslint.config(
{
// This block defines ignore patterns globally to all configurations below
// (therefore it can use slightly different patterns, see also the eslint "Flat Config" doc)
ignores: [
".github/*",
".reuse/*",
"coverage/*",
"**/docs/",
"**/jsdocs/",

languageOptions: {
globals: {
...globals.node,
},
// Exclude test files
"test/tmp/*",
"test/fixtures/*",
"test/expected/*",

ecmaVersion: 2023,
sourceType: "module",
// Exclude generated code
"lib/*",
],
},

settings: {
jsdoc: {
mode: "jsdoc",

tagNamePreference: {
return: "returns",
augments: "extends",
// Base configs applying to JS and TS files
eslint.configs.recommended,
stylistic.configs.customize({
indent: "tab",
quotes: "double",
semi: true,
jsx: false,
arrowParens: true,
braceStyle: "1tbs",
blockSpacing: false,
}),
ava.configs["flat/recommended"], {
// Lint all JS files using the eslint parser
files: ["**/*.js"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
},
}, {
// Lint all TS files using the typescript-eslint parser
// Also enable all recommended typescript-eslint rules
files: ["src/**/*.ts", "test/**/*.ts", "scripts/**/*.ts"],
extends: [
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
},

rules: {
"indent": ["error", "tab"],
"linebreak-style": ["error", "unix"],

"quotes": ["error", "double", {
allowTemplateLiterals: true,
}],

"semi": ["error", "always"],
"no-negated-condition": "off",
"require-jsdoc": "off",
"no-mixed-requires": "off",

"max-len": ["error", {
code: 120,
ignoreUrls: true,
ignoreRegExpLiterals: true,
}],

"no-implicit-coercion": [2, {
allow: ["!!"],
}],

"comma-dangle": "off",
"no-tabs": "off",
"no-console": 2, // Disallow console.log()
"no-eval": 2,
// The following rule must be disabled as of ESLint 9.
// It's removed and causes issues when present
// https://eslint.org/docs/latest/rules/valid-jsdoc
"valid-jsdoc": 0,
"jsdoc/check-examples": 0,
"jsdoc/check-param-names": 2,
"jsdoc/check-tag-names": 2,
"jsdoc/check-types": 2,
"jsdoc/no-undefined-types": 0,
"jsdoc/require-description": 0,
"jsdoc/require-description-complete-sentence": 0,
"jsdoc/require-example": 0,
"jsdoc/require-hyphen-before-param-description": 0,
"jsdoc/require-param": 2,
"jsdoc/require-param-description": 0,
"jsdoc/require-param-name": 2,
"jsdoc/require-param-type": 2,
"jsdoc/require-returns": 0,
"jsdoc/require-returns-description": 0,
"jsdoc/require-returns-type": 2,

"jsdoc/tag-lines": [2, "any", {
startLines: 1,
}],
rules: {
// TypeScript specific overwrites
// We must disable the base rule as it can report incorrect errors
"no-unused-vars": "off",
"@typescript-eslint/consistent-type-imports": ["error", {
fixStyle: "inline-type-imports",
}],
"@typescript-eslint/consistent-type-exports": ["error", {
fixMixedExportsWithInlineTypeSpecifier: true,
}],
"@typescript-eslint/no-unused-vars": [
"error", {
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
},
}, {
// To be discussed: Type-aware checks might add quite some additional work when writing tests
// and could even require us to export types that we would otherwise not export
files: ["test/**/*.ts"],
rules: {
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-unary-minus": "off",
},
}, {
// Overwrite any rules from the configurations above for both, JS and TS files
rules: {
"linebreak-style": [
"error",
"unix",
],
"@stylistic/object-curly-spacing": [
"error",
"never",
],
"@stylistic/operator-linebreak": ["error", "after"],
"@stylistic/comma-dangle": ["error", {
functions: "never",
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
enums: "always-multiline",
generics: "always-multiline",
tuples: "always-multiline",
}],
"max-len": [
"error",
{
code: 120,
ignoreUrls: true,
ignoreRegExpLiterals: true,
},
],
"no-implicit-coercion": [
"error",
{allow: ["!!"]},
],
"no-console": "error",
"no-eval": "error",

"jsdoc/valid-types": 0,
"ava/assertion-arguments": 0,
},
}
];
"valid-jsdoc": "off",
},
}, {
// JSdoc only applying to sources
files: ["src/**/*.ts"],
...jsdoc.configs["flat/recommended-typescript-error"],
}, {
// Overwriting JSDoc rules in a separate config with the same files pattern
files: ["src/**/*.ts"],
rules: {
"jsdoc/require-jsdoc": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/tag-lines": ["error", "any", {
startLines: 1,
}],
},
}
);
4 changes: 4 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import eslintCommonConfig from "./eslint.common.config.js";

export default [
...eslintCommonConfig, // Load common ESLint config
{
// Add project-specific ESLint config rules here
// in order to override common config
},
];
4 changes: 2 additions & 2 deletions jsdoc-plugin.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* JSDoc doesn't see "{@" as a valid type expression, probably as there's also {@link ...}.
*/
exports.handlers = {
jsdocCommentFound: function(e) {
jsdocCommentFound: function (e) {
e.comment = e.comment.replace(/{@ui5\//g, "{ @ui5/");
}
},
};
Loading