pattobrien / sidecar Goto Github PK
View Code? Open in Web Editor NEWA collection of packages providing you with more control over your IDE and developer experience.
Home Page: https://sidecaranalyzer.dev
License: MIT License
A collection of packages providing you with more control over your IDE and developer experience.
Home Page: https://sidecaranalyzer.dev
License: MIT License
Below are the definitions for different stages of project setup and configuration:
New Dart or Flutter project that does not yet have sidecar initialized.
pubspec.yaml
pubspec.yaml
and run pub gete.g. on pubspec.yaml
or analysis_options.yaml
changes
sidecar rebuild
on every config file changelint configurations:
lint configuration errors:
We could utilize a feature like VSCode Hover to output the exact subclass of a particular AstNode at the cursor. This could seriously help development of lints / edits.
for a riverpod package version 2.0.0
utils package: riverpod_analyzer v2.0.0
lints package: riverpod_lints v0.1.0 (i.e. version doesnt need to match 2.0.0, we can version it independently of the actual package version)
analysis_options.yaml
configurationCurrently plugin analyzes entire workspace.
example: riverpod_prefer_consumer_widget
The Analyzed and Reported AstNode should be the ClassDeclaration, but the highlighted node would be better served as the class name (i.e. Highlighted AstNode = SimpleIdentifier) or the extended superclass (i.e. Highlighted AstNode = Identifier).
We need to expose a separate method for the LintError class that allows subclasses to declare which node should be highlighted.
Lint / fixes should be responsible for declaring their own configurations, by declaring it when extending LintError or QuickFix .
Lints are, however, removed from bootstrap function.
Similar to CLI scripts, a user could run any sequence of CodeEdits from the CLI (including prompts for missing arguments). This would work similarly to dart fix
.
For example, users installing the intl
and flutter_localizations
packages will need to follow a series of steps in order to use generated translations. Instead of following a guide step-by-step, a user could instead run a command from the CLI that guides them through the install process.
Working with Types
CodeEdit debugger
Dart CLI Example:
DCM CLI Example (source):
Use of histograms could utilize this package: https://github.com/dart-lang/sdk/tree/main/pkg/scrape
.dart_tool
directorysidecar.yaml
rather than analysis_options.config
(due to plugin shutdown when the latter is edited)sidecar.yaml
generic configuration errorsUtilize pub's dependency checking abilities to figure out what version of sidecar_analyzer_plugin should be used as the base plugin. Also use this to determine lint/fix versions.
We should also include a way to override this path with a local path, to help with development.
To do:
package_config.json
file and extract the desired plugin version numberNote: this version may change at any time over the course of the project.
It's probably best that the implementation code of sidecar_analyzer_plugin
is separated into another package, so that the copied package does not have to be updated as frequently. This second package can be a simple interface of the plugin package.
Some errors are missing, while some other errors may be not descriptive enough.
analysis_options.yaml errors:
UX:
file.readAsString()
. Need to rethink how analysis option errors could be made visible.Wont Do:
SidecarInput
annotation and packageThis would probably best be paired with eventual CLI functionality, to run a lint or code edit.
LintRule debugger
Hot Reload
It seems like the plugin properly shuts down (RAM usage halves, lints no longer update when source code is edited), however, the last lint state is left in the editor.
A lint rule should default to one of the following:
a) inherit the includes glob of the sidecar config, or
b) inherit the includes globs defined for the lint itself (in the projects yaml file), or
c) have a LintRule-specific default
The order of which the globs should be applied should be dependent on the following definition order:
Lint-Explicit > Lint-Default > Package-Explicit > Package-Default > Sidecar-Explicit > Sidecar-Default
abstract class LintRule {
const LintRule([this.includesFromConfiguration]);
final List<Glob>? includesFromConfiguration;
...
List<Glob> get includes(String path) => includesFromConfiguration ?? [Glob('bin/**'), Glob('lib/**')];
}
During plugin initialization phase:
void init() {
for (final lintBuilder in lintBuilders) {
final packageConfig; // config comes from either a) project's sidecar.yaml OR b) the lint-package's definitions
final lint = lintBuilder(packageConfig);
allLints.add(lint);
}
}
During handleAnalysis
phase:
for (final lint in lints) {
if (lint.includes.any((glob) => glob.matches(analysisFilePath))) {
// lint is analyzed
}
}
Included lints for Sidecar
LintRule/CodeEdits:
Visitor:
it's possible for there to be many varying and conflicting implementations of a certain lint name. For example, avoid_string_literals
could be avoiding strings for any reason.
Instead of having lint/fix developers compete for lint names, or in lieu of arguing what the "proper definitions" of each lint could or should be, itd be much more reasonable to give lints and fixes namespace prefixes to avoid conflicts.
For example:
riverpod::prefer_consumer_widget
dart::prefer_adjacent_string_concatenation
flutter::use_full_hex_values_for_flutter_colors
Open Questions:
upon every new context collection creation:
Related issues:
Since the main objective of Sidecar was to have enhanced performance, it makes sense to solve the obvious quality-related performance issues before getting feedback - otherwise, users will be confused by the value proposition.
Runtime Enhancements:
Proposed pubspec file format:
name: riverpod_avoid_stateful_widgets
publish_to: cloudsmith.io/riverpod
version: 0.1.0
micropub: sidecar
environment:
sdk: ">=2.17.5 <3.0.0"
sidecar:
type: lint
dependencies:
riverpod_lint_utils: 0.1.0
sidecar: ^0.1.0
Users may want to create very project-specific lints or edits that wouldn't make sense to bundle up separately from the project itself. Therefore, defining lints/edits within the project directory is necessary to make defining project-specific rules as simple as possible.
Requirements:
Currently, flutter projects cannot use plugin because dart pub get
fails for Flutter packages.
We can use zones to control how printing is handled.
see this zone thread: https://twitter.com/rexthecoder/status/1585003704134299649?s=20&t=F33mFgvdpg6WB2K-tKHkZQ
This would be useful for the following reasons:
log()
(from developer
package) would clean up a lot of the code throughout the projectprint
or log
to output to debuggerCurrently LinterVisitor and NodeLintRegistry are copied outside of Analyzer package. There should be a desire to depend explicitly on analyzer package, to prevent issues arising from future analyzer package updates.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.