Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulmominsakib committed Oct 20, 2024
0 parents commit 7c7b4ae
Show file tree
Hide file tree
Showing 15 changed files with 2,730 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
out
dist
node_modules
.vscode-test/
*.vsix
5 changes: 5 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
});
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
]
}
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
11 changes: 11 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode/**
.vscode-test/**
src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/eslint.config.mjs
**/*.map
**/*.ts
**/.vscode-test.*
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log

All notable changes to the "flutter-component-separator" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Initial release
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Flutter Component Separator

## Overview

Flutter Component Separator is a Visual Studio Code extension designed to streamline the organization of Flutter widget files. It automatically separates component classes into individual files, making your Flutter projects more modular and easier to maintain.

## Features

- Automatically identifies the main widget in a Flutter file
- Separates other widget classes into individual files
- Creates a `components` folder to store separated widgets
- Updates import statements in the main file
- Works with any Flutter file structure

## Installation

1. Open Visual Studio Code
2. Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
3. Search for "Flutter Component Separator"
4. Click on the "Install" button

Alternatively, you can install the extension from the Visual Studio Code Marketplace.

## Usage

1. Open a Flutter file containing multiple widget classes
2. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
3. Type and select "Separate Flutter Components"
4. The extension will process the file:
- The first widget class encountered will be considered the main widget and will remain in the original file
- All other widget classes will be moved to separate files in a new `components` folder
- Import statements will be updated in the main file

## Example

Before:
```dart
// main_screen.dart
class MainScreen extends StatelessWidget {
// ...
}
class Header extends StatelessWidget {
// ...
}
class Footer extends StatelessWidget {
// ...
}
```

After running the extension:

```dart
// main_screen.dart
import 'components/header.dart';
import 'components/footer.dart';
class MainScreen extends StatelessWidget {
// ...
}
```

```dart
// components/header.dart
class Header extends StatelessWidget {
// ...
}
```

```dart
// components/footer.dart
class Footer extends StatelessWidget {
// ...
}
```

## Requirements

- Visual Studio Code 1.60.0 or higher
- Flutter extension for Visual Studio Code

## Known Issues

- The extension currently does not handle nested classes or classes defined inside functions
- It may not correctly process files with complex string literals containing code-like content

## Contributing

Contributions to the Flutter Component Separator extension are welcome! Please feel free to submit a Pull Request.

## License

This extension is released under the [MIT License](LICENSE).

## Support

If you encounter any problems or have any suggestions, please open an issue on the [GitHub repository](https://github.com/yourusername/flutter-component-separator).

Enjoy using Flutter Component Separator!
28 changes: 28 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";

export default [{
files: ["**/*.ts"],
}, {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module",
},

rules: {
"@typescript-eslint/naming-convention": ["warn", {
selector: "import",
format: ["camelCase", "PascalCase"],
}],

curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
semi: "warn",
},
}];
Loading

0 comments on commit 7c7b4ae

Please sign in to comment.