From dc6e803fc3fcc416df88e5dc104c7644805e625a Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Fri, 30 Sep 2022 20:18:41 +0300 Subject: [PATCH 1/3] chore: lint files in `examples` folder --- .eslintrc.cjs | 3 +-- examples/angular/app.component.spec.ts | 1 - examples/angular/app.component.ts | 1 - examples/angular/app.module.ts | 1 - examples/angular/shared/data.service.spec.ts | 1 - examples/angular/shared/data.service.ts | 1 - examples/angular/shared/sub.service.spec.ts | 1 - examples/enzyme/__tests__/CheckboxWithLabel-test.js | 3 +-- examples/mongodb/mongo-environment.js | 9 +++------ examples/mongodb/setup.js | 9 +++------ examples/mongodb/teardown.js | 6 ++---- examples/react-native/index.js | 2 +- examples/react/__tests__/CheckboxWithLabel-test.js | 1 - examples/snapshot/__tests__/clock.test.js | 2 +- examples/snapshot/__tests__/link.test.js | 2 +- examples/typescript/__tests__/CheckboxWithLabel-test.tsx | 1 - examples/typescript/__tests__/calc.test.ts | 5 ++--- examples/typescript/calc.ts | 2 +- 18 files changed, 16 insertions(+), 35 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 360f3d345c76..80e5ce82e1d4 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -216,8 +216,7 @@ module.exports = { { files: ['examples/**/*'], rules: { - 'import/no-unresolved': ['error', {ignore: ['^react-native$']}], - 'import/order': 'off', + 'no-restricted-imports': 'off', }, }, { diff --git a/examples/angular/app.component.spec.ts b/examples/angular/app.component.spec.ts index 6d5fcf88fdaa..19fc8d9eb0be 100644 --- a/examples/angular/app.component.spec.ts +++ b/examples/angular/app.component.spec.ts @@ -1,6 +1,5 @@ import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; import {describe, expect, it, jest} from '@jest/globals'; - import {AppComponent} from './app.component'; import {DataService} from './shared/data.service'; diff --git a/examples/angular/app.component.ts b/examples/angular/app.component.ts index 86aff20a89c9..b8125bbbcc6e 100644 --- a/examples/angular/app.component.ts +++ b/examples/angular/app.component.ts @@ -1,5 +1,4 @@ import {Component} from '@angular/core'; - import {DataService} from './shared/data.service'; @Component({ diff --git a/examples/angular/app.module.ts b/examples/angular/app.module.ts index 3d73ce15a3bf..485addfc9aab 100644 --- a/examples/angular/app.module.ts +++ b/examples/angular/app.module.ts @@ -1,6 +1,5 @@ import {NgModule} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; - import {AppComponent} from './app.component'; @NgModule({ diff --git a/examples/angular/shared/data.service.spec.ts b/examples/angular/shared/data.service.spec.ts index d2e7f829600e..00593e14b4ef 100644 --- a/examples/angular/shared/data.service.spec.ts +++ b/examples/angular/shared/data.service.spec.ts @@ -1,6 +1,5 @@ import {TestBed} from '@angular/core/testing'; import {beforeEach, describe, expect, it, jest} from '@jest/globals'; - import {DataService} from './data.service'; import {SubService} from './sub.service'; diff --git a/examples/angular/shared/data.service.ts b/examples/angular/shared/data.service.ts index f5359fd2c770..92f49ae69220 100644 --- a/examples/angular/shared/data.service.ts +++ b/examples/angular/shared/data.service.ts @@ -1,5 +1,4 @@ import {Injectable} from '@angular/core'; - import {SubService} from './sub.service'; @Injectable() diff --git a/examples/angular/shared/sub.service.spec.ts b/examples/angular/shared/sub.service.spec.ts index 941f98772987..769b826f16a3 100644 --- a/examples/angular/shared/sub.service.spec.ts +++ b/examples/angular/shared/sub.service.spec.ts @@ -1,6 +1,5 @@ import {TestBed} from '@angular/core/testing'; import {beforeEach, describe, expect, it} from '@jest/globals'; - import {SubService} from './sub.service'; describe('Service: SubService', () => { diff --git a/examples/enzyme/__tests__/CheckboxWithLabel-test.js b/examples/enzyme/__tests__/CheckboxWithLabel-test.js index 068dfa172e76..6e96b965160b 100644 --- a/examples/enzyme/__tests__/CheckboxWithLabel-test.js +++ b/examples/enzyme/__tests__/CheckboxWithLabel-test.js @@ -2,11 +2,10 @@ import Enzyme, {shallow} from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; +import CheckboxWithLabel from '../CheckboxWithLabel'; Enzyme.configure({adapter: new Adapter()}); -import CheckboxWithLabel from '../CheckboxWithLabel'; - it('CheckboxWithLabel changes the text after click', () => { // Render a checkbox with label in the document const checkbox = shallow(); diff --git a/examples/mongodb/mongo-environment.js b/examples/mongodb/mongo-environment.js index 60e5e8f14b72..c07bd2d4b0a6 100644 --- a/examples/mongodb/mongo-environment.js +++ b/examples/mongodb/mongo-environment.js @@ -1,9 +1,6 @@ -// mongo-environment.js -const NodeEnvironment = require('jest-environment-node').default; - -const path = require('path'); - -const fs = require('fs'); +import fs from 'fs'; +import path from 'path'; +import NodeEnvironment from 'jest-environment-node'; const globalConfigPath = path.join(__dirname, 'globalConfig.json'); diff --git a/examples/mongodb/setup.js b/examples/mongodb/setup.js index 095d57b150b6..ae87f7d78245 100644 --- a/examples/mongodb/setup.js +++ b/examples/mongodb/setup.js @@ -1,9 +1,6 @@ -// setup.js -const path = require('path'); - -const fs = require('fs'); - -const {MongoMemoryServer} = require('mongodb-memory-server'); +import fs from 'fs'; +import path from 'path'; +import {MongoMemoryServer} from 'mongodb-memory-server'; const globalConfigPath = path.join(__dirname, 'globalConfig.json'); diff --git a/examples/mongodb/teardown.js b/examples/mongodb/teardown.js index 2104c8ebf451..5a2c4a5f4dec 100644 --- a/examples/mongodb/teardown.js +++ b/examples/mongodb/teardown.js @@ -1,7 +1,5 @@ -// teardown.js -const path = require('path'); - -const fs = require('fs'); +import fs from 'fs'; +import path from 'path'; const globalConfigPath = path.join(__dirname, 'globalConfig.json'); diff --git a/examples/react-native/index.js b/examples/react-native/index.js index 33885e6ea214..8b1ac7e23694 100644 --- a/examples/react-native/index.js +++ b/examples/react-native/index.js @@ -6,9 +6,9 @@ * @flow */ -import Intro from './Intro'; import React, {Component} from 'react'; import {AppRegistry} from 'react-native'; +import Intro from './Intro'; class App extends Component<{}> { render() { diff --git a/examples/react/__tests__/CheckboxWithLabel-test.js b/examples/react/__tests__/CheckboxWithLabel-test.js index 05a89ab546b9..554c7007af9c 100644 --- a/examples/react/__tests__/CheckboxWithLabel-test.js +++ b/examples/react/__tests__/CheckboxWithLabel-test.js @@ -1,7 +1,6 @@ // Copyright 2004-present Facebook. All Rights Reserved. import {createRef} from 'react'; - import * as TestUtils from 'react-dom/test-utils'; import CheckboxWithLabel from '../CheckboxWithLabel'; diff --git a/examples/snapshot/__tests__/clock.test.js b/examples/snapshot/__tests__/clock.test.js index a4254cf284f7..78218ef2c14f 100644 --- a/examples/snapshot/__tests__/clock.test.js +++ b/examples/snapshot/__tests__/clock.test.js @@ -2,8 +2,8 @@ 'use strict'; -import Clock from '../Clock'; import renderer from 'react-test-renderer'; +import Clock from '../Clock'; jest.useFakeTimers(); Date.now = jest.fn(() => 1482363367071); diff --git a/examples/snapshot/__tests__/link.test.js b/examples/snapshot/__tests__/link.test.js index 607c8a639526..f7b868d6b4bd 100644 --- a/examples/snapshot/__tests__/link.test.js +++ b/examples/snapshot/__tests__/link.test.js @@ -2,8 +2,8 @@ 'use strict'; -import Link from '../Link'; import renderer from 'react-test-renderer'; +import Link from '../Link'; it('renders correctly', () => { const tree = renderer diff --git a/examples/typescript/__tests__/CheckboxWithLabel-test.tsx b/examples/typescript/__tests__/CheckboxWithLabel-test.tsx index 85159d2d4b15..96f73fb3f381 100644 --- a/examples/typescript/__tests__/CheckboxWithLabel-test.tsx +++ b/examples/typescript/__tests__/CheckboxWithLabel-test.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import * as TestUtils from 'react-dom/test-utils'; - const CheckboxWithLabel = require('../CheckboxWithLabel').default; it('CheckboxWithLabel changes the text after click', () => { diff --git a/examples/typescript/__tests__/calc.test.ts b/examples/typescript/__tests__/calc.test.ts index 7a05eadd8757..6d5d98510088 100644 --- a/examples/typescript/__tests__/calc.test.ts +++ b/examples/typescript/__tests__/calc.test.ts @@ -1,11 +1,10 @@ // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. import {jest} from '@jest/globals'; - -import Memory from '../memory'; +import Memory from '../Memory'; +import makeCalc from '../calc'; import sub from '../sub'; import sum from '../sum'; -import makeCalc from '../calc'; jest.mock('../memory'); jest.mock('../sub'); diff --git a/examples/typescript/calc.ts b/examples/typescript/calc.ts index 00a934b64559..ca3840c69f7d 100644 --- a/examples/typescript/calc.ts +++ b/examples/typescript/calc.ts @@ -1,6 +1,6 @@ +import Memory from './Memory'; import sub from './sub'; import sum from './sum'; -import Memory from './memory'; type Op = 'MemoryAdd' | 'MemoryClear' | 'MemorySub' | 'Sub' | 'Sum'; From 141c12838b33771c27be5747d3ce1403e58c4f99 Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Fri, 30 Sep 2022 20:32:53 +0300 Subject: [PATCH 2/3] rename --- examples/typescript/{memory.ts => Memory.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/typescript/{memory.ts => Memory.ts} (100%) diff --git a/examples/typescript/memory.ts b/examples/typescript/Memory.ts similarity index 100% rename from examples/typescript/memory.ts rename to examples/typescript/Memory.ts From abcfceba0daee3d46fcdf6b0cd1389d01aa1dd7c Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Fri, 30 Sep 2022 20:46:31 +0300 Subject: [PATCH 3/3] fix test --- examples/typescript/__tests__/calc.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typescript/__tests__/calc.test.ts b/examples/typescript/__tests__/calc.test.ts index 6d5d98510088..7ee93ef04678 100644 --- a/examples/typescript/__tests__/calc.test.ts +++ b/examples/typescript/__tests__/calc.test.ts @@ -6,7 +6,7 @@ import makeCalc from '../calc'; import sub from '../sub'; import sum from '../sum'; -jest.mock('../memory'); +jest.mock('../Memory'); jest.mock('../sub'); jest.mock('../sum');