-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore(website): add playground to website #4108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bradzacher
merged 50 commits into
typescript-eslint:main
from
armano2:website-playground
Nov 29, 2021
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
8d960ad
chore(website): migrate playground from #3147
armano2 c09021e
Merge branch 'master' into website-playground
armano2 09613a1
chore(website): playground compilation fix, not fully working
armano2 a121f03
docs: allow playground to be executed
armano2 5961541
docs: fix circular modules
armano2 bc4f486
Merge branch 'master' into website-playground
armano2 40c5e38
docs(website): regenerate vendors
armano2 6b70c80
Merge branch 'master' into website-playground
armano2 bf5870d
Merge remote-tracking branch 'origin/master' into website-playground
armano2 92a235a
Merge remote-tracking branch 'armano2/master' into website-playground
armano2 4339a46
fix: update playground
armano2 fc36401
fix: expose linter types from website-eslint
armano2 0f7439f
fix(website): add extended eslint config editor
armano2 fef660f
Merge remote-tracking branch 'origin/master' into website-playground
armano2 d5dc0c6
fix(website): enable default focus on search input
armano2 e58eefc
refactor(website): refactor codebase
armano2 d9c277e
refactor(website): mark all props as readonly
armano2 368b0bf
refactor(website): migrate config code to use reducers
armano2 9e5f387
refactor(website): ensure correct focus for textarea
armano2 80a5a3f
refactor(website): update useHashState
armano2 60d617c
refactor(website): add missing error handling
armano2 193dec5
refactor(website): add basic tsconfig edit
armano2 697d811
refactor(website): simplify components
armano2 0e1f198
refactor(website): add basic config validation
armano2 86af1b9
refactor(website): refactor config editors
armano2 d8bc68c
refactor(website): get all registered rules instead of only from esli…
armano2 b9c0fd2
fix: correct invalid header in modals
armano2 023400e
Merge remote-tracking branch 'origin/main' into website-playground
armano2 0af7777
chore(website): add actions to playground
armano2 a1a1114
chore(website): fix issue with isLoading
armano2 171087b
chore(website): final code cleanup
armano2 c549ca8
Merge remote-tracking branch 'origin/main' into website-playground
armano2 a3b4f40
chore(website): simplify code of editor
armano2 d636bb0
chore(website): use BrowserOnly component to load playground
armano2 c466baf
chore(website): apply first part of changes requested in code review
armano2 62d12c1
chore(website): refactor editor to use composite api
armano2 4aeee36
chore(website): improve playground position, and scrolling of options
armano2 5b13139
chore(website): correct issue with changing typescript version
armano2 30ff108
Merge branch 'main' into pr/armano2/4108
bradzacher ef239bf
docs(website): refactor ast viewer
armano2 0d5ca6c
Merge remote-tracking branch 'origin/main' into website-playground
armano2 dd3385d
chore(website): fix reverse hovering error
armano2 37414ab
chore(website): correct z-index of playground and allow hints to be seen
armano2 4f8702b
Merge remote-tracking branch 'origin/main' into website-playground
armano2 d0c2fb6
chore(website-eslint): add missing comments
armano2 3472b61
chore(website-eslint): correct some of linting errors
armano2 1996667
chore: disable spelling check for vendor
armano2 f9baefe
chore: xposed -> exposed
armano2 403fceb
fix: add missing dev deps for website-eslint
armano2 e66e0a0
fix: revert unnecessary changes and add missing command
armano2 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
{ | ||
"name": "@typescript-eslint/website-eslint", | ||
"version": "5.4.0", | ||
"private": true, | ||
"description": "ESLint which works in browsers.", | ||
"engines": { | ||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||
}, | ||
"types": "types/index.d.ts", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "rollup --config=rollup.config.js", | ||
"format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore" | ||
}, | ||
"dependencies": { | ||
"@typescript-eslint/experimental-utils": "^5.4.0", | ||
"@typescript-eslint/types": "^5.4.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "*", | ||
"rollup": "^2.59.0", | ||
"semver": "^7.3.5", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@rollup/pluginutils": "^3.1.0", | ||
"@typescript-eslint/eslint-plugin": "5.4.0", | ||
"@typescript-eslint/parser": "5.4.0", | ||
"@typescript-eslint/scope-manager": "5.4.0", | ||
"@typescript-eslint/typescript-estree": "5.4.0", | ||
"@typescript-eslint/visitor-keys": "5.4.0" | ||
} | ||
} | ||
armano2 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,5 @@ | ||
{ | ||
"root": "packages/website-eslint", | ||
"type": "library", | ||
"implicitDependencies": [] | ||
} |
This file contains hidden or 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,94 @@ | ||
const path = require('path'); | ||
const Module = require('module'); | ||
const rollupPluginUtils = require('@rollup/pluginutils'); | ||
const MagicString = require('magic-string'); | ||
|
||
function toAbsolute(id) { | ||
return id.startsWith('./') ? path.resolve(id) : require.resolve(id); | ||
} | ||
|
||
function log(opts, message, type = 'info') { | ||
if (opts.verbose) { | ||
console.log('rollup-plugin-replace > [' + type + ']', message); | ||
} | ||
} | ||
|
||
function createMatcher(it) { | ||
if (typeof it === 'function') { | ||
return it; | ||
} else { | ||
return rollupPluginUtils.createFilter(it); | ||
} | ||
} | ||
|
||
module.exports = (options = {}) => { | ||
const aliasesCache = new Map(); | ||
const aliases = (options.alias || []).map(item => { | ||
return { | ||
match: item.match, | ||
matcher: createMatcher(item.match), | ||
target: item.target, | ||
absoluteTarget: toAbsolute(item.target), | ||
}; | ||
}); | ||
const replaces = (options.replace || []).map(item => { | ||
return { | ||
match: item.match, | ||
test: item.test, | ||
replace: | ||
typeof item.replace === 'string' ? () => item.replace : item.replace, | ||
|
||
matcher: createMatcher(item.match), | ||
}; | ||
}); | ||
|
||
return { | ||
name: 'rollup-plugin-replace', | ||
resolveId(id, importerPath) { | ||
const importeePath = | ||
id.startsWith('./') || id.startsWith('../') | ||
? Module.createRequire(importerPath).resolve(id) | ||
: id; | ||
|
||
let result = aliasesCache.get(importeePath); | ||
if (result) { | ||
return result; | ||
} | ||
|
||
result = aliases.find(item => item.matcher(importeePath)); | ||
if (result) { | ||
aliasesCache.set(importeePath, result.absoluteTarget); | ||
log(options, `${importeePath} as ${result.target}`, 'resolve'); | ||
return result.absoluteTarget; | ||
} | ||
|
||
return null; | ||
}, | ||
transform(code, id) { | ||
let hasReplacements = false; | ||
let magicString = new MagicString(code); | ||
|
||
replaces.forEach(item => { | ||
if (item.matcher && !item.matcher(id)) { | ||
return; | ||
} | ||
|
||
let match = item.test.exec(code); | ||
let start, end; | ||
while (match) { | ||
hasReplacements = true; | ||
start = match.index; | ||
end = start + match[0].length; | ||
magicString.overwrite(start, end, item.replace(match)); | ||
match = item.test.global ? item.test.exec(code) : null; | ||
} | ||
}); | ||
|
||
if (!hasReplacements) { | ||
return; | ||
} | ||
log(options, id, 'replace'); | ||
return { code: magicString.toString() }; | ||
}, | ||
}; | ||
}; |
This file contains hidden or 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,103 @@ | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
const replace = require('./rollup-plugin/replace'); | ||
|
||
module.exports = { | ||
input: 'src/linter/linter.js', | ||
output: { | ||
format: 'amd', | ||
interop: 'auto', | ||
freeze: false, | ||
file: 'dist/index.js', | ||
}, | ||
external: ['vs/language/typescript/tsWorker'], | ||
plugins: [ | ||
replace({ | ||
// verbose: true, | ||
alias: [ | ||
{ | ||
// those files should be omitted, we do not want them to be exposed to web | ||
match: [ | ||
/eslint\/lib\/(rule-tester|eslint|cli-engine|init)\//u, | ||
/eslint\/lib\/cli\.js$/, | ||
/experimental-utils\/dist\/eslint-utils\/RuleTester\.js$/, | ||
/experimental-utils\/dist\/ts-eslint\/CLIEngine\.js$/, | ||
/experimental-utils\/dist\/ts-eslint\/RuleTester\.js$/, | ||
/typescript-estree\/dist\/create-program\/createWatchProgram\.js/, | ||
/typescript-estree\/dist\/create-program\/createProjectProgram\.js/, | ||
/typescript-estree\/dist\/create-program\/createIsolatedProgram\.js/, | ||
/experimental-utils\/dist\/ts-eslint\/ESLint\.js/, | ||
// 'eslint/lib/shared/ajv.js', | ||
// 'eslint/lib/shared/runtime-info.js', | ||
], | ||
target: './src/mock/empty.js', | ||
}, | ||
{ | ||
// use window.ts instead of bundling typescript | ||
match: /typescript$/u, | ||
target: './src/mock/typescript.js', | ||
}, | ||
{ | ||
// assert for web | ||
match: /^assert$/u, | ||
target: './src/mock/assert.js', | ||
}, | ||
{ | ||
// path for web | ||
match: /^path$/u, | ||
target: './src/mock/path.js', | ||
}, | ||
{ | ||
// util for web | ||
match: /^util$/u, | ||
target: './src/mock/util.js', | ||
}, | ||
{ | ||
// semver simplified, solve issue with circular dependencies | ||
match: /semver$/u, | ||
target: './src/mock/semver.js', | ||
}, | ||
], | ||
replace: [ | ||
{ | ||
// we do not want dynamic imports | ||
match: /eslint\/lib\/linter\/rules\.js$/u, | ||
test: /require\(this\._rules\[ruleId\]\)/u, | ||
replace: 'null', | ||
}, | ||
{ | ||
// esquery has both browser and node versions, we are bundling browser version that has different export | ||
test: /esquery\.parse\(/u, | ||
replace: 'esquery.default.parse(', | ||
}, | ||
{ | ||
// esquery has both browser and node versions, we are bundling browser version that has different export | ||
test: /esquery\.matches\(/u, | ||
replace: 'esquery.default.matches(', | ||
}, | ||
{ | ||
// replace all process.env.NODE_DEBUG with false | ||
test: /process\.env\.NODE_DEBUG/u, | ||
replace: 'false', | ||
}, | ||
{ | ||
// replace all process.env.TIMING with false | ||
test: /process\.env\.TIMING/u, | ||
replace: 'false', | ||
}, | ||
{ | ||
// replace all process.env.IGNORE_TEST_WIN32 with true | ||
test: /process\.env\.IGNORE_TEST_WIN32/u, | ||
replace: 'true', | ||
}, | ||
], | ||
}), | ||
resolve({ | ||
browser: true, | ||
preferBuiltins: false, | ||
}), | ||
commonjs(), | ||
json({ preferConst: true }), | ||
], | ||
}; |
This file contains hidden or 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,48 @@ | ||
import { getDefaultLibFileName } from 'typescript'; | ||
armano2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export class CompilerHost { | ||
constructor(files, sourceFiles) { | ||
this.files = files; | ||
this.sourceFiles = sourceFiles; | ||
} | ||
|
||
fileExists(name) { | ||
return !!this.files[name]; | ||
} | ||
|
||
getCanonicalFileName(name) { | ||
return name; | ||
} | ||
|
||
getCurrentDirectory() { | ||
return '/'; | ||
} | ||
|
||
getDirectories() { | ||
return []; | ||
} | ||
|
||
getDefaultLibFileName(options) { | ||
return '/' + getDefaultLibFileName(options); | ||
} | ||
|
||
getNewLine() { | ||
return '\n'; | ||
} | ||
|
||
useCaseSensitiveFileNames() { | ||
return true; | ||
} | ||
|
||
writeFile() { | ||
return null; | ||
} | ||
|
||
readFile(name) { | ||
return this.files[name]; | ||
} | ||
|
||
getSourceFile(name) { | ||
return this.sourceFiles[name]; | ||
} | ||
} |
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.
i missed this in #4140