<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Deep Naik on Medium]]></title>
        <description><![CDATA[Stories by Deep Naik on Medium]]></description>
        <link>https://medium.com/@deepnaik?source=rss-fcfde2e3fa30------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VTRhso1THcEUTjJm</url>
            <title>Stories by Deep Naik on Medium</title>
            <link>https://medium.com/@deepnaik?source=rss-fcfde2e3fa30------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:19:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deepnaik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Custom lint(Dart) — Part 6]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-part-6-cf70b90a2788?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf70b90a2788</guid>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:48 GMT</pubDate>
            <atom:updated>2025-08-18T16:26:48.316Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint(Dart) — Part 6</h3><h3>Build your first custom lint</h3><p>Lint rules are only useful if they’re properly set up and integrated into your project. In this part of the series, we’ll go step by step on how to create your own custom lint package, configure it, and finally see it in action. To make things practical, we’ll also include the <strong>IncorrectPageNameRule</strong> we wrote earlier as an example.</p><h3>Step 1: Create a New Dart Package for Your Lints</h3><p>Instead of mixing lints directly into your main Flutter project, the best practice is to create a separate Dart package. This keeps your codebase clean and reusable across multiple projects.</p><p>Run:</p><pre>dart create -t package my_custom_lints</pre><p>This creates a my_custom_lints package with the usual lib/ folder.</p><h3>Step 2: Add Dependencies</h3><p>Inside your my_custom_lints/pubspec.yaml, add:</p><pre>name: custom_lints_dart<br>description: A simple custom lint<br>version: 1.0.0<br><br>environment:<br>  sdk: &#39;&gt;=3.0.0 &lt;4.0.0&#39;<br><br>dependencies:<br>  analyzer: ^7.5.0<br>  analyzer_plugin: ^0.13.0<br>  custom_lint_builder: 0.8.0<br>  custom_lint: 0.8.0</pre><h3>Step 3: Define Your First Rule</h3><p>Inside lib/, create a file called incorrect_page_name_rule.dart and add the following:</p><pre>class IncorrectPageNameRule extends DartLintRule {<br>  const IncorrectPageNameRule() : super(code: _code);<br>  static const _code = LintCode(<br>    name: &#39;page_name_must_contain_page&#39;,<br>    problemMessage: &#39;Please ensure that the class name contains &quot;Page&quot; &#39;<br>        &#39;if it extends BasePage.&#39;,<br>  );<br>  @override<br>  void run(<br>    CustomLintResolver resolver,<br>    ErrorReporter reporter,<br>    CustomLintContext context,<br>  ) {<br>    context.registry.addClassDeclaration((node) {<br>      final element = node.declaredFragment?.element;<br>      if (element == null) return;<br>      final className = node.name.lexeme;<br>      final hasPageInName = className.contains(&#39;Page&#39;);<br>      final extendsBasePage = element.allSupertypes<br>          .any((type) =&gt; type.getDisplayString() == &#39;BasePage&#39;);<br>      if (!hasPageInName &amp;&amp; extendsBasePage) {<br>        reporter.atNode(node, _code);<br>      }<br>    });<br>  }<br>}</pre><p>This rule checks:</p><ul><li>If a class extends BasePage.</li><li>If its name does <strong>not</strong> include &quot;Page&quot;.</li><li>Then, it raises a lint warning.</li></ul><h3>Step 4: Register the Rule</h3><p>Create a lib/src/plugin.dart file and register your rule:PluginBase createPlugin() =&gt; _Plugin();</p><pre>class ExampleLinter extends PluginBase {<br>  @override<br>  List&lt;LintRule&gt; getLintRules(CustomLintConfigs configs) {<br>    return [<br>      IncorrectPageNameRule(),<br>    ];<br>  }<br>}</pre><p>This is the entry point for the lint plugin.</p><h3>Step 5: Use the Lint in Your Flutter Project</h3><ol><li>Go to your <strong>Flutter project’s </strong><strong>pubspec.yaml</strong>.</li></ol><pre><br>dependencies:<br>  flutter:<br>    sdk: flutter<br>  cupertino_icons: ^1.0.8<br><br>dev_dependencies:<br>  flutter_test:<br>    sdk: flutter<br>  custom_lint: 0.8.0<br>  custom_lints_dart:<br>    path: custom_lints_dart</pre><ol><li>Update your <strong>analysis_options.yaml</strong> in the Flutter project:</li></ol><pre>analyzer:<br>  plugins:<br>    - custom_lint</pre><h3>Step 6: Run and See It in Action</h3><p>In your Flutter project, run:</p><pre>dart run custom_lint</pre><p>If you have a class like this:</p><pre>class Profile extends BasePage {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Column(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      children: [<br>        Text(<br>          &#39;Profile Page&#39;,<br>        ),<br>        const SizedBox(height: 20),<br>        ElevatedButton(<br>          onPressed: () {<br>            // Example action<br>            print(&quot;Profile button pressed&quot;);<br>          },<br>          child: const Text(&#39;Go to Profile&#39;),<br>        ),<br>      ],<br>    );<br>  }<br>}</pre><p>You’ll now see a lint warning:</p><pre>Please ensure that the class name contains &quot;Page&quot; if it extends BasePage.</pre><p>But if you fix it:</p><pre>class ProfilePage extends BasePage {<br> <br>}</pre><p>No lint error will appear.</p><h3>Why This Setup Matters</h3><ul><li>Keeps lint rules reusable across multiple projects.</li><li>Provides better team collaboration (shared rules).</li><li>Helps enforce consistent coding standards automatically.</li></ul><p>✅ <strong>In short:</strong> You now know how to create a linting package, register rules, and integrate it into your Flutter/Dart projects. Our example IncorrectPageNameRule ensures that any class extending BasePage must include &quot;Page&quot; in its name. This is just the beginning—you can expand with many more custom rules tailored to your project’s needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf70b90a2788" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom lint(Dart) — Part 5]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-part-5-2a3094f3f503?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a3094f3f503</guid>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:45 GMT</pubDate>
            <atom:updated>2025-08-25T17:21:10.838Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint(Dart) — Part 5</h3><h3>How CustomLintContext Helps Identify AST and ASTNode</h3><p>When writing custom lint rules in Dart, one of the most important components you will encounter is CustomLintContext. It serves as the gateway between your rule and the Dart Analyzer, enabling you to interact with the Abstract Syntax Tree (AST) and its nodes (ASTNode).</p><p>This article explains how CustomLintContext works, how it helps identify AST and ASTNodes, and why it is essential in building reliable lint rules.</p><h3>What is AST (Abstract Syntax Tree)?</h3><p>The <strong>Abstract Syntax Tree (AST)</strong> is a structured tree representation of Dart source code. Instead of analyzing raw text, the analyzer parses Dart code into nodes that represent meaningful language constructs.</p><p>Examples of AST nodes include:</p><ul><li>A <strong>class declaration</strong></li><li>A <strong>method or function declaration</strong></li><li>A <strong>variable declaration</strong></li><li>A <strong>return statement</strong></li><li>An <strong>if condition</strong></li></ul><h3>What is an ASTNode?</h3><p>An <strong>ASTNode</strong> is a single element within the AST. Each piece of Dart code, whether it’s a function, class, or statement, is represented as an ASTNode.</p><p>For example:</p><ul><li>The following function has multiple ASTNodes:</li></ul><pre>int add(int a, int b) {<br>  return a + b;<br>}</pre><p>Here:</p><ul><li>add (function declaration) is an ASTNode.</li><li>a and b (parameters) are ASTNodes.</li><li>return a + b is an ASTNode.</li><li>Even the + operator is part of the AST.</li></ul><h3>What is CustomLintContext?</h3><p>CustomLintContext is provided to every lint rule’s run method. It allows you to:</p><ul><li>Access the AST.</li><li>Register which types of ASTNodes you want to analyze.</li><li>Report diagnostics (errors or warnings) when your rules are violated.</li></ul><p>Without CustomLintContext, your lint rule would not know which part of the code to inspect.</p><h3>How CustomLintContext Helps in Identifying ASTNodes</h3><p>Inside your lint rule, you use the registry property of CustomLintContext. This registry allows you to <strong>subscribe to specific ASTNode types</strong>. Whenever the analyzer finds that type of node, it calls your callback with the node instance.</p><p>Example:</p><pre>class IncorrectPageNameRule extends DartLintRule {<br>  const IncorrectPageNameRule() : super(code: _code);<br><br>  static const _code = LintCode(<br>    name: &#39;page_name_must_contain_page&#39;,<br>    problemMessage: &#39;Please ensure that the class name contains &quot;Page&quot; &#39;<br>        &#39;if it extends BasePage.&#39;,<br>  );<br><br>  @override<br>  void run(<br>    CustomLintResolver resolver,<br>    ErrorReporter reporter,<br>    CustomLintContext context,<br>  ) {<br>    context.registry.addClassDeclaration((node) {<br>      final element = node.declaredFragment?.element;<br>      if (element == null) return;<br><br>      final className = node.name.lexeme;<br>      final hasPageInName = className.contains(&#39;Page&#39;);<br>      final extendsBasePage = element.allSupertypes<br>          .any((type) =&gt; type.getDisplayString() == &#39;BasePage&#39;);<br><br>      if (!hasPageInName &amp;&amp; extendsBasePage) {<br>        reporter.atNode(node, _code);<br>      }<br>    });<br>  }<br>}</pre><h3>Breakdown:</h3><ul><li>context.registry.addClassDeclaration tells the analyzer: <em>“I want to look at every class declaration.”</em></li><li>node represents the <strong>ASTNode</strong> of that class.</li><li>node.name.lexeme gets the actual name of the class.</li><li>context.reportError(node.name) raises a lint error if the function violates the rule.</li></ul><h3>Step-by-Step Process</h3><p>Here’s how the interaction works:</p><ol><li>The Dart Analyzer parses the source code and builds the AST.</li><li>The analyzer creates ASTNodes for all constructs (classes, functions, variables, etc.).</li><li>Your lint rule is executed, and CustomLintContext is passed to it.</li><li>You register interest in specific ASTNode types (via context.registry).</li><li>Whenever the analyzer encounters that node type, it calls your callback with the node.</li><li>Inside the callback, you analyze the node and decide whether to report a lint issue.</li></ol><h3>Why This Matters</h3><ul><li>You don’t need to parse Dart source manually.</li><li>You focus only on the code constructs relevant to your rule.</li><li>CustomLintContext ensures your lint is precise, efficient, and integrated with the analyzer.</li></ul><p>✅ In short: CustomLintContext acts as the connector between your lint rule and the analyzer’s AST. It lets you target exactly which ASTNodes to analyze, simplifying the process of building powerful and accurate lint rules.</p><p>✅ Up Next: <a href="https://medium.com/@deepnaik/custom-lint-dart-part-6-cf70b90a2788">Part 6 — Build your first custom lint</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a3094f3f503" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom lint(Dart) — Part 4]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-part-4-75f83f273bfd?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/75f83f273bfd</guid>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:42 GMT</pubDate>
            <atom:updated>2025-08-18T16:29:07.611Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint(Dart) — Part 4</h3><h3>How ContextResolver is Used and How Semantic Analysis Comes into the Picture</h3><p>In the previous article, we discussed what a custom lint is and why it is useful. To go a step deeper, we now need to understand two key concepts that power custom lints: the <strong>ContextResolver</strong> and <strong>semantic analysis</strong>. These components are what allow lint rules to do more than just look at code structure — they enable rules to understand what the code actually means.</p><h3>What is Semantic Analysis?</h3><p>Semantic analysis is the phase after the Dart analyzer builds the Abstract Syntax Tree (AST).</p><ul><li>The AST gives us the <strong>structure</strong> of the code (what nodes exist, like classes, functions, and variables).</li><li>Semantic analysis goes further — it assigns <strong>meaning</strong> to those nodes.</li></ul><p>For example:</p><ul><li>The AST may tell us that there is a variable named user.</li><li>Semantic analysis tells us that user is of type UserModel, declared in a specific file, and maybe imported from another module.</li></ul><p>This level of understanding is crucial for linting because many rules depend not only on syntax but also on the <strong>meaning and relationships</strong> within the code.</p><h3>What is ContextResolver?</h3><p>The <strong>ContextResolver</strong> is a utility provided in the custom lint ecosystem. Its purpose is to help your lint rules interact with the analyzer’s semantic information.</p><p>In simple terms, it:</p><ul><li>Gives access to the analysis context of your project</li><li>Helps resolve references in the code (e.g., finding what type a variable actually belongs to)</li><li>Acts as a bridge between your custom lint and the analyzer’s semantic layer</li></ul><h3>How ContextResolver is Used</h3><p>When writing a custom lint, you might want to:</p><ul><li>Check the type of a variable</li><li>Find out where a class is defined</li><li>Ensure a method call is only used in the right context</li></ul><p>The ContextResolver enables this by resolving identifiers and nodes inside the AST. For example:</p><ul><li>If your lint rule wants to prevent using print(), you can use ContextResolver to resolve the call expression and verify it points to dart:core.print.</li><li>If your lint rule enforces naming conventions, you can resolve class declarations and their corresponding elements for validation.</li></ul><h3>Connection Between ContextResolver and Semantic Analysis</h3><p>ContextResolver directly relies on semantic analysis.</p><ul><li>The analyzer performs semantic analysis to map AST nodes to elements (symbols, types, functions, etc.).</li><li>ContextResolver lets your custom lint query this semantic data in a structured way.</li></ul><p>Without semantic analysis, a custom lint could only check raw syntax patterns. With semantic analysis, you can write much more powerful rules that truly understand the meaning of code.</p><h3>Why Is This Important?</h3><p>This step is what differentiates a <strong>basic static check</strong> (just looking at code text or patterns) from a <strong>true lint rule</strong> (understanding code deeply).</p><p>For example:</p><ul><li>A regex could catch the word print, but it wouldn’t know if it refers to dart:core.print or a user-defined function called print.</li><li>A custom lint with ContextResolver and semantic analysis can make that distinction accurately.</li></ul><h3>Key Takeaway</h3><p>The <strong>ContextResolver</strong> is the tool that makes semantic analysis usable inside custom lints. It allows you to move from just analyzing <strong>what code looks like</strong> to understanding <strong>what code means</strong>. This unlocks powerful linting capabilities, ensuring rules are accurate, reliable, and context-aware.</p><p>✅ Up Next: <a href="https://medium.com/@deepnaik/2a3094f3f503">Part 5 — Build your first custom lint</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75f83f273bfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom lint(Dart) — Part 3]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-part-3-822f78a6bd9f?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/822f78a6bd9f</guid>
            <category><![CDATA[analyzer]]></category>
            <category><![CDATA[lint]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[custom-lint]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:39 GMT</pubDate>
            <atom:updated>2025-08-18T17:48:12.689Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint(Dart) — Part 3</h3><h3>What is a Custom Lint in Dart?</h3><p>In the previous articles, we explored how the Dart analyzer works and what linting is. Now, let’s move one step further and understand what a custom lint is and why it matters.</p><h3>What is a Custom Lint?</h3><p>A custom lint is a linting rule that you create for your own project or team. Unlike the predefined rules in Dart or Flutter (like flutter_lints or pedantic), a custom lint allows you to define your own coding guidelines. It plugs into the Dart analyzer and automatically runs whenever your code is analyzed.</p><h3>Why Do We Need Custom Lints?</h3><p>Built-in lint rules cover general best practices, but they don’t know about your project’s specific requirements. For example, suppose you want to enforce that all repositories must end with Repository in their class name. The default linting rules won’t check this. A custom lint can catch this automatically.</p><p>Custom lints are useful to:</p><ul><li>Enforce project-specific rules</li><li>Ensure consistency in code structure</li><li>Prevent common mistakes unique to your project</li><li>Act as an automated reviewer that never misses anything</li></ul><h3>How Does a Custom Lint Work?</h3><p>The workflow is straightforward.</p><ol><li>Dart analyzer scans your raw source code.</li><li>It creates the Abstract Syntax Tree (AST) representation of that code.</li><li>Your custom lint rule inspects the AST.</li><li>If your rule’s condition is violated, a warning or error appears in your IDE.</li></ol><p>This can be summarized as:</p><p>Source Code → Analyzer → AST → Custom Rule Applied → Warning/Error Shown</p><h3>Example Use Cases of Custom Lints</h3><ul><li>Prevent using print() and enforce Logger.</li><li>Ensure all public APIs have documentation comments.</li><li>Force all async methods to include error handling.</li><li>Restrict certain imports (like avoiding UI imports inside the data layer).</li><li>Validate project naming conventions (e.g., file names must be in snake_case).</li></ul><h3>Tools to Create Custom Lints</h3><p>There are two main approaches to create custom lints.</p><ul><li>The custom_lint package: The easiest way to create and run custom lints.</li><li>Dart analyzer plugin: A more advanced option for deeper integration.</li></ul><h3>Key Takeaway</h3><p>Custom lints are about control and flexibility. They let you move beyond predefined rules and define automated checks tailored to your project’s needs. This ensures better consistency, maintainability, and quality across your codebase.</p><p>✅ Up Next: <a href="https://medium.com/@deepnaik/75f83f273bfd">Part 4 — How ContextResolver is used, and how semantic analysis comes into the picture.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=822f78a6bd9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom lint(Dart) — Part 2]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-part-2-8c87352614b6?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c87352614b6</guid>
            <category><![CDATA[analyzer]]></category>
            <category><![CDATA[custom-lint]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[lint]]></category>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:36 GMT</pubDate>
            <atom:updated>2025-08-18T17:46:54.440Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint(Dart) — Part 2</h3><h3>What is a Lint in Dart?</h3><p>When working with Dart or Flutter, you’ve probably seen warnings like <em>“Use const constructors where possible”</em> or <em>“Avoid empty catch blocks.”</em><br> These warnings are not just random — they come from <strong>lints</strong>.</p><h3>What is a Lint?</h3><p>• A <strong>lint</strong> is a rule that checks your code against recommended best practices.<br> • Unlike compiler errors, lints do not prevent your code from running. Instead, they <strong>guide you toward cleaner, safer, and more maintainable code</strong>.<br> • Example:</p><p>Code that compiles but may not be optimal:</p><pre>var list = [1, 2, 3]; <br>final copy = List.from(list);d</pre><p>A lint might suggest using list.toList() instead for readability.</p><h3>Why Do We Need Lints?</h3><p>• <strong>Consistency</strong>: Ensures everyone in a team follows the same style and patterns.<br> • <strong>Error Prevention</strong>: Catches potential bugs early (e.g., forgetting await).<br> • <strong>Readability</strong>: Makes the codebase easier to read and maintain.<br> • <strong>Best Practices</strong>: Encourages efficient and modern Dart usage.</p><h3>Types of Lints</h3><p>• <strong>Style Lints</strong> — related to formatting and code style.<br> Example: “Name classes using UpperCamelCase.”</p><p>• <strong>Performance Lints</strong> — ensure better performance.<br> Example: “Avoid using toString() in debugPrint.”</p><p>• <strong>Error-prone Lints</strong> — highlight code that is likely to cause bugs.<br> Example: “Avoid empty catch blocks.”</p><p>• <strong>Best Practice Lints</strong> — encourage better coding habits.<br> Example: “Prefer final for variables that are not reassigned.”</p><h3>How Lints are Configured</h3><p>• Lints are controlled by the analysis_options.yaml file in your project.<br> • Example setup:</p><pre>include: package:flutter_lints/flutter.yaml</pre><pre>linter:<br>  rules:<br>    prefer_const_constructors: true<br>    avoid_print: true</pre><p>• This means you can <strong>enable or disable specific rules</strong> depending on your team’s needs.</p><h3>Lints vs Errors</h3><p>• <strong>Errors</strong> stop compilation (e.g., missing semicolon).<br> • <strong>Lints</strong> are suggestions — your code still runs, but you’re encouraged to improve it.<br> • Think of lints as <strong>a code review assistant</strong> that works in real-time.</p><h3>Key Takeaway</h3><p>Lints are the <strong>first line of defense</strong> against messy code.<br> They don’t replace tests or reviews, but they <strong>raise the baseline quality of your code automatically</strong>.</p><p>Next up: <a href="https://medium.com/@deepnaik/custom-lint-dart-part-3-822f78a6bd9f"><strong>Article 3 — What is a Custom Lint in Dart?</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c87352614b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom lint(Dart) — Part 1]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-part-1-35355317480f?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/35355317480f</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[lint]]></category>
            <category><![CDATA[analyzer]]></category>
            <category><![CDATA[custom-lint]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:29 GMT</pubDate>
            <atom:updated>2025-08-18T17:46:03.922Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint(Dart) — Part 1</h3><h3><strong>How the Dart Analyzer Works</strong></h3><p>When you write Dart code, your editor (VS Code, IntelliJ, or Android Studio) is constantly showing you hints, warnings, and errors. This is powered by the <strong>Dart Analyzer</strong>.<br>But how does it actually work under the hood? Let’s break down the pipeline step by step.</p><h3>The Analyzer Pipeline</h3><p>The analyzer doesn’t just look at text. It processes your code through several stages to understand both <strong>syntax</strong> (how the code looks) and <strong>semantics</strong> (what the code means).</p><h3>1. Raw Source Code</h3><p>• This is the plain .dart file you write.<br> • At this stage, the analyzer sees nothing more than text characters.</p><h3>2. Lexical Analysis (Tokens)</h3><p>• The analyzer scans the text and breaks it into <strong>tokens</strong> (keywords, identifiers, operators, literals).<br> • Example: int x = 10; becomes tokens → int, x, =, 10, ;.<br> • This is often called the <strong>lexical layer</strong>.</p><h3>3. Syntax Tree (AST — Abstract Syntax Tree)</h3><p>• Tokens are grouped into a <strong>tree structure</strong> called the AST.<br> • The AST represents <strong>how the code is structured</strong>, not just the sequence of words.<br> • Example: int x = 10; becomes a variable declaration node with children → type (int), identifier (x), initializer (10).<br> • This step gives the analyzer a machine-readable model of your code’s grammar.</p><h3>4. Semantic Analysis</h3><p>• Now the analyzer connects the AST to <strong>real meanings</strong> in your program.<br> • Example: If you write user.name, the analyzer resolves what user refers to and checks if name exists on that type.<br> • It ensures types are correct, variables exist, and symbols are used properly.<br> • This stage powers type checking, unused variable warnings, and advanced lints.</p><h3>Why This Pipeline Matters</h3><p>• <strong>Lexical layer</strong> helps catch basic syntax errors (like missing ;).<br> • <strong>AST layer</strong> allows structural analysis (e.g., ensuring build methods return a widget).<br> • <strong>Semantic layer</strong> allows type-aware rules (e.g., warning if you compare int with String).</p><p>Without this layered approach, Dart couldn’t provide meaningful feedback beyond “your code has a typo.”</p><h3>Key Takeaway</h3><p>The Dart Analyzer works like a compiler’s front-end:</p><ul><li>Text → Tokens</li><li>Tokens → AST</li><li>AST → Semantic Model</li></ul><p>Understanding this pipeline is crucial because <strong>custom lints hook into these stages</strong>, especially the AST and semantic layers. That’s how we can write our own rules to enforce code quality.</p><p>Next up: <a href="https://medium.com/@deepnaik/8c87352614b6"><strong>Article 2 — What is a Lint in Dart?</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35355317480f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom lint(Dart)]]></title>
            <link>https://medium.com/@deepnaik/custom-lint-dart-a651e0171fd6?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/a651e0171fd6</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[custom-lint]]></category>
            <category><![CDATA[analyzer]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[lint]]></category>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 16:26:04 GMT</pubDate>
            <atom:updated>2025-08-18T16:37:59.048Z</atom:updated>
            <content:encoded><![CDATA[<h3>Custom lint in Dart</h3><p>When we write Dart or Flutter code, we rely on analysis tools in the background — editor errors, warnings about unused variables, and suggestions like using const where possible.</p><p>This series explains how those insights are produced and how you can extend them with your own rules.</p><h3>What this series covers</h3><h3>1. How the Dart Analyzer works</h3><p>• The pipeline from raw source → lexical tokens → AST (Abstract Syntax Tree) → semantic model.<br> • Why this pipeline matters for building precise lint rules.</p><h3>2. Lints in Dart (what and why)</h3><p>• The role of lints versus errors and warnings.<br> • How lints improve consistency, safety, and maintainability.</p><h3>3. Custom lints (extending analysis)</h3><p>• Why teams create project-specific rules.<br> • How the custom_lint package integrates with the analyzer.</p><h3>4. ContextResolver and semantic analysis</h3><p>• How Dart resolves identifiers, types, and references.<br> • Why semantic information enables accurate, type-aware lints.</p><h3>5. CustomLintContext and AST inspection</h3><p>• Accessing the AST and resolved units from a lint.<br> • Registering visitors to analyze specific AST nodes.</p><h3>6. Build your first custom lint</h3><p>• Project setup, writing a simple rule, registering it, and running it.<br> • Integrating the rule into an app and seeing results in the IDE/CLI.</p><h3>Who this series is for</h3><p>• Beginners who want to understand where editor diagnostics come from.<br> • Intermediate developers who want stronger code quality via linting.<br> • Advanced developers who need custom, architecture-level rules.</p><h3>What you’ll gain</h3><p>• A clear mental model of how Dart understands code.<br> • The ability to distinguish syntax (AST) from semantics (types, symbols).<br> • Practical skills to create and ship custom lint rules for your projects.<br> • A foundation for advanced analyzer work, including semantic checks and automated fixes.</p><p>Next up: <a href="https://medium.com/@deepnaik/custom-lint-dart-part-1-35355317480f"><strong>Article 1 — How the Dart Analyzer Works</strong>.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a651e0171fd6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shorebird : Code push for flutter Part 2]]></title>
            <link>https://medium.com/@deepnaik/shorebird-code-push-for-flutter-part-2-3b10efaf9bcc?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b10efaf9bcc</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[release-management]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Sun, 26 Nov 2023 15:16:31 GMT</pubDate>
            <atom:updated>2023-11-26T16:34:05.922Z</atom:updated>
            <content:encoded><![CDATA[<h3>Shorebird : Code push for flutter Part 2</h3><p>Welcome to part 2 of the series, where we explore the architecture, release, and patch process.</p><p><strong>Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*IMgls_pNk5sRZ3xa5xdhlQ.png" /></figure><h3><strong>Shorebird CLI</strong></h3><p>It helps to initiate, download, and deploy the changes via CLI. There are a couple of important commands we have in CLI.</p><p><strong><em>init</em></strong><em> </em>:- It will initiate the Shorebird project, create a unique app id (which can be found in shorebird.yaml file). This app id will then be useful to download the patches from the Shorebird server.</p><p><strong><em>login and login:ci </em></strong>:-<em> </em>It will help to log in as a Shorebird user, whereas login:ci will help to retrieve a token, which can then be used in CI workflows.</p><p><strong><em>release </em></strong>:- It will create a new release of the app, which needs to be follow the normal release process via app stores.</p><p><strong><em>patch </em></strong>:- It will create a patch build(changes of dart code), that can be applied to latest release.</p><p><strong>preview :- </strong>It will help to review the release on the local device. if we need to preview release that we are aiming to deploy.</p><h4>Modified Flutter Engine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*qOLRnn33Mj2ym9jRZHl8bg.png" /></figure><p><strong><em>Engine </em></strong>:- It is used to render UI and help in communicating with the host OS. Updater is used to communicate with the forked engine and then it does the same thing.</p><p><strong><em>Updater </em></strong>:- It is considered as the core part of Shorebird, because as mentioned, it fetches the changes from the Shorebird server and communicates with the forked engine, which then applies the changes to the devices. <a href="https://github.com/shorebirdtech/updater">https://github.com/shorebirdtech/updater</a></p><p><strong><em>Buildroot </em></strong>:- it contains the scripts that helps in building the flutter engine.</p><h4>Release and patch process</h4><p>As mentioned in the part 1 briefly, now we will see different approaches of how we can make a better release process. <em>Release</em> has to be done via stores, and <em>patches</em> applied to the last release made via stores.<br>By default patches will be installed to users devices whenever user restart their application session. This behaviour can be changed, we need to uncomment (<em>auto_update: false) </em>from shorebird.yaml file. Once we uncomment this shorebird wont fetch the changes from the shorebird server and now we can modify how we want our users to get the updates.<br>In order to achieve this we need shorebird code push package (<a href="https://pub.dev/packages/shorebird_code_push">https://pub.dev/packages/shorebird_code_push</a>). It has inbuilt functions that will check if new patch is available, it download the latest patch etc.<br>We can utilise this package and build a custom behaviour for our users to get the latest patches.<br>Note:- It requires an app to be restart so we can use restart app package <a href="https://pub.dev/packages/restart_app">https://pub.dev/packages/restart_app</a>. Important thing to note here is install and modification of changes is done on a separate isolate and not on main isolate.</p><p>Here comes the end of two part series, Thank you for the read.</p><p>connect with me at :- <br><a href="https://www.linkedin.com/in/naikdeep411/">https://www.linkedin.com/in/naikdeep411/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b10efaf9bcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shorebird : Code push for flutter Part 1]]></title>
            <link>https://medium.com/@deepnaik/shorebird-code-push-for-flutter-part-1-6a4ca886627e?source=rss-fcfde2e3fa30------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a4ca886627e</guid>
            <category><![CDATA[code-push]]></category>
            <category><![CDATA[release-management]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[cicd]]></category>
            <dc:creator><![CDATA[Deep Naik]]></dc:creator>
            <pubDate>Sun, 26 Nov 2023 15:15:59 GMT</pubDate>
            <atom:updated>2023-11-26T15:15:59.655Z</atom:updated>
            <content:encoded><![CDATA[<h3>Shorebird : Code push for flutter Part 1</h3><p><strong>What is shorebird</strong></p><p>Shorebird is a code push (over the air update). It’s a cloud service that allows developers to push app updates directly to users’ devices.</p><p><strong>When should we use it</strong></p><p>Consider a situation where there is a critical change or bug fix (dart code) that needs to be done in a production environment and we don’t want to compromise the user experience with our app.</p><h4><strong><em>Regular app release process</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*z9pJsvTT5jt57r8198sPaQ.png" /></figure><h4><strong><em>Shorebird release process</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*TBiGf0_JAF2L2VGMTqUQYA.png" /></figure><p>How it works</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*-vSwplQQ-c_uJrrzalt6fA.png" /></figure><h4><strong><em>Shorebird init</em></strong></h4><p>It will create a Shorebird app id, which will then be used to provide updates over the air with the help of <strong>Updater</strong>.</p><h4><strong><em>Shorebird release</em></strong></h4><p>It will create a release that has the <strong>Updater, </strong>which is responsible to provide update from the shorebird server and applying the changes.</p><h4><strong><em>Release through the store</em></strong></h4><p>Releases will always follow the traditional app update process.</p><h4><strong><em>Shorebird patch</em></strong></h4><p>It will first upload the dart code changes to the server. Then it will download the latest release from the server. It will then validate the patch. If everything is good, it will upload the patch with the latest release, and that’s pretty much it. Changes are now available to users.</p><h4><strong>Resources</strong></h4><p><a href="https://docs.shorebird.dev/">https://docs.shorebird.dev/</a><br><a href="https://github.com/shorebirdtech/updater">https://github.com/shorebirdtech/updater</a></p><h4><strong>FAQs</strong></h4><p><a href="https://docs.shorebird.dev/faq">https://docs.shorebird.dev/faq</a></p><p>In the next part will mention the architecture and the release and patch process.</p><p>connect with me at :- <br><a href="https://www.linkedin.com/in/naikdeep411/">https://www.linkedin.com/in/naikdeep411/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a4ca886627e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>