File tree Expand file tree Collapse file tree 6 files changed +99
-0
lines changed Expand file tree Collapse file tree 6 files changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ 29
Original file line number Diff line number Diff line change
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 ])
Original file line number Diff line number Diff line change
1
+ import { linterFmtTest } from "tests" ;
2
+
3
+ linterFmtTest ( { linterName : "ation" } ) ;
Original file line number Diff line number Diff line change
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/**/*"
Original file line number Diff line number Diff line change
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
+ `;
Original file line number Diff line number Diff line change
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!" )
You can’t perform that action at this time.
0 commit comments