Skip to content

Commit d85efe7

Browse files
committed
start
1 parent 3108512 commit d85efe7

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

linters/ation/.ation

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
29

linters/ation/ation.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
6+
DEFAULT_LENGTH = 100
7+
8+
9+
def get_length(workspace):
10+
config_file = workspace + "/.ation"
11+
if not os.path.exists(config_file):
12+
return DEFAULT_LENGTH
13+
with open(config_file) as f:
14+
return int(f.readline())
15+
16+
17+
if __name__ == "__main__":
18+
line_length = DEFAULT_LENGTH
19+
if len(sys.argv) > 1:
20+
line_length = get_length(sys.argv[1])
21+
22+
out = ""
23+
# TODO: TYLER REPLACE WITH READ
24+
for line in sys.stdin:
25+
replacement = line.replace("bad code", "good code")[:line_length]
26+
if replacement[-1] == "\n":
27+
out += replacement
28+
else:
29+
out += replacement + "\n"
30+
31+
print(out[:-1])

linters/ation/ation.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { linterFmtTest } from "tests";
2+
3+
linterFmtTest({ linterName: "ation" });

linters/ation/plugin.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 0.1
2+
lint:
3+
definitions:
4+
- name: ation
5+
files: [ALL]
6+
suggest_if: never
7+
runtime: python
8+
direct_configs: [.ation]
9+
commands:
10+
- name: format
11+
output: rewrite
12+
formatter: true
13+
cache_results: true
14+
stdin: true
15+
run: python3 "${cwd}/ation.py" ${workspace}
16+
success_codes: [0]
17+
ignore:
18+
- linters: [ation]
19+
paths:
20+
- "**/plugin.yaml"
21+
- ".trunk/**/*"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Testing formatter ation test basic 1`] = `
4+
"#!/usr/bin/env python3
5+
6+
GLOBAL_CONSTANT_128 = 10 * 12 + 8
7+
8+
# TODO: This is super clean. But have we considered what to do about roundoff error?
9+
def add(a, b):
10+
return a + b
11+
12+
# This is good code
13+
def fibonacci(n):
14+
if n <= 0:
15+
return 0
16+
elif n == 1:
17+
return 1
18+
else:
19+
return fibonacci(n-1) + fibonacci(n-2)
20+
21+
if __name__ == "__main__":
22+
print("Hello, World!")
23+
"
24+
`;

linters/ation/test_data/basic.in.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
3+
GLOBAL_CONSTANT_128 = 10 * 12 + 8
4+
5+
# TODO: This is super clean. But have we considered what to do about roundoff error?
6+
def add(a, b):
7+
return a + b
8+
9+
# This is bad code
10+
def fibonacci(n):
11+
if n <= 0:
12+
return 0
13+
elif n == 1:
14+
return 1
15+
else:
16+
return fibonacci(n-1) + fibonacci(n-2)
17+
18+
if __name__ == "__main__":
19+
print("Hello, World!")

0 commit comments

Comments
 (0)
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