This repository has been archived by the owner on Mar 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AFP-234 Remove support for using JSX without React
* AFP-234: Enforce React to be imported for all components * AFP-234: Import React in generated code * AFP-234: Add React imports to remaining files and test fixtures * Add changeset * AFP-234: Remove @emotion/core usages from components as it breaks things * AFP-234: Add comment explaining disabled rule * Enable eslint rule again
- Loading branch information
1 parent
3f83228
commit fce89ba
Showing
53 changed files
with
231 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"releases": [{ "name": "@brisk-docs/website", "type": "minor" }], | ||
"dependents": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Remove support for using JSX without importing React in the website. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": [ | ||
"airbnb", | ||
"prettier", | ||
"prettier/flowtype", | ||
"prettier/react", | ||
"plugin:jest/recommended" | ||
"parser": "babel-eslint", | ||
"extends": [ | ||
"airbnb", | ||
"prettier", | ||
"prettier/flowtype", | ||
"prettier/react", | ||
"plugin:jest/recommended" | ||
], | ||
"plugins": ["emotion"], | ||
"rules": { | ||
"emotion/jsx-import": "error", | ||
"react/jsx-filename-extension": "off", | ||
"react/require-default-props": "off", | ||
"jsx-a11y/anchor-is-valid": [ | ||
"error", | ||
{ | ||
"components": ["Link"], | ||
"specialLink": ["hrefLeft", "hrefRight"], | ||
"aspects": ["invalidHref", "preferButton"] | ||
} | ||
], | ||
"plugins": ["emotion"], | ||
"rules": { | ||
"emotion/jsx-import": "error", | ||
"react/jsx-filename-extension": "off", | ||
"react/react-in-jsx-scope": "off", | ||
"react/require-default-props": "off", | ||
"jsx-a11y/anchor-is-valid": "off", | ||
"import/extensions": ["error", "never", { "css": "ignorePackages", "json": "always" }], | ||
"react/sort-comp": "off" | ||
"import/extensions": [ | ||
"error", | ||
"never", | ||
{ "css": "ignorePackages", "json": "always" } | ||
], | ||
"react/sort-comp": "off" | ||
}, | ||
"settings": { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"] | ||
}, | ||
"settings": { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"] | ||
}, | ||
"import/resolver": { | ||
// use <root>/path/to/folder/tsconfig.json | ||
"typescript": { | ||
"directory": "./packages/react-changelogs/tsconfig.json" | ||
} | ||
} | ||
"import/resolver": { | ||
// use <root>/path/to/folder/tsconfig.json | ||
"typescript": { | ||
"directory": "./packages/react-changelogs/tsconfig.json" | ||
} | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package1/examples/example1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 1 page'; | ||
const Example1 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package1/examples/example2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 2 page'; | ||
const Example2 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package1/examples/example3.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 3 page'; | ||
const Example3 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/website/__fixtures__/simple-mock-packages/packages/mock-package1/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Test Package 1'; | ||
const Element = <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package2/examples/example1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 1 package 2'; | ||
const Example1 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package2/examples/example2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 2 package 2'; | ||
const Example2 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package2/examples/example3.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 3 package 2'; | ||
const Example3 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/website/__fixtures__/simple-mock-packages/packages/mock-package2/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Test Package 2'; | ||
const Element = <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package3/examples/example1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 1 package3'; | ||
const Example1 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package3/examples/example2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 2 package3'; | ||
const Example2 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
...ges/website/__fixtures__/simple-mock-packages/packages/mock-package3/examples/example3.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Example 3 package3'; | ||
const Example3 = () => <h1>Hello, {name}</h1>; | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/website/__fixtures__/simple-mock-packages/packages/mock-package3/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
const name = 'Test Package 1'; | ||
const Element = <h1>Hello, {name}</h1>; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { createTempDir } from 'jest-fixtures'; | ||
import path from 'path'; | ||
import fse from 'fs-extra'; | ||
|
||
import * as generators from './index'; | ||
|
||
const assertImportsReact = source => { | ||
expect(source).toMatch(/^import React from 'react';$/m); | ||
}; | ||
|
||
describe('Page generators', () => { | ||
let cwd; | ||
let pagesPath; | ||
let wrappersPath; | ||
|
||
const getOutput = filename => { | ||
const outputPath = path.join(pagesPath, filename); | ||
return fse.readFileSync(outputPath, { encoding: 'utf-8' }); | ||
}; | ||
|
||
beforeEach(async () => { | ||
cwd = await createTempDir(); | ||
pagesPath = path.join(cwd, 'pages'); | ||
wrappersPath = path.join(cwd, 'wrappers'); | ||
}); | ||
|
||
it('creates js for a package home page', () => { | ||
generators.generateHomePage( | ||
'output.js', | ||
path.join(cwd, 'README.md'), | ||
{}, | ||
{ wrappersPath, pagesPath }, | ||
); | ||
|
||
const output = getOutput('output.js'); | ||
|
||
assertImportsReact(output); | ||
}); | ||
|
||
it('creates js for a package doc page', () => { | ||
generators.generatePackageDocPage( | ||
'output.js', | ||
path.join(cwd, 'README.md'), | ||
{}, | ||
{ wrappersPath, pagesPath }, | ||
); | ||
|
||
const output = getOutput('output.js'); | ||
|
||
assertImportsReact(output); | ||
}); | ||
|
||
it('creates js for a package example pages', () => { | ||
generators.generateExamplePage( | ||
'output.js', | ||
'output-raw.js', | ||
path.join(cwd, 'example.js'), | ||
{}, | ||
{ wrappersPath, pagesPath }, | ||
); | ||
|
||
const output = getOutput('output.js'); | ||
|
||
const outputRaw = getOutput('output-raw.js'); | ||
|
||
assertImportsReact(output); | ||
|
||
assertImportsReact(outputRaw); | ||
}); | ||
|
||
it('creates js for a docs home page', () => { | ||
generators.generateDocsHomePage( | ||
'output.js', | ||
{}, | ||
{ wrappersPath, pagesPath }, | ||
); | ||
|
||
const output = getOutput('output.js'); | ||
|
||
assertImportsReact(output); | ||
}); | ||
|
||
it('creates js for an examples home page', () => { | ||
generators.generateExamplesHomePage( | ||
'output.js', | ||
{}, | ||
{ wrappersPath, pagesPath }, | ||
); | ||
|
||
const output = getOutput('output.js'); | ||
|
||
assertImportsReact(output); | ||
}); | ||
|
||
it('creates js for project doc page', () => { | ||
generators.generateProjectDocPage( | ||
'output.js', | ||
path.join(cwd, 'README.md'), | ||
{}, | ||
{ wrappersPath, pagesPath }, | ||
); | ||
|
||
const output = getOutput('output.js'); | ||
|
||
assertImportsReact(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import React from 'react'; | ||
import Heading from './Heading'; | ||
import Link from '../switch-link'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
BackItem, | ||
MenuSection, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/website/components/navigation/package-nav-content.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
MenuSection, | ||
BackItem, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.