Skip to content

Commit

Permalink
feat(prettier): add prettier-plugin-ini support
Browse files Browse the repository at this point in the history
close #120
  • Loading branch information
JounQin committed Jul 7, 2022
1 parent 4f70fd3 commit ae3315f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lockfile=false
9 changes: 6 additions & 3 deletions packages/config/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
exports.iniRcFiles = ['.npmrc', '.yarnrc']

exports.shRcFiles = ['.*shrc']

exports.nonJsonRcFiles = [
...exports.iniRcFiles,
...exports.shRcFiles,
'.browserslistrc',
'.npmrc',
'.nvmrc',
'.yarnrc',
'.*shrc',
]

exports.jsoncFiles = [
Expand Down
2 changes: 1 addition & 1 deletion packages/lint-staged/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TS_FILES = 'cts,mts,ts,tsx'
const STYLELINT_FILES = 'css,less,sass,scss,styl,stylus,svelte,vue'

const config = [
`*.{*sh,env,env.*,gql,html,json,properties,pug,rb,toml,yaml,yml${
`*.{*sh,env,env.*,gql,html,ini,json,properties,pug,rb,toml,yaml,yml${
isEslintAvailable ? '' : ',' + ESLINT_FILES + ',' + TS_FILES
}${isStylelintAvailable ? '' : ',' + STYLELINT_FILES}}`,
'.!(nvm)rc',
Expand Down
1 change: 1 addition & 0 deletions packages/lint-staged/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"lint-staged": ">=10.0.0"
},
"dependencies": {
"@1stg/config": "^0.0.0",
"@1stg/prettier-config": "^3.5.1",
"@1stg/tsconfig": "^2.2.2",
"@pkgr/utils": "^2.3.0",
Expand Down
27 changes: 19 additions & 8 deletions packages/prettier-config/base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const { jsoncFiles, nonJsonRcFiles } = require('@1stg/config')
const {
iniRcFiles,
jsoncFiles,
nonJsonRcFiles,
shRcFiles,
} = require('@1stg/config')

module.exports = {
arrowParens: 'avoid',
Expand All @@ -16,22 +21,28 @@ module.exports = {
),
overrides: [
{
files: ['.*rc', '*.json'],
excludeFiles: [...nonJsonRcFiles, ...jsoncFiles],
files: iniRcFiles,
options: {
parser: 'json-stringify',
parser: 'ini',
},
},
{
files: ['.browserslistrc', '.npmrc', '.yarnrc', '.*shrc'],
files: jsoncFiles,
options: {
parser: 'sh',
parser: 'json',
},
},
{
files: jsoncFiles,
files: ['.*rc', '*.json'],
excludeFiles: [...nonJsonRcFiles, ...jsoncFiles],
options: {
parser: 'json',
parser: 'json-stringify',
},
},
{
files: shRcFiles,
options: {
parser: 'sh',
},
},
],
Expand Down
1 change: 1 addition & 0 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@prettier/plugin-pug": "^2.1.1",
"@prettier/plugin-ruby": "^3.1.2",
"@prettier/plugin-xml": "^2.2.0",
"prettier-plugin-ini": "^1.0.0",
"prettier-plugin-pkg": "^0.16.0",
"prettier-plugin-sh": "^0.12.6",
"prettier-plugin-stylus": "^0.0.1-beta.3",
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10622,6 +10622,13 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier-plugin-ini@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-plugin-ini/-/prettier-plugin-ini-1.0.0.tgz#af0ecea207683c1598190d69e9a8cb49e94690eb"
integrity sha512-/b/D6U2Ivo0CW8kvfXpzNTl/6ehnTngNeUiS1Ao69uxbugHL1BVaT1gUX7BgobrdQPvWRgH2j2hOyBw7bEPNEA==
dependencies:
prettier ">=2.3"

prettier-plugin-pkg@^0.16.0:
version "0.16.0"
resolved "https://registry.yarnpkg.com/prettier-plugin-pkg/-/prettier-plugin-pkg-0.16.0.tgz#eb2e063796a77bf6fd786f8d3699f3a17b8dac77"
Expand Down Expand Up @@ -10655,7 +10662,7 @@ prettier-plugin-toml@^0.3.1:
"@toml-tools/parser" "^0.3.1"
prettier "^1.16.0"

prettier@>=2.3.0, prettier@>=2.4.0, prettier@^1.16.0, prettier@^1.19.1, prettier@^2.6.2, prettier@^2.7.1:
prettier@>=2.3, prettier@>=2.3.0, prettier@>=2.4.0, prettier@^1.16.0, prettier@^1.19.1, prettier@^2.6.2, prettier@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
Expand Down

0 comments on commit ae3315f

Please sign in to comment.