From a8b463311ac8eff2485b8d89dca7c7faf88e957d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20De=20Freitas?= <37962411+JoseDeFreitas@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:47:14 -0500 Subject: [PATCH 1/3] Add files via upload --- linter/lint.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 linter/lint.py diff --git a/linter/lint.py b/linter/lint.py new file mode 100644 index 0000000..7b37424 --- /dev/null +++ b/linter/lint.py @@ -0,0 +1,28 @@ +from rules import (content_about, featured_playlists, youtubers_names) + +file_readme = './../readme.md' +with open(file_readme, 'r') as read_readme: + content_readme = read_readme.readlines() + +def main(): + """ + Main function. Used specifically to call print results + by calling functions into rules/. + """ + if len(youtubers_names.youtubers_name_errors_nums) == 0: + print("Every YouTubers names are good.", "\n") + else: + print("'YouTubers name' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in youtubers_names.youtubers_name_errors_nums]), "\n") + + if len(content_about.content_about_errors_nums) == 0: + print("Every 'Content about' sections are good.", "\n") + else: + print("'Content about' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in content_about.content_about_errors_nums]), "\n") + + if len(featured_playlists.featured_playlists_errors_nums) == 0: + print("Every 'Featured playlists' sections are good.", "\n") + else: + print("'Featured playlists' errors:\n", '\n'.join(["Error at line {}: there should be a trailing '\\'.".format(i) for i in featured_playlists.featured_playlists_errors_nums]), "\n") + +if __name__ == '__main__': + main() From e47c9a400631e2fe1f3aab7921999523e5f931d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20De=20Freitas?= <37962411+JoseDeFreitas@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:48:34 -0500 Subject: [PATCH 2/3] Add files via upload --- linter/rules/content_about.py | 15 +++++++++++++++ linter/rules/featured_playlists.py | 16 ++++++++++++++++ linter/rules/youtubers_names.py | 15 +++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 linter/rules/content_about.py create mode 100644 linter/rules/featured_playlists.py create mode 100644 linter/rules/youtubers_names.py diff --git a/linter/rules/content_about.py b/linter/rules/content_about.py new file mode 100644 index 0000000..60c9ed7 --- /dev/null +++ b/linter/rules/content_about.py @@ -0,0 +1,15 @@ +file_readme = './../readme.md' +with open(file_readme, 'r') as read_readme: + content_readme = read_readme.readlines() + +def content_about(): + content_about_errors_nums = [] + content_about_line = 'Content about:' + + for j, i in enumerate(content_readme): + if content_about_line in i: + if i[-2] != '\\': + content_about_errors_nums.append(j) + return content_about_errors_nums + +content_about_errors_nums = content_about() diff --git a/linter/rules/featured_playlists.py b/linter/rules/featured_playlists.py new file mode 100644 index 0000000..d877011 --- /dev/null +++ b/linter/rules/featured_playlists.py @@ -0,0 +1,16 @@ +file_readme = './../readme.md' +with open(file_readme, 'r') as read_readme: + content_readme = read_readme.readlines() + +def featured_playlists(): + featured_playlists_errors_nums = [] + featured_playlists_line = 'Featured playlists:' + featured_playlists_dlen = 124 + + for j, i in enumerate(content_readme): + if featured_playlists_line in i: + if len(i) < featured_playlists_dlen and i[-2] != '\\': + featured_playlists_errors_nums.append(j) + return featured_playlists_errors_nums + +featured_playlists_errors_nums = featured_playlists() diff --git a/linter/rules/youtubers_names.py b/linter/rules/youtubers_names.py new file mode 100644 index 0000000..986bdaf --- /dev/null +++ b/linter/rules/youtubers_names.py @@ -0,0 +1,15 @@ +file_readme = './../readme.md' +with open(file_readme, 'r') as read_readme: + content_readme = read_readme.readlines() + +def youtubers_names(): + youtubers_name_errors_nums = [] + youtuber_count_char = '[**' + + for j, i in enumerate(content_readme): + if youtuber_count_char in i: + if i[-2] != '\\': + youtubers_name_errors_nums.append(j) + return youtubers_name_errors_nums + +youtubers_name_errors_nums = youtubers_names() From e8a94f613e97a979b332f6158695783dadc533f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20De=20Freitas?= <37962411+JoseDeFreitas@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:54:38 -0500 Subject: [PATCH 3/3] Create readme.md --- linter/readme.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 linter/readme.md diff --git a/linter/readme.md b/linter/readme.md new file mode 100644 index 0000000..bb356d1 --- /dev/null +++ b/linter/readme.md @@ -0,0 +1,17 @@ +# Awesome YouTubers linter + +The awesome-youtubers linter is a workflow that checks the layout of the pull requests opened. This helps the contributors show if +something in the layout is not formatted correctly so it can be fixed. This linter was created in order to keep the format of the +list without breaking the layouts (images, new lines, etc.) + +## Rules + +The rules that the linter follows are: + +- Trailing `\` at the end of the name and link of the YouTuber. +- Trailing `\` at the end of the "Content about" section. +- Trailing `\` at the end of the "Featured playlists" section. +- Spaces between badges. +- Spaces between "Content about" words (including `,`). +- Spaces between "Featured playlists" words (including `,`). +- Links formatted correctly in the markdown syntax (`[text](link)`)