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
Remove support for using JSX without React #25
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
58d2139
AFP-234: Enforce React to be imported for all components
dpisani-atl 028d7ba
AFP-234: Import React in generated code
dpisani-atl 90a5c47
AFP-234: Add React imports to remaining files and test fixtures
dpisani-atl 6594454
Add changeset
dpisani-atl 4866af3
Merge branch 'master' into dpisani/AFP-234-standard-babel-config
dpisani-atl 126ae70
AFP-234: Remove @emotion/core usages from components as it breaks things
dpisani-atl b00e56e
Merge branch 'dpisani/AFP-234-standard-babel-config' of github.com:gl…
dpisani-atl 45fe1c1
AFP-234: Add comment explaining disabled rule
dpisani-atl e3304a8
Enable eslint rule again
dpisani-atl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a description of this and what this is?