Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint-readme: insert semicolons more discerningly #14

Closed
Avaq opened this issue May 1, 2018 · 3 comments
Closed

lint-readme: insert semicolons more discerningly #14

Avaq opened this issue May 1, 2018 · 3 comments

Comments

@Avaq
Copy link
Member

Avaq commented May 1, 2018

The script (see below) that rewrites code blocks for linting should be smarter about inserting semicolons, so that the linter will not complain about misplaced semicolons.

rewrite() {
local state=
local line
while IFS='' read -r line ; do
local a="${line:0:1}"
local b="${line:1:1}"
local z="${line: -1}"
if [[ $a$b == '> ' ]] ; then
printf '\n%s' "${line:2}"
state=input
elif [[ -n $state && $a$b == '. ' ]] ; then
printf '\n%s' "${line:2}"
elif [[ $state == input && $a$z == '{}' ]] ; then
printf ';\n%s' "($line)"
state=output
elif [[ $state == input ]] ; then
printf ';\n%s' "$line"
state=output
elif [[ $state == output ]] ; then
printf ';\n%s' "$line"
state=
else
printf '\n%s' "$line"
fi
done
}

See Avaq/permissionary#5 for discussion leading up to this.

@Avaq Avaq changed the title lint-readme: insert insert semicolons more discerningly lint-readme: insert semicolons more discerningly May 1, 2018
@gabejohnson
Copy link
Member

Why do we have a script to rewrite code blocks? Is this to work around limitations of ESLint?

@Avaq
Copy link
Member Author

Avaq commented May 1, 2018

@gabejohnson Because codeblocks are written for https://github.com/davidchambers/doctest with additional information prefixed to every line in the form of >, ., and ! characters.

@gabejohnson
Copy link
Member

Ahhh...those code blocks. Thanks for the explanation Aldwin 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants