-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance ESLint plugin configuration and documentation
- Added support for eslint-plugin and package-json plugins in eslint.config.js. - Updated package.json with new keywords, repository details, and scripts for release management. - Improved README.md with installation instructions, usage examples, and release process details. - Refactored lib/index.js to dynamically read package.json and set up plugin metadata. - Enhanced enforce-package-type rule documentation for clarity. These changes improve the plugin's functionality, usability, and maintainability.
- Loading branch information
Showing
6 changed files
with
165 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"git": { | ||
"commitMessage": "chore: release v${version}", | ||
"tagName": "v${version}", | ||
"requireCleanWorkingDir": true, | ||
"requireUpstream": true | ||
}, | ||
"github": { | ||
"release": true, | ||
"releaseName": "v${version}" | ||
}, | ||
"npm": { | ||
"publish": true | ||
}, | ||
"hooks": { | ||
"before:init": ["npm run lint", "npm test"], | ||
"after:bump": "npm run format" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
import js from '@eslint/js'; | ||
import eslintPlugin from 'eslint-plugin-eslint-plugin'; | ||
import packageJson from 'eslint-plugin-package-json/configs/recommended'; | ||
import enforcePackageType from './lib/index.js'; | ||
|
||
export default [ | ||
js.configs.recommended, | ||
eslintPlugin.configs['flat/recommended'], | ||
...enforcePackageType.configs.recommended, | ||
packageJson, | ||
{ | ||
files: ['**/*.test.js'], | ||
...eslintPlugin.configs['flat/tests-recommended'] | ||
}, | ||
{ | ||
files: ['**/*.js'], | ||
languageOptions: { | ||
ecmaVersion: 2022, | ||
sourceType: 'module' | ||
} | ||
}, | ||
{ | ||
files: ['package.json'], | ||
plugins: { | ||
'enforce-package-type': { | ||
rules: { | ||
'enforce-package-type': (await import('./lib/rules/enforce-package-type.js')).default | ||
} | ||
} | ||
}, | ||
rules: { | ||
'enforce-package-type/enforce-package-type': 'error' | ||
}, | ||
languageOptions: { | ||
parser: (await import('jsonc-eslint-parser')).default | ||
} | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
import fs from 'fs'; | ||
import jsoncParser from 'jsonc-eslint-parser'; | ||
import {URL} from 'url'; | ||
import enforcePackageType from './rules/enforce-package-type.js'; | ||
|
||
export default { | ||
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')); | ||
|
||
const plugin = { | ||
meta: { | ||
name: pkg.name, | ||
version: pkg.version | ||
}, | ||
rules: { | ||
'enforce-package-type': enforcePackageType | ||
}, | ||
configs: { | ||
recommended: { | ||
plugins: ['enforce-package-type'], | ||
configs: {} | ||
}; | ||
|
||
// Assign configs after plugin object is created so we can reference it | ||
Object.assign(plugin.configs, { | ||
recommended: [ | ||
{ | ||
files: ['package.json'], | ||
plugins: { | ||
'enforce-package-type': plugin | ||
}, | ||
rules: { | ||
'enforce-package-type/enforce-package-type': 'error' | ||
}, | ||
languageOptions: { | ||
parser: jsoncParser | ||
} | ||
} | ||
} | ||
}; | ||
] | ||
}); | ||
|
||
export default plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters