Skip to content

Commit 1715cdd

Browse files
authored
Update typescript, typedoc, vuepress & eslint (#1258)
* Update packages without breaking changes * Upgrade vuepress, typedoc, karma and serve * Update typescript to version 4 * Update eslint * Fix eslint errors * Adjust jest config * Refactor ArithmeticHelper.inferExtendedNumberTypeAdditive * Replace vulnerable string-replace-webpack-plugin with string-replace-loader * Update css-loader
1 parent 104ce4c commit 1715cdd

34 files changed

+4731
-5177
lines changed

.config/webpack/languages.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
/**
22
* Config responsible for building not minified Handsontable `languages/` files.
33
*/
4-
const NEW_LINE_CHAR = '\n';
54
const SOURCE_LANGUAGES_DIRECTORY = 'lib/i18n/languages';
65
const OUTPUT_LANGUAGES_DIRECTORY = 'languages';
76

87
const path = require('path');
9-
const StringReplacePlugin = require('string-replace-webpack-plugin');
108
const WebpackOnBuildPlugin = require('on-build-webpack');
119
const fs = require('fs');
1210
const fsExtra = require('fs-extra');
@@ -34,31 +32,23 @@ function getEntryJsFiles() {
3432

3533
const ruleForSnippetsInjection = {
3634
test: /\.js$/,
37-
loader: StringReplacePlugin.replace({
38-
replacements: [
39-
{
40-
pattern: /\/\/.import/,
41-
replacement: function() {
42-
const snippet1 = `import HyperFormula from '../..';`;
43-
44-
return `${snippet1}${NEW_LINE_CHAR.repeat(2)}`;
35+
loader: 'string-replace-loader',
36+
options: {
37+
multiple: [
38+
{ search: 'export default dictionary', replace: `
39+
if (!HyperFormula.languages) {
40+
HyperFormula.languages = {};
4541
}
46-
},
47-
{
48-
pattern: /export default dictionary/,
49-
replacement: function(matchingPhrase) {
50-
const snippet = `
51-
if (!HyperFormula.languages) {
52-
HyperFormula.languages = {};
53-
}
54-
HyperFormula.languages[dictionary.langCode] = dictionary;
55-
`;
56-
57-
return `${snippet}${NEW_LINE_CHAR.repeat(2)}${matchingPhrase}`;
58-
}
59-
}
42+
HyperFormula.languages[dictionary.langCode] = dictionary;
43+
44+
export default dictionary
45+
`},
46+
{ search: /\/\/.import/, replace: `
47+
import HyperFormula from '../..';
48+
49+
`}
6050
]
61-
})
51+
}
6252
};
6353

6454
module.exports.create = function create() {

.eslintrc.js

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
root: true,
3+
ignorePatterns: ['.eslintrc.js'],
34
parser: '@typescript-eslint/parser',
45
plugins: [
56
'@typescript-eslint',
@@ -27,17 +28,21 @@ module.exports = {
2728
delimiter: 'comma',
2829
},
2930
}],
30-
'@typescript-eslint/camelcase': 'error',
31+
'@typescript-eslint/naming-convention': [
32+
'error',
33+
{ 'selector': 'variableLike', 'format': ['camelCase', 'UPPER_CASE', 'PascalCase'], 'leadingUnderscore': 'allow' },
34+
{ 'selector': 'interface', 'format': ['PascalCase'], 'custom': { 'regex': '^I[A-Z]', 'match': false } },
35+
],
3136
'@typescript-eslint/semi': ['error', 'never'],
32-
'@typescript-eslint/brace-style': 'error', // wtf
37+
'@typescript-eslint/brace-style': 'error',
3338
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
3439
'@typescript-eslint/no-extra-non-null-assertion': ['error'],
3540
'@typescript-eslint/no-throw-literal': ['error'],
3641
'@typescript-eslint/array-type': ['error'],
37-
'@typescript-eslint/space-before-function-paren': ["error", {
38-
"anonymous": "never",
39-
"named": "never",
40-
"asyncArrow": "always"
42+
'@typescript-eslint/space-before-function-paren': ['error', {
43+
'anonymous': 'never',
44+
'named': 'never',
45+
'asyncArrow': 'always'
4146
}],
4247
'@typescript-eslint/quotes': ['error', 'single', { avoidEscape: true }],
4348
'@typescript-eslint/no-extra-semi': ['error'],
@@ -64,35 +69,41 @@ module.exports = {
6469
'no-useless-escape': 'off',
6570
'no-inner-declarations': 'off',
6671

72+
// Overrides
6773
'@typescript-eslint/no-non-null-assertion': 'warn',
6874
'@typescript-eslint/prefer-regexp-exec': 'warn',
6975
'@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }],
7076
'@typescript-eslint/no-explicit-any': 'warn',
71-
'@typescript-eslint/interface-name-prefix': 'warn',
77+
'@typescript-eslint/no-unsafe-argument': 'warn',
78+
'@typescript-eslint/no-unsafe-return': 'warn',
79+
'@typescript-eslint/no-unsafe-member-access': 'warn',
80+
'@typescript-eslint/no-unsafe-assignment': 'warn',
81+
'@typescript-eslint/restrict-template-expressions': 'warn',
82+
'@typescript-eslint/no-unsafe-call': 'warn',
7283

73-
"jsdoc/check-access": 'warn',
74-
"jsdoc/check-alignment": 'warn',
75-
"jsdoc/check-param-names": 'warn',
76-
"jsdoc/check-property-names": 'warn',
77-
"jsdoc/check-tag-names": ['warn', {definedTags: ['category']}],
78-
"jsdoc/check-types": 'warn',
79-
"jsdoc/empty-tags": 'warn',
80-
"jsdoc/implements-on-classes": 'warn',
81-
"jsdoc/multiline-blocks": 'warn',
82-
"jsdoc/newline-after-description": 'warn',
83-
"jsdoc/no-multi-asterisks": 'warn',
84-
"jsdoc/require-param-description": 'warn',
85-
"jsdoc/require-param-name": 'warn',
86-
"jsdoc/require-param-type": 'warn',
87-
"jsdoc/require-property-description": 'warn',
88-
"jsdoc/require-property-name": 'warn',
89-
"jsdoc/require-property-type": 'warn',
90-
"jsdoc/require-returns-check": 'warn',
91-
"jsdoc/require-returns-description": 'warn',
92-
"jsdoc/require-returns-type": 'warn',
93-
"jsdoc/require-yields-check": 'warn',
94-
"jsdoc/valid-types": 'warn',
95-
"jsdoc/require-jsdoc": ['warn', {
84+
'jsdoc/check-access': 'warn',
85+
'jsdoc/check-alignment': 'warn',
86+
'jsdoc/check-param-names': 'warn',
87+
'jsdoc/check-property-names': 'warn',
88+
'jsdoc/check-tag-names': ['warn', { definedTags: ['category'] }],
89+
'jsdoc/check-types': 'warn',
90+
'jsdoc/empty-tags': 'warn',
91+
'jsdoc/implements-on-classes': 'warn',
92+
'jsdoc/multiline-blocks': 'warn',
93+
'jsdoc/tag-lines': 'warn',
94+
'jsdoc/no-multi-asterisks': 'warn',
95+
'jsdoc/require-param-description': 'warn',
96+
'jsdoc/require-param-name': 'warn',
97+
'jsdoc/require-param-type': 'warn',
98+
'jsdoc/require-property-description': 'warn',
99+
'jsdoc/require-property-name': 'warn',
100+
'jsdoc/require-property-type': 'warn',
101+
'jsdoc/require-returns-check': 'warn',
102+
'jsdoc/require-returns-description': 'warn',
103+
'jsdoc/require-returns-type': 'warn',
104+
'jsdoc/require-yields-check': 'warn',
105+
'jsdoc/valid-types': 'warn',
106+
'jsdoc/require-jsdoc': ['warn', {
96107
require: {
97108
ArrowFunctionExpression: true,
98109
ClassDeclaration: true,
@@ -117,4 +128,4 @@ module.exports = {
117128
}
118129
},
119130
],
120-
};
131+
}

0 commit comments

Comments
 (0)