@agjjquery/coding-style
v1.0.0
Published
Shared ESLint, Stylelint and Prettier configuration for agjjQuery plugins
Readme
agjjQuery Coding Style
Description
agjjQuery coding style is a shared ESLint and Stylelint configuration package for agjjQuery.org jQuery plugins. It provides a single source of truth for coding style rules so that all agjjQuery plugins share consistent linting without duplicating configuration across repositories.
agjjQuery coding style is an agjjQuery.org project.
Usage
The package exports a createConfig function that returns a complete ESLint flat configuration array for TypeScript projects. TypeScript and a tsconfig.json in the project root are required. Node.js ≥ 18.18.0 is required.
With npm or Yarn
This package offers support for the npm and Yarn dependency managers. You can find the package online on npmjs.com.
Install using npm
Run this command to install the package using npm:
npm install --save-dev @agjjquery/coding-styleInstall using Yarn
Run this command to install the package using Yarn:
yarn add --dev @agjjquery/coding-styleOnce installed, create or update your eslint.config.mjs to use the shared configuration. Use .mjs if your project does not have "type": "module" in its package.json; if it does, eslint.config.js works equally well.
import createConfig from '@agjjquery/coding-style/eslint';
export default createConfig(['source/*.ts', 'tests/*.ts']);The first argument is an array of file glob patterns to lint. An optional second argument accepts an array of additional ESLint flat config objects to append, which is useful for applying per-file rule overrides:
import createConfig from '@agjjquery/coding-style/eslint';
export default createConfig(
['source/*.ts', 'examples/*.ts', 'tests/*.ts'],
[
{
files: ['examples/*.ts'],
rules: {
'jsdoc/require-file-overview': 'off',
},
},
]
);Note: After configuring ESLint, also add the shared Prettier settings — see the Prettier section below.
Prettier
The package also exports a shared Prettier configuration via @agjjquery/coding-style/prettier.
Instead of creating a .prettierrc.json file in each project, add a top-level "prettier" key to the project's package.json:
"prettier": "@agjjquery/coding-style/prettier"Prettier and the ESLint Prettier plugin both resolve configuration the same way, so eslint --fix will format code using the shared settings automatically.
Stylelint
The package also exports a shared Stylelint configuration via @agjjquery/coding-style/stylelint. Installation is the same as for ESLint — see the With npm or Yarn section above.
Once installed, create or update your stylelint.config.mjs to extend the shared configuration:
export default {
extends: [
'@agjjquery/coding-style/stylelint'
]
};The shared configuration includes all rules common across agjjQuery plugins. Rules that are specific to a plugin's own CSS class and ID naming conventions should be added directly in the plugin's stylelint.config.mjs:
export default {
extends: [
'@agjjquery/coding-style/stylelint'
],
rules: {
'selector-class-pattern': [
'myPlugin-[a-z-]+'
],
'selector-id-pattern': [
'myPlugin',
'myPlugin-[a-z-]+'
]
}
};Included Configuration
The shared ESLint configuration extends the following rule sets:
- Google TypeScript Style rules and Prettier formatting via
gts - JSDoc documentation rules via
eslint-plugin-jsdoc - QUnit rules via
eslint-plugin-qunit
Custom overrides are applied on top of those rule sets to match the agjjQuery coding style.
The shared Stylelint configuration extends:
- The Stylelint standard config via
stylelint-config-standard - Stylus support via
stylelint-stylus
Help Requests
Please post any questions in the discussions area on GitHub if you need help.
If you discover a bug please open an issue on GitHub. When submitting an issue please use our issue templates.
Contributing
Please read our contributing guidelines if you want to contribute.
You can contribute financially by becoming a patron at patreon.com/agjopensource to support agjjQuery coding style and other agjjQuery.org projects.
Acknowledgements
This project was started by Andrew G. Johnson (@andrewgjohnson).
Full list of contributors:
Our security policies and procedures come via the atomist/samples project. Our issue templates come via the tensorflow/tensorflow project. Our pull request template comes via the stevemao/github-issue-templates project.
Changelog
You can find all notable changes in the changelog.






