Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ jobs:
- run: npm run build
- run: npm test
- run: npm run lint
- run: npm run typecheck
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ See https://community.openproject.org/work_packages/47084 for context.
Now the webpack development mode is building the files and outputting them to `frontend/src/vendor/ckeditor/*` in the
core repository, overriding anything in there.

### Type checking

The source is being converted to TypeScript. Files ending in `.ts` are checked in strict mode; files still ending in
`.js` are not checked. Webpack and jest strip types without checking them, so run the checker separately:

```
npm run typecheck
```

## Migration Notes

### jQuery Removal
Expand Down
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ module.exports = {
},
},
],
[
"@babel/preset-typescript",
{
// Match tsc: keep imports unless written as `import type`,
// and let `declare` fields emit nothing.
onlyRemoveTypeImports: true,
allowDeclareFields: true,
},
],
],
plugins: ["@babel/plugin-transform-modules-commonjs"]
}
61 changes: 61 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
import globals from "globals";
import eslint from '@eslint/js';
import jestPlugin from 'eslint-plugin-jest';
import tseslint from 'typescript-eslint';

const tsFiles = ["src/**/*.ts", "tests/**/*.ts"];

const tsRules = {
// TypeScript reports undefined names itself.
"no-undef": "off",
"no-cond-assign": "off",
// TODO(OP-18993): re-enable once the conversion has merged. It changes
// types only, and these would demand edits to runtime code that the
// JavaScript rules never asked for.
"prefer-const": "off",
"no-var": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-expressions": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": true,
"minimumDescriptionLength": 10
}
]
};

export default [
eslint.configs.recommended,
Expand Down Expand Up @@ -75,4 +112,28 @@ export default [
"no-undef": "error"
}
},
...tseslint.configs.recommended.map(config => ({ ...config, files: tsFiles })),
{
files: ["src/**/*.ts"],
languageOptions: {
globals: {
...globals.browser
}
},
rules: tsRules
},
{
files: ["tests/**/*.ts"],
plugins: {
jest: jestPlugin
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest
}
},
rules: tsRules
},
];
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
],
// A map from regular expressions to paths to transformers
transform: {
'^.+\\.js$': 'babel-jest',
'^.+\\.(js|ts)$': 'babel-jest',
},
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
Expand Down
Loading
Loading