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

Add Default Linter #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tm/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
"test": "echo no-test",
"clean": "rm -rf node_modules yarn.lock package-lock.json",
"reset": "npm run clean && npm i && npm run build && npm test",
"mock-server": "prism mock def/$DefinitionFile"
"mock-server": "prism mock def/$DefinitionFile",
"lint-js": "cd sdk/js && npm run lint",
"lint-js-watch": "chokidar 'sdk/js/**/*.{js,ts}' -c 'npm run lint-js'",
"lint-py": "autopep8 --in-place --aggressive --aggressive sdk/py/**/*.py sdk/py/**/**/*.py",
"lint-py-watch": "chokidar 'sdk/py/**/*.py' -c 'npm run lint-py'",
"lint-rb": "cd sdk/rb && bundle exec standardrb --fix .",
"lint-rb-watch": "chokidar 'sdk/rb/**/*.rb' -c 'npm run lint-rb'",
"lint-go": "gofmt -s -w sdk/go",
"lint-go-watch": "chokidar 'sdk/go/**/*.go' -c 'npm run lint:go'",
"lint-php": "cd sdk/php && composer run-script lint",
"lint-php-watch": "chokidar 'sdk/php/**/*.php' -c 'npm run lint-php'"
},
"author": "",
"license": "MIT",
Expand All @@ -25,6 +35,7 @@
"@voxgig/util": "^0.0.3",
"@types/node": "22.7.5",
"@stoplight/prism-cli": "^5.10.0",
"typescript": "^5.6.3"
"typescript": "^5.6.3",
"chokidar-cli": "^3.0.0"
}
}
3 changes: 2 additions & 1 deletion tm/standard/src/py/Main_py.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const config_setup_files = [
'setup.cfg',
'MANIFEST.in',
'Makefile',
'pytest.ini'
'pytest.ini',
'.pep8'
]

const Main = cmp(async function Main(props: any) {
Expand Down
7 changes: 5 additions & 2 deletions tm/standard/tm/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"scripts": {
"test": "node --test test/*.test.js",
"test-accept": "node --test test/accept/*.test.js",
"test-all": "npm run test && npm run test-accept"
"test-all": "npm run test && npm run test-accept",
"lint": "standard --fix 'src/**/*.{js,ts}' 'test/**/*.js'"
},
"author": "$$Name$$",
"license": "MIT",
"devDependencies": {
"@hapi/code": "^9.0.3",
"dotenv": "^16.4.5"
"dotenv": "^16.4.5",
"ts-standard": "^12.0.2",
"standard": "^17.1.2"
}
}
31 changes: 31 additions & 0 deletions tm/standard/tm/php/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "$$name$$/sdk",
"description": "A PHP SDK for interacting with the $$Name$$ API.",
"type": "library",
"require": {
"php": "^7.4 || ^8.0",
"guzzlehttp/guzzle": "^7.3",
"vlucas/phpdotenv": "^5.3",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"$$Name$$SDK\\PhpSDK\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "test/"
}
},
"scripts": {
"test": "phpunit --testdox",
"lint": "phpcs --standard=phpcs.xml src/ tests/",
"lint:fix": "phpcbf --standard=phpcs.xml src/ tests/"
},
"license": "MIT",
"require-dev": {
"squizlabs/php_codesniffer": "^3.10"
}
}

12 changes: 12 additions & 0 deletions tm/standard/tm/py/.pep8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[pep8]
# Set the maximum allowed line length (StandardJS uses 80 by default)
max-line-length = 80

# Enforce space around operators
ignore = E203

# Disable formatting warnings for shebang
ignore = E265

# Set other rules similar to StandardJS
indent-size = 2 # Match the default indentation of 2 spaces in StandardJS
1 change: 1 addition & 0 deletions tm/standard/tm/py/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest
python-dotenv
pydantic
requests
autopep8
42 changes: 42 additions & 0 deletions tm/standard/tm/py/support/linter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
To run the linter:

```js
npm run lint:py
```

To run the linter in watch mode:

```js
npm run lint:py:watch
```

**Add the Local Bin Directory to Your PATH:**

You can add the local bin directory (~/.local/bin) to your PATH so that autopep8 and other Python tools can be found.

Run the following command to add the directory to your current session’s PATH:

```bash
export PATH="$HOME/.local/bin:$PATH"
```
To make this permanent, add it to your shell configuration file (~/.bashrc or ~/.zshrc):


```bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # For bash
```
Reload your shell configuration:

```bash
source ~/.bashrc # For bash
```

** NOTES: **

You can use --recursive to format entire directories. For example:

```
autopep8 --in-place --recursive sdk/py
```

This will recursively format all Python files in the sdk/py directory.
1 change: 1 addition & 0 deletions tm/standard/tm/rb/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ end
# Development and test dependencies
group :development, :test do
gem 'pry', '~> 0.14'
gem 'standard', '~> 1.40.1'
end
1 change: 1 addition & 0 deletions tm/standard/tm/rb/tm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "simplecov", "~> 0.22"
spec.add_development_dependency "codecov"
spec.add_development_dependency "pry", "~> 0.14"
spec.add_development_dependency 'standard', '~> 1.40.1'

# If you use any files in your Gemfile that should be explicitly included in the gem:
spec.files += Dir["lib/**/*", "bin/*", "README.md", "LICENSE.txt"]
Expand Down