-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Add default code examples and behavior #23
Conversation
✅ Deploy Preview for eslint-code-explorer ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
src/hooks/use-explorer.ts
Outdated
export type SourceType = Exclude<Options['sourceType'], undefined>; | ||
export type Version = Exclude<Options['ecmaVersion'], undefined>; | ||
|
||
type ExplorerState = { | ||
tool: 'ast' | 'scope' | 'path'; | ||
setTool: (tool: ExplorerState['tool']) => void; | ||
|
||
code: string; | ||
setCode: (code: string) => void; | ||
JSCode: string; |
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.
Im not sure if we would want to scale the state variables like this. Going forward there are chances where we can actually have markdown as well? in that case we would have to then add a markdown code state and a setter for it. We might want to think of something generic for this case.
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.
src/App.tsx
Outdated
import { ThemeProvider, useTheme } from './components/theme-provider'; | ||
|
||
function App() { | ||
const { theme } = useTheme(); | ||
const { language, tool, code, setCode } = useExplorer(); | ||
const { language, tool, JSCode, setJSCode, JSONCode, setJSONCode } = useExplorer(); |
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'd suggest jsCode
and jsonCode
to match our code conventions.
src/lib/const.ts
Outdated
"key3": [1, 2, "3", 1e10, 1e-3] | ||
} | ||
} | ||
` |
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.
` | |
`.trim(); |
src/lib/const.ts
Outdated
export default [ | ||
...js.configs.recommended, | ||
getConfig() | ||
];`; |
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.
Remove extra empty line at the start.
];`; | |
];`.trim(); |
I think we will probably need to create our own language definition for JSONC. There's playground to help with that: We can do that separate from this PR. |
Sure I will check. when I checked online suggested to create own language definition. |
We could also consider using CodeMirror instead. It looks like creating custom languages may be a bit complex. |
There is a way to enable comments in the Monaco Editor by configuring the DiagnosticsOptions. |
Looks like there's a conflict now. |
To wrap up this PR, let's go ahead and enable comments when JSONC is selected. That will at least get things functional, then we can figure out a better long-term approach. |
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.
LGTM
I have already made the change. |
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.
LGTM. Thanks!
Prerequisites checklist
What is the purpose of this pull request?
fixes #11
What changes did you make? (Give an overview)
Add default code examples and behavior
Related Issues
#11
Is there anything you'd like reviewers to focus on?
jsonc
as the language, but it wasn't recognized, so it will likely show errors for comments in the JSON.sourceType
asmodule
and ECMAScript version aslatest
.