diff --git a/tm/standard/package.json b/tm/standard/package.json index 3dc1d9e..8c75089 100644 --- a/tm/standard/package.json +++ b/tm/standard/package.json @@ -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", @@ -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" } } diff --git a/tm/standard/src/py/Main_py.ts b/tm/standard/src/py/Main_py.ts index 1f60513..b3188fb 100644 --- a/tm/standard/src/py/Main_py.ts +++ b/tm/standard/src/py/Main_py.ts @@ -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) { diff --git a/tm/standard/tm/js/package.json b/tm/standard/tm/js/package.json index e91cf50..a2b8f45 100644 --- a/tm/standard/tm/js/package.json +++ b/tm/standard/tm/js/package.json @@ -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" } } diff --git a/tm/standard/tm/php/composer.json b/tm/standard/tm/php/composer.json new file mode 100644 index 0000000..df1c75c --- /dev/null +++ b/tm/standard/tm/php/composer.json @@ -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" + } + } + \ No newline at end of file diff --git a/tm/standard/tm/py/.pep8 b/tm/standard/tm/py/.pep8 new file mode 100644 index 0000000..b359c4e --- /dev/null +++ b/tm/standard/tm/py/.pep8 @@ -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 \ No newline at end of file diff --git a/tm/standard/tm/py/requirements.txt b/tm/standard/tm/py/requirements.txt index 0e5175b..0bb3ab6 100644 --- a/tm/standard/tm/py/requirements.txt +++ b/tm/standard/tm/py/requirements.txt @@ -2,3 +2,4 @@ pytest python-dotenv pydantic requests +autopep8 diff --git a/tm/standard/tm/py/support/linter.md b/tm/standard/tm/py/support/linter.md new file mode 100644 index 0000000..ad80e27 --- /dev/null +++ b/tm/standard/tm/py/support/linter.md @@ -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. diff --git a/tm/standard/tm/rb/Gemfile b/tm/standard/tm/rb/Gemfile index bb7b8de..45e601f 100644 --- a/tm/standard/tm/rb/Gemfile +++ b/tm/standard/tm/rb/Gemfile @@ -18,4 +18,5 @@ end # Development and test dependencies group :development, :test do gem 'pry', '~> 0.14' + gem 'standard', '~> 1.40.1' end diff --git a/tm/standard/tm/rb/tm.gemspec b/tm/standard/tm/rb/tm.gemspec index 0ef6ff1..1de32a1 100644 --- a/tm/standard/tm/rb/tm.gemspec +++ b/tm/standard/tm/rb/tm.gemspec @@ -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"]