Skip to content

Commit

Permalink
Modernizing codebase by refactoring indexOf methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Havunen committed Oct 30, 2023
1 parent 5184994 commit b8396c6
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 88 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Inferno v9 requires following features to be present in the executing runtime:

- `Promise`
- `String.prototype.includes()`
- `String.prototype.startsWith()`
- `Array.prototype.includes()`
- `Object.spread()`

Expand Down
134 changes: 67 additions & 67 deletions fixtures/browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fixtures/packaging/build-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function addResult(tool, environment, result) {
}

function buildFixture(tool, environment) {
const isWindows = os.type().indexOf('Windows') !== -1;
const isWindows = os.type().includes('Windows');
// Let console know what's going on
console.log(`Running ${tool}:${environment}`);

Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"test:memory": "node --expose-gc scripts/fakedom/uibench-reactlike/start.js",
"test:memory:js-framework": "node --expose-gc scripts/fakedom/js-framework-bench/start.js",
"test:memory:lifecycle": "node --expose-gc scripts/fakedom/uibench-lifecycle/start.js",
"test:memory:lifecycle:debug": "node --inspect-brk --expose-gc scripts/fakedom/uibench-lifecycle/start.js",
"test:memory:js-framework:debug": "node --inspect-brk --expose-gc scripts/fakedom/js-framework-bench/start.js"
},
"devDependencies": {
Expand All @@ -90,14 +91,14 @@
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.4",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@swc/core": "^1.3.94",
"@swc/core": "^1.3.95",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.6",
"@types/jsdom": "^21.1.4",
"@types/node": "^20.8.7",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@types/node": "^20.8.9",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"babel-plugin-inferno": "6.7.0",
"cli-table": "^0.3.11",
"concat-stream-es6": "0.0.1",
Expand All @@ -107,7 +108,7 @@
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.1.1",
Expand All @@ -129,7 +130,7 @@
"pre-commit": "^1.2.2",
"prettier": "^3.0.3",
"rimraf": "^5",
"rollup": "^4.1.4",
"rollup": "^4.1.5",
"swc": "^1.0.11",
"swc-loader": "^0.2.3",
"swc-plugin-inferno": "^0.0.10",
Expand Down
12 changes: 6 additions & 6 deletions packages/inferno-router/src/StaticRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ function stripBasename(
const base = addLeadingSlash(basename);
if (location.pathname.indexOf(base) !== 0) {
if (location.pathname.startsWith(base)) {
return {
...location,
pathname: location.pathname.substring(base.length),
};
} else {
return location;
}
return {
...location,
pathname: location.pathname.substring(base.length),
};
}
function createLocation(location): Path {
Expand Down
1 change: 1 addition & 0 deletions packages/inferno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Inferno v9 requires following features to be present in the executing runtime:

- `Promise`
- `String.prototype.includes()`
- `String.prototype.startsWith()`
- `Array.prototype.includes()`
- `Object.spread()`

Expand Down
6 changes: 3 additions & 3 deletions packages/inferno/__tests__/componentlifecycle.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ describe('legacy life cycle', () => {
expect(consoleErrorStub).toHaveBeenCalledTimes(1);

const message = consoleErrorStub.calls.argsFor(0)[0];
expect(message.indexOf('componentWillMount')).toBeGreaterThan(-1);
expect(message.indexOf('componentWillReceiveProps')).toBeGreaterThan(-1);
expect(message.indexOf('componentWillUpdate')).toBeGreaterThan(-1);
expect(message.includes('componentWillMount')).toBeTruthy();
expect(message.includes('componentWillReceiveProps')).toBeTruthy();
expect(message.includes('componentWillUpdate')).toBeTruthy();
});

it('should allow suppress legacy life cycles when mixed with new APIs', () => {
Expand Down
Loading

0 comments on commit b8396c6

Please sign in to comment.