diff --git a/.editorconfig b/.editorconfig index 6b68779..9ebff1d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,13 +1,14 @@ +# editorconfig.org root = true [*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true indent_style = tab indent_size = 4 +end_of_line = lf +charset = utf-8 trim_trailing_whitespace = true +insert_final_newline = true -[{.travis.yml,appveyor.yml,npm-shrinkwrap.json,package.json}] +[{package-lock.json,package.json,*.yml}] indent_style = space indent_size = 2 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d2cdf81 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +ko_fi: mrmlnc +custom: + - https://www.buymeacoffee.com/mrmlnc + - https://www.paypal.me/mrmlnc diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..4434060 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,22 @@ +### Environment + + * VSCode Version: ... + * OS Version: ... + +### Actual behavior + +... + +### Expected behavior + +... + +### Steps to reproduce + +... + +### Config + +```js +// Paste your configuration here. +``` diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e37ec22 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +### What is the purpose of this pull request? + +... + +### What changes did you make? (Give an overview) + +... diff --git a/.gitignore b/.gitignore index 77145a1..b3d92af 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,3 @@ node_modules/ # Compiled and tempory files .tmp/ out/ - -# Other files -package-lock.json -yarn.lock diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0fad082 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "csscomb.js"] + path = csscomb.js + url = https://github.com/csscomb/csscomb.js + branch = dev diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..cffe8cd --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +save-exact=true diff --git a/.travis.yml b/.travis.yml index 32f498b..3490c9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false language: node_js node_js: - - '7' + - '10' script: - npm run build diff --git a/.vscodeignore b/.vscodeignore index 4aad89e..cc80fe1 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -11,3 +11,8 @@ tslint.json .vscode/** src/** smoke/** + +# csscomb submodule +csscomb.js/** +!csscomb.js/config +!csscomb.js/lib diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md new file mode 100644 index 0000000..efccb43 --- /dev/null +++ b/CODE-OF-CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at dmalinochkin@rambler.ru. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d0c672d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,57 @@ +# Contributing to my package + +Welcome, and thank you for your interest in contributing to **vscode-csscomb**! + +Please note that this project is released with a [Contributor Code of Conduct](CODE-OF-CONDUCT.md). By participating in this project you agree to abide by its terms. + +## Contribution Guidelines + +There are a couple of ways you can contribute to this repo: + + * **Ideas, feature requests and bugs**: We are open to all ideas and we want to get rid of bugs! Use the [Issues section](https://github.com/mrmlnc/vscode-csscomb/issues) to either report a new issue, provide your ideas or contribute to existing threads. + * **Documentation**: Found a typo or strangely worded sentences? Submit a PR! + * **Code**: Contribute bug fixes, features or design changes. + +### Creating an Issue + +Before you create a new Issue: + + * Check the [Issues](https://github.com/mrmlnc/vscode-csscomb/issues) on Github to ensure one doesn't already exist. + * Clearly describe the issue, including the steps to reproduce the issue. + +### Making Changes + +#### Getting Started + + * Install [Node.js](https://nodejs.org/en/). + * Fork the project and clone the fork repo. ([how to create fork?](https://help.github.com/articles/fork-a-repo/#fork-an-example-repository)). + * Create a topic branch from the master branch. + * Run `yarn` or `npm install` to install the application dependencies. + +#### Setup + +1. Start watching: + +``` +$ npm run watch +``` + +2. Make changes: + +``` +$ code . +``` + +3. Run tests: + +``` +$ npm t +``` + +4. Test your version of the extension: + +Press F5 in the editor and then test extension commands and functions. + +#### Commit + +Keep git commit messages clear and appropriate. You can use [Angular guide](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). diff --git a/README.md b/README.md index 472ad59..4581bd8 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,22 @@ > VS Code plugin for [CSScomb](http://csscomb.com/) — CSS coding style formatter. -## Donate +## :warning: This plugin is archived -If you want to thank me, or promote your Issue. +The main package ([`csscomb`](https://github.com/csscomb/csscomb.js)) has no maintainer and does not develop. In this regard, the development of the plugin does not make sense. -[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/mrmlnc) +Alternatively you can use: + +* [`postcss`](https://github.com/postcss/postcss) with similar plugins. +* [`stylelint`](https://github.com/stylelint/stylelint) + +> I'm ready to go back to developing the plugin if the csscomb will develops again. -> Sorry, but I have work and support for plugins and modules requires some time after work. I will be glad of your support or PR's. +## Donation + +Do you like this project? Support it by donating, creating an issue or pull request. + +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/mrmlnc) ## Install @@ -19,14 +28,15 @@ See the [extension installation guide](https://code.visualstudio.com/docs/editor ## Usage -Press F1 and run the command named `CSSComb`. +1. Put a `cssconfig.json` in your project root, or set the config in the setting `csscomb.preset`. You can start with one of the [predefined configs](https://github.com/csscomb/csscomb.js/tree/dev/config) or [generate a config](http://csscomb.com/config). See details in [config docs](https://github.com/csscomb/csscomb.js/blob/dev/doc/configuration.md). +1. Run `CSSComb` in the Command Palette (F1, Ctrl+Shift+P on Windows, Cmd+Shift+P on macOS). ## Supported languages * Styles: CSS, Less, Sass, SCSS - * Styles inside `') { // Find first newline symbol for the current style tag let previous = pos; - let indent = ''; do { char = text.charAt(previous); previous--; - - indent += char; } while (char !== '\n' && previous >= 0); const blockEndIndex = pos - (pos - previous - 1); @@ -117,6 +114,6 @@ export default class EmbeddedProvider extends BaseProvider { } public supportedSyntaxes(): string[] { - return ['html', 'htm', 'vue', 'vue-html']; + return ['html', 'htm', 'vue', 'vue-html', 'svelte']; } } diff --git a/src/providers/styles.ts b/src/providers/styles.ts index c379a54..41c40f3 100644 --- a/src/providers/styles.ts +++ b/src/providers/styles.ts @@ -6,9 +6,9 @@ import { IPluginSettings, IStyleBlock } from '../types'; export default class StylesProvider extends BaseProvider { constructor( - private document: vscode.TextDocument, - private selection: vscode.Selection, - public syntax: string, + private readonly document: vscode.TextDocument, + private readonly selection: vscode.Selection, + public readonly syntax: string, workspace: string, filepath: string, settings: IPluginSettings ) { super(workspace, filepath, syntax, settings); @@ -30,7 +30,9 @@ export default class StylesProvider extends BaseProvider { content = this.document.getText(range); } - return [{ syntax: this.syntax, range, content, error: null, changed: false }]; + const syntax: string = this.getSyntax(this.syntax); + + return [{ syntax, range, content, error: null, changed: false }]; } public supportedSyntaxes(): string[] { diff --git a/src/services/csscomb.ts b/src/services/csscomb.ts index 7cd6ea6..f046c43 100644 --- a/src/services/csscomb.ts +++ b/src/services/csscomb.ts @@ -1,16 +1,32 @@ -import * as CSSComb from 'csscomb'; +// @ts-ignore +import * as CSSComb from '../../csscomb.js/lib/csscomb.js'; + +interface IProcessOptions { + filename?: string; + context?: string; + syntax: string; +} + +declare class CSSCombConstructor { + constructor(config: string | object); + public static getConfig(name: string): object; + public configure(config: object): void; + public processString(text: string, options: IProcessOptions): Promise; +} + +type CSSComb = typeof CSSCombConstructor; const DEFAULT_CONFIGS = { - csscomb: CSSComb.getConfig('csscomb'), - yandex: CSSComb.getConfig('yandex'), - zen: CSSComb.getConfig('zen') + csscomb: (CSSComb as CSSComb).getConfig('csscomb'), + yandex: (CSSComb as CSSComb).getConfig('yandex'), + zen: (CSSComb as CSSComb).getConfig('zen') }; /** * Apply CSSComb to the given text with provided config. */ export function use(filename: string, text: string, syntax: string, config: object): Promise { - const csscomb = new CSSComb(config); + const csscomb = new (CSSComb as CSSComb)(config); return csscomb.processString(text, { syntax, filename }); }