mirror of
https://github.com/zombieFox/nightTab.git
synced 2024-11-25 01:23:15 +01:00
update packages
This commit is contained in:
parent
35d5de3014
commit
4af8cd3c12
51
.eslintrc.js
51
.eslintrc.js
@ -1,51 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
module.exports = {
|
|
||||||
'env': {
|
|
||||||
'browser': true,
|
|
||||||
'es2021': true,
|
|
||||||
"webextensions": true
|
|
||||||
},
|
|
||||||
'extends': 'eslint:recommended',
|
|
||||||
'ignorePatterns': ['webpack.*', 'dist/', 'babel.*'],
|
|
||||||
'parserOptions': {
|
|
||||||
'ecmaVersion': 12,
|
|
||||||
'sourceType': 'module'
|
|
||||||
},
|
|
||||||
'plugins': ['unused-imports', 'jest'],
|
|
||||||
'rules': {
|
|
||||||
'indent': ['error', 2, { 'SwitchCase': 1 }],
|
|
||||||
'linebreak-style': [
|
|
||||||
'error',
|
|
||||||
'unix'
|
|
||||||
],
|
|
||||||
'quotes': [
|
|
||||||
'error',
|
|
||||||
'single'
|
|
||||||
],
|
|
||||||
'semi': [
|
|
||||||
'error',
|
|
||||||
'always'
|
|
||||||
],
|
|
||||||
'no-unused-vars': 'off',
|
|
||||||
'unused-imports/no-unused-imports': ['error'],
|
|
||||||
'unused-imports/no-unused-vars': [
|
|
||||||
'warn',
|
|
||||||
{ 'vars': 'all', 'varsIgnorePattern': '^_', 'args': 'after-used', 'argsIgnorePattern': '^_' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
// This lints typescript files differently than js files.
|
|
||||||
'overrides': [{
|
|
||||||
'files': ["**/*.ts"],
|
|
||||||
'extends': [
|
|
||||||
'eslint:recommended', "plugin:@typescript-eslint/recommended"
|
|
||||||
],
|
|
||||||
'parser': '@typescript-eslint/parser',
|
|
||||||
'plugins': ['@typescript-eslint', 'unused-imports', 'jest'],
|
|
||||||
'rules': {
|
|
||||||
'@typescript-eslint/ban-ts-comment': 'off',
|
|
||||||
'@typescript-eslint/no-unused-vars': 'off',
|
|
||||||
// Good in theory, but seems to disables implict function return types
|
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
||||||
},
|
|
||||||
}]
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
npm run lint
|
|
@ -1,6 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
['@babel/preset-env', { targets: { node: 'current' } }],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
};
|
|
7
eslint.config.js
Normal file
7
eslint.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = [{
|
||||||
|
files: ["src/**/*.js"],
|
||||||
|
rules: {
|
||||||
|
"no-duplicate-imports": "error",
|
||||||
|
"prefer-const": "error"
|
||||||
|
}
|
||||||
|
}];
|
20280
package-lock.json
generated
20280
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@ -6,9 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack serve --open --config webpack.dev.js",
|
"start": "webpack serve --open --config webpack.dev.js",
|
||||||
"build": "webpack --config webpack.prod.js",
|
"build": "webpack --config webpack.prod.js",
|
||||||
"lint": "eslint --fix --ext .js,.ts,.test.ts .",
|
"lint": "eslint"
|
||||||
"prepare": "husky install",
|
|
||||||
"test": "jest tests/*"
|
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"startpage",
|
"startpage",
|
||||||
@ -29,32 +27,21 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/zombieFox/nightTab#readme",
|
"homepage": "https://github.com/zombieFox/nightTab#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-env": "^7.16.11",
|
"copy-webpack-plugin": "^12.0.2",
|
||||||
"@babel/preset-typescript": "^7.16.7",
|
"css-loader": "^7.1.2",
|
||||||
"@types/jest": "^27.4.0",
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
"eslint": "^9.5.0",
|
||||||
"@typescript-eslint/parser": "^5.10.0",
|
"html-webpack-plugin": "^5.6.0",
|
||||||
"copy-webpack-plugin": "^10.2.1",
|
"mini-css-extract-plugin": "^2.9.0",
|
||||||
"css-loader": "^6.5.1",
|
"moment": "^2.30.1",
|
||||||
"css-minimizer-webpack-plugin": "^3.4.1",
|
"sortablejs": "^1.15.2",
|
||||||
"eslint": "^8.7.0",
|
"style-loader": "^4.0.0",
|
||||||
"eslint-plugin-jest": "^25.7.0",
|
"terser-webpack-plugin": "^5.3.10",
|
||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
|
||||||
"html-webpack-plugin": "^5.5.0",
|
|
||||||
"husky": "^7.0.4",
|
|
||||||
"jest": "^27.4.7",
|
|
||||||
"mini-css-extract-plugin": "^2.5.2",
|
|
||||||
"moment": "^2.29.1",
|
|
||||||
"sortablejs": "^1.14.0",
|
|
||||||
"style-loader": "^3.3.1",
|
|
||||||
"terser-webpack-plugin": "^5.3.0",
|
|
||||||
"ts-loader": "^9.2.6",
|
|
||||||
"typescript": "^4.5.5",
|
|
||||||
"webfontloader": "^1.6.28",
|
"webfontloader": "^1.6.28",
|
||||||
"webpack": "^5.66.0",
|
"webpack": "^5.92.1",
|
||||||
"webpack-cli": "^4.9.1",
|
"webpack-cli": "^5.1.4",
|
||||||
"webpack-dev-server": "^4.7.3",
|
"webpack-dev-server": "^5.0.4",
|
||||||
"webpack-merge": "^5.8.0",
|
"webpack-merge": "^5.10.0",
|
||||||
"zip-webpack-plugin": "^4.0.1"
|
"zip-webpack-plugin": "^4.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
// This file is strictly for utility functions used to bootstrap tests
|
|
@ -1,30 +0,0 @@
|
|||||||
# NightTab Testing Principles
|
|
||||||
|
|
||||||
Testing in NightTab consists primarily of unit tests covering functions that manipulate data in some way. Incorrect data transformations/corruption are the most likely thing to break nighttab and thus our focus is on that.
|
|
||||||
|
|
||||||
UI testing can get very tedious and so with nighttab we're manually testing visual aspects. Though we're open to discussing adding some regression testing.
|
|
||||||
|
|
||||||
All testing must meet the following criteria:
|
|
||||||
- **Tests Should Be Fast**
|
|
||||||
- **Tests Should Be Deterministic**
|
|
||||||
- **Tests Should Be Simple**
|
|
||||||
- Test Shouldn’t Duplicate Implementation Logic
|
|
||||||
- Tests Should Be Readable
|
|
||||||
- Tests should be integrated into the development and CI process
|
|
||||||
- Tests should never be coupled with implementation details
|
|
||||||
- Mocks should be avoided, when possible.
|
|
||||||
|
|
||||||
## Typescript
|
|
||||||
We're using typescript for testing for two reasons:
|
|
||||||
1. Benefit of types inside tests
|
|
||||||
2. New Data Layer will be written in typescript for more robustness.
|
|
||||||
|
|
||||||
Linting for typescript is done via file overrides in the `.eslintrc.js` file, meaning js files are linted using their own configuration and then typescript files are linted with a few extra settings on top of those for js.
|
|
||||||
|
|
||||||
## Status of Testing
|
|
||||||
Nighttab started without any automated testing. As the app grows in popularity with over 100k+ users and multiple contributors working on it, we've decided its time to integrate testing. We're slowly adding testing to make the app more robust and easier to improve and refactor.
|
|
||||||
|
|
||||||
## File Structure
|
|
||||||
Tests file should have the `*.test.ts` extension and be placed under `/test/<path>` where path is a direct mirror of its location in `/src/<path>`.
|
|
||||||
|
|
||||||
The file `/test/index.ts` is not a test file and is instead meant to be used to keep utility functions used across tests.
|
|
@ -1,49 +0,0 @@
|
|||||||
//@ts-nocheck get has no types, for now
|
|
||||||
import { get } from '../../src/utility/get';
|
|
||||||
|
|
||||||
let object;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
object = { theme: { accent: { rgb: { r: 'hello there' } } } };
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For some reason get mutates the object its trying to access,
|
|
||||||
* might be a good idea to remove this "feature".
|
|
||||||
*/
|
|
||||||
describe('get.js', () => {
|
|
||||||
test('should get receive both props', () => {
|
|
||||||
const path = 'theme.accent.rgb.r';
|
|
||||||
const result = 'hello there';
|
|
||||||
|
|
||||||
expect(get({ object, path })).toBe(result);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an incorrect path', () => {
|
|
||||||
const path = 'theme.accent.rgb.d';
|
|
||||||
|
|
||||||
expect(get({ object, path })).toBe('');
|
|
||||||
expect(object.theme.accent.rgb.d).toStrictEqual(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an incorrect intermediate path', () => {
|
|
||||||
const path = 'theme.accent.wrong.r';
|
|
||||||
|
|
||||||
expect(get({ object, path })).toBe('');
|
|
||||||
expect(object.theme.accent.wrong).toStrictEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an incorrect intermediate path as a number', () => {
|
|
||||||
const path = 'theme.accent.1.r';
|
|
||||||
|
|
||||||
expect(get({ object, path })).toBe('');
|
|
||||||
expect(object.theme.accent[1]).toStrictEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an null prop', () => {
|
|
||||||
const path = 'theme.accent.rgb.r';
|
|
||||||
|
|
||||||
expect(get({ object, path: null })).toBe(false);
|
|
||||||
expect(get({ object: null, path })).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,7 +0,0 @@
|
|||||||
import { makePath } from '../../src/utility/makePath';
|
|
||||||
|
|
||||||
test('makePath correctly parses the dot notation', () => {
|
|
||||||
const input = 'theme.accent.rgb.r';
|
|
||||||
const result = ['theme', 'accent', 'rgb', 'r'];
|
|
||||||
expect(makePath(input)).toStrictEqual(result);
|
|
||||||
});
|
|
@ -1,50 +0,0 @@
|
|||||||
//@ts-nocheck
|
|
||||||
import { set } from '../../src/utility/set';
|
|
||||||
|
|
||||||
let object;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
object = { theme: { accent: { rgb: { r: 'Hello there!' } } } };
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It seems, unlike get, set doesn't mutate objects when it doesn't find keys
|
|
||||||
*/
|
|
||||||
describe('set.js', () => {
|
|
||||||
test('should set update an object as expected', () => {
|
|
||||||
const path = 'theme.accent.rgb.r';
|
|
||||||
const result = 'General Kenobi!';
|
|
||||||
|
|
||||||
set({ object, path, value: 'General Kenobi!' });
|
|
||||||
expect(object.theme.accent.rgb.r).toBe(result);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an incorrect path', () => {
|
|
||||||
const path = 'theme.accent.rgb.d';
|
|
||||||
|
|
||||||
expect(set({ object, path })).toBe(false);
|
|
||||||
expect(object.theme.accent.rgb.d).toBe(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an incorrect intermediate path', () => {
|
|
||||||
const path = 'theme.accent.wrong.r';
|
|
||||||
|
|
||||||
expect(set({ object, path })).toBe(false);
|
|
||||||
expect(object.theme.accent.wrong).toStrictEqual(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an incorrect path including a number', () => {
|
|
||||||
const path = 'theme.accent.1.r';
|
|
||||||
|
|
||||||
expect(set({ object, path })).toBe(false);
|
|
||||||
expect(object.theme.accent[1]).toBe(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should get receive an null prop', () => {
|
|
||||||
const path = 'theme.accent.rgb.r';
|
|
||||||
|
|
||||||
expect(set({ object, path: null })).toBe(false);
|
|
||||||
expect(set({ object: null, path })).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
||||||
"target": "es5",
|
|
||||||
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
||||||
"lib": [
|
|
||||||
"DOM"
|
|
||||||
],
|
|
||||||
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
|
|
||||||
"allowJs": true,
|
|
||||||
/* Allow 'import x from y' when a module doesn't have a default export. */
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
/* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
|
|
||||||
"esModuleInterop": true,
|
|
||||||
/* Ensure that casing is correct in imports. */
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
/* Enable importing .json files */
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
/* Skip type checking all .d.ts files. */
|
|
||||||
"skipLibCheck": true,
|
|
||||||
/* Enable all strict type-checking options. */
|
|
||||||
"strict": true,
|
|
||||||
/* Specify an output folder for all emitted files. */
|
|
||||||
"outDir": "./dist/",
|
|
||||||
/* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
||||||
"noImplicitAny": true,
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user