
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
eslint-plugin-sequelize-node
Advanced tools
Collection of custom linting rules for Sequelize NodeJS
yarn add eslint-plugin-sequelize-node
{
"extends": [],
"rules": {
"sequelize-node/no-allow-null-true": "error"
},
"env": {},
"plugins": ["sequelize-node"]
}
Adding a non nullable constraint on a column leads to PG acquiring a lock on the table while it validates the constraint. On larger tables, this can result in lock contention and other issues on the Database.
As an alternative you can write a raw SQL to safely add, validate without PG having to block writes while the constraint is being added.
The following shows how you can add the constraint on an existing column. If you are adding a new column (via addColumn) with allowNull: false, best to add the column first, then add the constraint of NOT NULL safely, like mentioned below using the four statements:
1. ALTER TABLE $table-name ADD CONSTRAINT $constraint-name CHECK ($column-name IS NOT NULL) NOT VALID;
2. ALTER TABLE $table-name validate CONSTRAINT $constraint-name; -- performs seq scan but doesn't block read/writes.
3. ALTER TABLE $table-name ALTER COLUMN workspace SET NOT NULL;
4. ALTER TABLE $table-name DROP CONSTRAINT $constraint-name;
NOTE: Depending on the size of the table, the validate
instruction
can take a while.
Requires that an index created or dropped via raw SQL to include the 'CONCURRENTLY' keyword to avoid excessive locking.
Using removeIndex
does not allow setting concurrently: true
as an option for removing the index.
For that reason, this rule would disallow usage of this function in favor for a raw SQL query with
CONCURRENTLY
:
DROP INDEX CONCURRENTLY IF EXISTS my_index
Do not use references as part of addColumn
, changeColumn
,addConstraint
or
createTable
. Instead use raw SQL to add foreign key/references to a column with
a NOT VALID
.
NOT VALID
on an ALTER
statement for foreign key does not
block writes against the referred table, thus making it a
safer operation to run on large production tables. You
can manually run VALIDATE CONSTRAINT if you desire.
For createTable
its preferrable to add the column first, then
using queryInterface.query add the constraint using raw SQL.
Example:
ALTER TABLE "users" ADD FOREIGN KEY ("level_id") REFERENCES "level" ("id") NOT VALID;
Tests
yarn test
Prettier
yarn pretty
version
in package.json
, create a PR and merge it to main
main
git checkout main && git pull
git tag v<$version>
(same version
as in package.json
). Example: git tag v0.1.0
git push --tags origin
publish
job.
FAQs
Custom linting rules for Sequelize NodeJS
The npm package eslint-plugin-sequelize-node receives a total of 1,433 weekly downloads. As such, eslint-plugin-sequelize-node popularity was classified as popular.
We found that eslint-plugin-sequelize-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.