diff --git a/.flake8 b/.flake8 index c01b6312..b755cb6a 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] max-line-length = 120 -ignore = D100,D101,D102,F811,E722,F821 +ignore = D100,D101,D102,F811,E722,F821,W503 exclude = .git,__pycache__,.idea,messages,screenshots diff --git a/JsPrettier.py b/JsPrettier.py index 2733f7c4..8bc1f282 100644 --- a/JsPrettier.py +++ b/JsPrettier.py @@ -689,9 +689,14 @@ def is_typescript(view): if not filename: return False scopename = view.scope_name(0) - if scopename.startswith('source.ts') or filename.endswith('.ts'): - return True - if scopename.startswith('source.tsx') or filename.endswith('.tsx'): + if ( + scopename.startswith("source.ts") + or scopename.startswith("source.tsx") + or filename.endswith(".ts") + or filename.endswith(".tsx") + or filename.endswith(".cts") + or filename.endswith(".mts") + ): return True return False @@ -701,7 +706,12 @@ def is_json(view): if not filename: return False scopename = view.scope_name(0) - if scopename.startswith('source.json') or filename.endswith('.json'): + if ( + scopename.startswith("source.json") + or filename.endswith(".json") + or filename.endswith(".jsonc") + or filename.endswith(".json5") + ): return True return False @@ -772,7 +782,11 @@ def is_yaml(view): if not filename: return False scopename = view.scope_name(0) - if scopename.startswith('source.yaml') or filename.endswith('.yml'): + if ( + scopename.startswith("source.yaml") + or filename.endswith(".yml") + or filename.endswith(".yaml") + ): return True return False diff --git a/JsPrettier.sublime-settings b/JsPrettier.sublime-settings index 590e9cdb..162a950c 100644 --- a/JsPrettier.sublime-settings +++ b/JsPrettier.sublime-settings @@ -160,9 +160,10 @@ // // Additional custom file extensions to format. // - // There's built-in support already for "js", "jsx", "mjs", "json", "html", - // "graphql/gql", "ts", "tsx", "css", "scss", "less", "md", "mdx", "yml" - // and "vue" and "component.html" (angular html) files. + // There's built-in support already for "js", "jsx", "cjs", "mjs", "json", + // "jsonc", "json5", "html", "graphql/gql", "ts", "tsx", "cts", "mts", "css", + // "scss", "less", "md", "mdx", "yml", "yaml" and "vue" and "component.html" + // (angular html) files. // // Additional file extensions MUST be specified here, and without the leading dot. // ---------------------------------------------------------------------- diff --git a/README.md b/README.md index dc904c38..757575ef 100644 --- a/README.md +++ b/README.md @@ -237,9 +237,10 @@ application menu to: Text syntaxes. - **custom_file_extensions** (default: []) - There's built-in support already for `js`, `jsx`, `mjs`, `json`, `html`, - `graphql/gql`, `ts`, `tsx`, `css`, `scss`, `less`, `md`, `mdx`, `yml`, - `vue` and `component.html` (angular html) files. + There's built-in support already for `js`, `jsx`, `cjs`, `mjs`, `json`, + `jsonc`, `json5`, `html`, `graphql/gql`, `ts`, `tsx`, `cts`, `mts`, `css`, + `scss`, `less`, `md`, `mdx`, `yml`, `yaml`, `vue` and `component.html` + (angular html) files. Put additional file extensions here, and be sure not to include the leading dot in the file extension. diff --git a/jsprettier/const.py b/jsprettier/const.py index 895526fa..ba930eac 100644 --- a/jsprettier/const.py +++ b/jsprettier/const.py @@ -138,6 +138,8 @@ 'js', 'jsx', 'json', + 'jsonc', + 'json5', 'graphql', 'gql', 'html', @@ -149,6 +151,10 @@ 'md', 'vue', 'yml', + 'yaml', + 'cjs', 'mjs', - 'mdx' + 'mdx', + 'cts', + 'mts' ]