diff --git a/.ation b/.ation new file mode 100644 index 000000000..f04c001f3 --- /dev/null +++ b/.ation @@ -0,0 +1 @@ +29 diff --git a/linters/ation/.ation b/linters/ation/.ation new file mode 100644 index 000000000..f04c001f3 --- /dev/null +++ b/linters/ation/.ation @@ -0,0 +1 @@ +29 diff --git a/linters/ation/README.md b/linters/ation/README.md new file mode 100644 index 000000000..a617576cd --- /dev/null +++ b/linters/ation/README.md @@ -0,0 +1,10 @@ +# Trunk Ation + +Bring the power of brevity straight to the command line! Avoid pesky code run-ons, incessant nesting, and +long line smells, all with the press of a button! + +Simply run the following to get started: + +```bash +trunk check --filter=ation +``` diff --git a/linters/ation/ation.py b/linters/ation/ation.py new file mode 100644 index 000000000..4f764d6c0 --- /dev/null +++ b/linters/ation/ation.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import os +import sys + +DEFAULT_LENGTH = 100 + + +def get_length(workspace): + config_file = workspace + "/.ation" + if not os.path.exists(config_file): + return DEFAULT_LENGTH + with open(config_file) as f: + return int(f.readline()) + + +if __name__ == "__main__": + line_length = get_length(os.getcwd()) + + out = "" + for line in sys.stdin: + replacement = line.replace("bad code", "good code")[:line_length] + if replacement[-1] == "\n": + out += replacement + else: + out += replacement + "\n" + + print(out[:-1]) diff --git a/linters/ation/ation.test.ts b/linters/ation/ation.test.ts new file mode 100644 index 000000000..715a11a62 --- /dev/null +++ b/linters/ation/ation.test.ts @@ -0,0 +1,3 @@ +import { linterFmtTest } from "tests"; + +linterFmtTest({ linterName: "ation" }); diff --git a/linters/ation/plugin.yaml b/linters/ation/plugin.yaml new file mode 100644 index 000000000..6f748de06 --- /dev/null +++ b/linters/ation/plugin.yaml @@ -0,0 +1,23 @@ +version: 0.1 +lint: + definitions: + - name: ation + files: [ALL] + suggest_if: never + runtime: python + direct_configs: [.ation] + commands: + - name: format + output: rewrite + formatter: true + cache_results: true + stdin: true + run: python3 "${cwd}/ation.py" ${workspace} + success_codes: [0] + ignore: + - linters: [ation] + paths: + - "**/plugin.yaml" + - .trunk/**/* + enabled: + - ation diff --git a/linters/ation/test_data/ation_basic.fmt.shot b/linters/ation/test_data/ation_basic.fmt.shot new file mode 100644 index 000000000..b9cc69fd4 --- /dev/null +++ b/linters/ation/test_data/ation_basic.fmt.shot @@ -0,0 +1,24 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing formatter ation test basic 1`] = ` +"#!/usr/bin/env python3 + +GLOBAL_CONSTANT_128 = 10 * 12 + +# TODO: This is super clean. +def add(a, b): + return a + b + +# This is good code +def fibonacci(n): + if n <= 0: + return 0 + elif n == 1: + return 1 + else: + return fibonacci(n-1) + +if __name__ == "__main__": + print("Hello, World!") +" +`; diff --git a/linters/ation/test_data/basic.in.py b/linters/ation/test_data/basic.in.py new file mode 100644 index 000000000..00a0123fb --- /dev/null +++ b/linters/ation/test_data/basic.in.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +GLOBAL_CONSTANT_128 = 10 * 12 + +# TODO: This is super clean. +def add(a, b): + return a + b + +# This is good code +def fibonacci(n): + if n <= 0: + return 0 + elif n == 1: + return 1 + else: + return fibonacci(n-1) + +if __name__ == "__main__": + print("Hello, World!") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy