Comments (9)
Would this logic work?
For every line, count the number of leading spaces, spaces
. Replace them with spaces/tabsize
tabs.
from obsidian-linter.
I think so.
One consideration could be to also deal with cases where you have one more space than your tabsize, which would result in tab+space
. But that would rather be another rule, I guess?
from obsidian-linter.
You can pass it in as an option, the user can set
tabsize=2
in the settings. See the other rules for examples.
That would work, but it isn't ideal. Users might not consider that the tabsize set in the Linter plugin is independent from the tabsize set in the Obsidian main setting, leading to unnecessary confusion about the use of that rule
from obsidian-linter.
I was thinking about your use case, when you are copying from external sources. It would be nice if the default tabsize was the obsidian tab size though.
from obsidian-linter.
on the discord, found vault.getConfig("tabSize").
from obsidian-linter.
I have the rule ready, but I am a bit uncertain about the typescript part.
- is this how you would do it in the
rules.ts
?
(text: string) => {
let tabsize = vault.getConfig("tabSize"); // <- this the proper syntax?
(...)
},
- also, concerning the examples, how exactly do I have to write them, with the indention in the code of the
rules.ts
itself? or does thededent
already deal with that?
from obsidian-linter.
You should test the tabSize syntax in obsidian. If you put the repo in your plugins folder, after you run npm run compile
you should be able to activate it in obsidian and test it.
Yep dedent deals with it, its pretty smart about the indentation.
from obsidian-linter.
okay, I have a working solution ready, but there are two problem.
Problem 1: vault.getConfig("tabSize")
does not work, when compiling, I get the following error:
(!) Plugin typescript: @rollup/plugin-typescript TS2304: Cannot find name 'vault'.
src/rules.ts: (654:23)
654 let tabsize = vault.getConfig("tabSize");
~~~~~
I also tried adding import { App } from 'obsidian';
to the imports at the top of the document, but that did not solve it.
Problem 2: So what I did for now, was to simply use tabsize
as an option, as you suggested before. npm run compile
works fine and all tests are passed, however, npm run lint
has β surprise β a problems with me having added tabs.
> [email protected] lint
> eslint . --ext .ts --fix
/Users/chrisgrieser/Google Drive/File Hub/obsidian-linter/src/rules.ts
674:13 error Unexpected tab character no-tabs
676:13 error Unexpected tab character no-tabs
β 2 problems (2 errors, 0 warnings)
674:13
and 674:13
are, of course, exactly the two positions where I have inserted the tabs for the example. Naturally, removing the tabs for the linter causes the test not to pass. π
So assume you would have to change some linter configuration before I can commit this rule?
from obsidian-linter.
Well, at least problem #2 I figured out on my own by using inline comments to temporarily disable linting rules. Will be adding a PR shortly.
from obsidian-linter.
Related Issues (20)
- Bug: Linter removes the # from the Share Note share_link URL HOT 1
- Bug: Unable to parse url correctly HOT 2
- Bug: i can't insert yaml by using linger HOT 5
- FR: improve YAML key sort to "at Start" and "at End" order
- Button to exclude file/folder from Linter HOT 2
- Question: Copy `ε€ηεΈθ½ mAP\@.5` but the pasted text is `ε€ηεΈθ½ mAP\@`. how to fix it? HOT 3
- FR: Enabling personal additions to auto-correction map HOT 3
- Bug: Smart quotes get applied in Markdown image links HOT 5
- Bug: random deletion of characters/words/line breaks throughout the note HOT 17
- Bug: footnote-after-punctuation fails if reference name contains hyphen
- Question: Custom Command: converting multiple single lines to bullet points HOT 1
- FR: empty line around lists HOT 5
- Bug: Tag Regex Matches Punctuation Like `:` Which Causes Other Problems HOT 4
- Bug: Header capitalization rule does not update link text HOT 2
- FR: Support Obsidian-style comment for inline linter toggle HOT 1
- Bug: "Lint the current File" command failed to execute HOT 4
- Bug: "Move Tags to YAML" breaks when tags have a `/` HOT 5
- Bug: Remove space header when option `RemoveSpaceAroundCharacters` is enabled and Katakata is beginning of the line HOT 1
- FR: Matching / Tidying Header Pound Signs
- Bug: capitalize-headings, yaml-title, yaml-title-alias require two lint passes to resolve
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-linter.